本文整理匯總了Java中org.apache.hadoop.hbase.client.HTableInterface.getScanner方法的典型用法代碼示例。如果您正苦於以下問題:Java HTableInterface.getScanner方法的具體用法?Java HTableInterface.getScanner怎麽用?Java HTableInterface.getScanner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HTableInterface
的用法示例。
在下文中一共展示了HTableInterface.getScanner方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: QueryAll
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
public static void QueryAll(String tableName) {
try {
HTableInterface table = conn.getTable(tableName);
ResultScanner rs = table.getScanner(new Scan());
for (Result r : rs) {
System.out.println("rowkey:" + new String(r.getRow()));
for (KeyValue keyValue : r.raw()) {
System.out.println("column:" + new String(keyValue.getFamily())
+ "====value:" + new String(keyValue.getValue()));
}
}
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: verifyScan
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
private void verifyScan(HTableInterface table, Scan scan, List<KeyValue> expectedCells) throws Exception {
List<Cell> actualCells = new ArrayList<>();
try (ResultScanner scanner = table.getScanner(scan)) {
Result[] results = scanner.next(expectedCells.size() + 1);
for (Result result : results) {
actualCells.addAll(Lists.newArrayList(result.rawCells()));
}
Assert.assertEquals(expectedCells, actualCells);
}
}
示例3: getNextSetOfTimeRegions
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
@Nullable
private TimeRegions getNextSetOfTimeRegions(HTableInterface stateTable, long time) throws IOException {
byte[] timeBytes = Bytes.toBytes(getInvertedTime(time));
Scan scan = new Scan(makeTimeRegionKey(timeBytes, EMPTY_BYTE_ARRAY), REGION_TIME_KEY_PREFIX_STOP);
scan.addColumn(FAMILY, REGION_TIME_COL);
long currentRegionTime = -1;
SortedSet<byte[]> regions = new TreeSet<>(Bytes.BYTES_COMPARATOR);
Result next;
try (ResultScanner scanner = stateTable.getScanner(scan)) {
while ((next = scanner.next()) != null) {
Map.Entry<Long, byte[]> timeRegion = getTimeRegion(next.getRow());
// Stop if reached next time value
if (currentRegionTime == -1) {
currentRegionTime = timeRegion.getKey();
} else if (timeRegion.getKey() < currentRegionTime) {
break;
} else if (timeRegion.getKey() > currentRegionTime) {
throw new IllegalStateException(
String.format("Got out of order time %d when expecting time less than or equal to %d",
timeRegion.getKey(), currentRegionTime));
}
regions.add(timeRegion.getValue());
}
}
return regions.isEmpty() ? null : new TimeRegions(currentRegionTime, Collections.unmodifiableSortedSet(regions));
}
示例4: deleteFromScan
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
@VisibleForTesting
void deleteFromScan(HTableInterface stateTable, Scan scan) throws IOException {
try (ResultScanner scanner = stateTable.getScanner(scan)) {
Result next;
while ((next = scanner.next()) != null) {
stateTable.delete(new Delete(next.getRow()));
}
}
}