本文整理汇总了Java中org.apache.hadoop.hbase.thrift.generated.TScan.setFilterString方法的典型用法代码示例。如果您正苦于以下问题:Java TScan.setFilterString方法的具体用法?Java TScan.setFilterString怎么用?Java TScan.setFilterString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.thrift.generated.TScan
的用法示例。
在下文中一共展示了TScan.setFilterString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rowFilter
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
@Test
public void rowFilter() throws Exception {
String TABLE_NAME = "UIH_OverallItemInfo";
List<TRowResult> results = null;
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
//
String filterString = "RowFilter(=, 'regexstring:00[1-3]00')";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
long beg = System.currentTimeMillis();
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan, attributes);// 可以attributes=null
results = client.scannerGetList(scannerId, 10);// 讀取幾筆
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
client.scannerClose(scannerId);// 一定要關閉
}
}
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
printlnResult(results);
}
示例2: prefixFilter
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
@Test
public void prefixFilter() throws Exception {
String TABLE_NAME = "UIH_OverallItemInfo";
List<TRowResult> results = null;
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
//
String filterString = "PrefixFilter('1000|B101|A17P')";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
long beg = System.currentTimeMillis();
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan, attributes);// 可以attributes=null
results = client.scannerGetList(scannerId, 10);// 讀取幾筆
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
client.scannerClose(scannerId);// 一定要關閉
}
}
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
printlnResult(results);
}
示例3: keyOnlyFilter
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
/**
* 只傳回key值,value屏蔽掉
*
* @throws Exception
*/
@Test
public void keyOnlyFilter() throws Exception {
String TABLE_NAME = "UIH_OverallItemInfo";
List<TRowResult> results = null;
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
// KeyOnlyFilter()
String filterString = "KeyOnlyFilter()";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
long beg = System.currentTimeMillis();
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan, attributes);// 可以attributes=null
results = client.scannerGetList(scannerId, 10);// 讀取幾筆
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
client.scannerClose(scannerId);// 一定要關閉
}
}
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
//
printlnResult(results);
}
示例4: firstKeyOnlyFilter
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
/**
* 只傳回第一個keyValue
*
* @throws Exception
*/
@Test
public void firstKeyOnlyFilter() throws Exception {
String TABLE_NAME = "UIH_OverallItemInfo";
List<TRowResult> results = null;
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
// FirstKeyOnlyFilter()
String filterString = "FirstKeyOnlyFilter()";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
long beg = System.currentTimeMillis();
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan, attributes);// 可以attributes=null
results = client.scannerGetList(scannerId, 10);// 讀取幾筆
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
client.scannerClose(scannerId);// 一定要關閉
}
}
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
//
printlnResult(results);
}
示例5: scanNotClose
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
@Test
public void scanNotClose() throws Exception {
String TABLE_NAME = "ItemCreation_Buffer_Item_B";
String cloumn = "ItemInfo:ProcessResult";
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
columns.add(ByteBufferHelper.toByteBuffer(cloumn));
columns.add(ByteBufferHelper.toByteBuffer("ItemInfo:ProcessStatus"));
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
//
String filterString = "SingleColumnValueFilter('ItemInfo','ProcessResult',=,'substring:Test')";// substring:A17P
filterString += " AND SingleColumnValueFilter('ItemInfo','ProcessStatus',=,'substring:Test')";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
int rowCount = 0;
long beg = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan,
attributes);// 可以attributes=null
// System.out.println(scannerId);
while (true) {
List<TRowResult> results = client.scannerGet(scannerId);
if (results.isEmpty()) {
break;
}
System.out.println(i + ", " + scannerId);
// printlnResult(results);
rowCount++;
if (rowCount > 0) {
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
// 故意不關
// client.scannerClose(scannerId);// 一定要關閉
}
}
}
//
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
}
示例6: singleColumnValueFilter
import org.apache.hadoop.hbase.thrift.generated.TScan; //导入方法依赖的package包/类
@Test
public void singleColumnValueFilter() throws Exception {
String TABLE_NAME = "UIH_OverallItemInfo";
String cloumn = "CommonInfo:SellerID";
List<TRowResult> results = null;
//
List<ByteBuffer> columns = new LinkedList<ByteBuffer>();
columns.add(ByteBufferHelper.toByteBuffer(cloumn));
columns.add(ByteBufferHelper.toByteBuffer("CommonInfo:SellerItemNumber"));
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<ByteBuffer, ByteBuffer>();
//
TScan scan = new TScan();
scan.setCaching(200);
// SingleColumnValueFilter('<family>', '<qualifier>', <compare
// operator>, '<comparator>', <filterIfColumnMissing_boolean>,
// <latest_version_boolean>)
// 注意: 只有當COLUMNS中包含SingleColumnValueFilter提到的欄位時,
// 該SingleColumnValueFilter才有效的
String filterString = "SingleColumnValueFilter('CommonInfo','SellerID',=,'binary:A17P')";// substring:A17P
filterString += " AND SingleColumnValueFilter('CommonInfo','SellerItemNumber',=,'binary:AUDI15028005')";
scan.setFilterString(ByteBufferHelper.toByteBuffer(filterString));
scan.setColumns(columns);
//
int scannerId = 0;
long beg = System.currentTimeMillis();
try {
scannerId = client.scannerOpenWithScan(
ByteBufferHelper.toByteBuffer(TABLE_NAME), scan, attributes);// 可以attributes=null
results = client.scannerGetList(scannerId, 10);// 讀取幾筆
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (scannerId >= 0) {
client.scannerClose(scannerId);// 一定要關閉
}
}
long end = System.currentTimeMillis();
System.out.println((end - beg) + " at mills.");
printlnResult(results);
}