我需要根据HBase MAP减少的开始和结束EPOC值(长度为长)过滤EPOC值

  • 本文关键字:EPOC 结束 过滤 开始 HBase MAP hbase
  • 更新时间 :
  • 英文 :


我通过扩展WritableByteArrayComparable类以比较HBase中的长度来编写自定义比较器。这是供参考的代码。

import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
import org.apache.hadoop.hbase.util.Bytes;
public class LongWritableComparable extends WritableByteArrayComparable {
public LongWritableComparable() {
    super();
}
public LongWritableComparable(byte[] value) {
    super(value);
}
public LongWritableComparable(Long value) {
    super(Bytes.toBytes(value));
}

@Override
public int compareTo(byte[] otherValue, int arg1, int arg2) {
    // TODO Auto-generated method stub
    byte[] thisValue = this.getValue();
    long thisLong = Bytes.toLong(thisValue);
    long otherLong = Bytes.toLong(otherValue,arg1,arg2);
    if (thisLong == otherLong) {
        return 0;
    }
    if (thisLong < otherLong) {
        return -1;
    }
    return 1;
  }
}

我在驱动程序类中使用了类似的比较器:

long endtimelongval = Long.valueOf(datetime.get("endDate").getMillis()).longValue();
LongWritableComparable etval=new LongWritableComparable(endtimelongval);
SingleColumnValueFilter eventCreationEndTimeFilter = new SingleColumnValueFilter(Bytes.toBytes("d"), Bytes.toBytes("et"), CompareOp.LESS,etval );

当我执行上述代码时,它会以错误:

进行。
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.hbase.filter.SingleColumnValueFilter.<init>([B[BLorg/apache/hadoop/hbase/filter/CompareFilter$CompareOp;Lorg/apache/hadoop/hbase/filter/WritableByteArrayComparable;)V

SingleColumnValueFilter行中。

任何人都帮助我解决了您的解决方案。预先感谢。

我找到了一种方法,无需编写自定义比较器。getmillis()将在毫里返回几秒钟,但是在我们的HBase表中,我们在几秒钟内具有EPOC值,因此我更改为以下,并且可以正常工作。
long startlongval = long.valueof(dateTime.get(" startDate")。getmillis())。longValue()/1000L;
SingleColumnValueFilter EventCreationStartTimeFilter = new SinglecolumnValueFilter(bytes.tobytes(" d"),bytes.tobytes(" et"),compareop.greater.greater,bytes.tobytes(startlongval);

相关内容

最新更新