Home > database >  Hbase custom filters
Hbase custom filters

Time:10-03

Hbase's own original filter, calls are sure
But to write their own filter has been an error, can't find the class
The CLASSPATH is set to hbase/lib folder, custom filters are packaged jar copied to each server hbase/lib folder
Hbase is restarted,
Could you tell me who know how to return a responsibility?
An error log:
The Exception in the thread "main" Java. Lang. NoClassDefFoundError: hadoop/FlowFilter
At the hadoop. Shellcom. FilterHbase (shellcom. Java: 471)
At the hadoop. Shellcom. Main (shellcom. Java: 511)
At sun. Reflect. NativeMethodAccessorImpl. Invoke0 (Native Method)
At sun. Reflect. NativeMethodAccessorImpl. Invoke (NativeMethodAccessorImpl. Java: 57)
At sun. Reflect. DelegatingMethodAccessorImpl. Invoke (43) DelegatingMethodAccessorImpl. Java:
The at Java. Lang. Reflect. Method. Invoke (606) Method. The Java:
At org, apache hadoop. Util. RunJar. Main (197) RunJar. Java:
Under Caused by: Java. Lang. ClassNotFoundException: hadoop. FlowFilter
The at java.net.URLClassLoader$1.run URLClassLoader. Java: (366)
The at java.net.URLClassLoader$1.run URLClassLoader. Java: (355)
The at Java. Security. The AccessController. DoPrivileged (Native Method)
The at java.net.URLClassLoader.findClass URLClassLoader. Java: (354)
The at Java. Lang. This. LoadClass (425). This Java:
The at Java. Lang. This. LoadClass (358). This Java:

Custom filters RowFilter source code: (copy)
Package hadoop;

Import org, apache hadoop. Hbase. Filter. *;
Import org, apache hadoop. Hbase. KeyValue;
Import org, apache hadoop. Hbase. Client. Scan;

Import the Java. Util. List;

Public class FlowFilter extends CompareFilter {

Private Boolean filterOutRow=false;

/* *
* Writable constructor, do not use.
*/
Public FlowFilter () {
Super ();
}

/* *
* Constructor.
* @ param rowCompareOp the compare the op for row matching
* @ param rowComparator the comparator for row matching
*/
Public FlowFilter (final CompareOp rowCompareOp,
Final WritableByteArrayComparable rowComparator) {
Super (rowCompareOp rowComparator);
}

@ Override
Public void reset () {
Enclosing filterOutRow=false;
}

@ Override
Public ReturnCode filterKeyValue (KeyValue v) {
If (this. FilterOutRow) {
Return ReturnCode. NEXT_ROW;
}
Return ReturnCode. INCLUDE;
}

@ Override
Public Boolean filterRowKey (byte [] data, int offset, int length) {
If (doCompare (this.com and this.com parator pareOp, data, offset, length)) {
Enclosing filterOutRow=true;
}
Return this. FilterOutRow;
}

@ Override
Public Boolean filterRow () {
Return this. FilterOutRow;
}
}

CodePudding user response:

For everyone a great god help ah
  • Related