本文整理匯總了Java中org.apache.hadoop.hbase.client.Result.cellScanner方法的典型用法代碼示例。如果您正苦於以下問題:Java Result.cellScanner方法的具體用法?Java Result.cellScanner怎麽用?Java Result.cellScanner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.Result
的用法示例。
在下文中一共展示了Result.cellScanner方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: verifyRowFromMap
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
protected static void verifyRowFromMap(ImmutableBytesWritable key, Result result)
throws IOException {
byte[] row = key.get();
CellScanner scanner = result.cellScanner();
while (scanner.advance()) {
Cell cell = scanner.current();
//assert that all Cells in the Result have the same key
Assert.assertEquals(0, Bytes.compareTo(row, 0, row.length,
cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
}
for (int j = 0; j < FAMILIES.length; j++) {
byte[] actual = result.getValue(FAMILIES[j], null);
Assert.assertArrayEquals("Row in snapshot does not match, expected:" + Bytes.toString(row)
+ " ,actual:" + Bytes.toString(actual), row, actual);
}
}
示例2: postScannerNext
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
@Override
public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> e,
InternalScanner s, List<Result> results, int limit, boolean hasMore) throws IOException {
if (checkTagPresence) {
if (results.size() > 0) {
// Check tag presence in the 1st cell in 1st Result
Result result = results.get(0);
CellScanner cellScanner = result.cellScanner();
if (cellScanner.advance()) {
Cell cell = cellScanner.current();
tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
cell.getTagsLength());
}
}
}
return hasMore;
}
示例3: scanRow
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
private void scanRow(final Result result, final RowKeyBuilder simpleRowKeyBuilder, final RowKey rowKey,
final StatisticType statsType, EventStoreTimeIntervalEnum interval) throws IOException {
final CellScanner cellScanner = result.cellScanner();
while (cellScanner.advance()) {
final Cell cell = cellScanner.current();
// get the column qualifier
final byte[] bTimeQualifier = new byte[cell.getQualifierLength()];
System.arraycopy(cell.getQualifierArray(), cell.getQualifierOffset(), bTimeQualifier, 0,
cell.getQualifierLength());
// convert this into a true time, albeit rounded to the column
// interval granularity
final long columnIntervalNo = Bytes.toInt(bTimeQualifier);
final long columnIntervalSize = interval.columnInterval();
final long columnTimeComponentMillis = columnIntervalNo * columnIntervalSize;
final long rowKeyPartialTimeMillis = simpleRowKeyBuilder.getPartialTimestamp(rowKey);
final long fullTimestamp = rowKeyPartialTimeMillis + columnTimeComponentMillis;
LOGGER.debug("Col: [" + ByteArrayUtils.byteArrayToHex(bTimeQualifier) + "] - ["
+ Bytes.toInt(bTimeQualifier) + "] - [" + fullTimestamp + "] - ["
+ DateUtil.createNormalDateTimeString(fullTimestamp) + "]");
final byte[] bValue = new byte[cell.getValueLength()];
System.arraycopy(cell.getValueArray(), cell.getValueOffset(), bValue, 0, cell.getValueLength());
switch (statsType) {
case VALUE:
final ValueCellValue cellValue = new ValueCellValue(bValue);
LOGGER.debug("Val: " + cellValue);
break;
case COUNT:
LOGGER.debug("Val: " + Bytes.toLong(bValue));
break;
}
}
}
示例4: updateValueSize
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
void updateValueSize(final Result r) throws IOException {
if (r == null || !isRandomValueSize()) return;
int size = 0;
for (CellScanner scanner = r.cellScanner(); scanner.advance();) {
size += scanner.current().getValueLength();
}
updateValueSize(size);
}
示例5: verifyGet
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
@Override
protected void verifyGet(final byte[] row, final String visString, final int expected,
final boolean nullExpected, final String... auths) throws IOException,
InterruptedException {
PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf1);
Table table2 = connection.getTable(TableName.valueOf(TABLE_NAME))) {
CellScanner cellScanner;
Cell current;
Get get = new Get(row);
get.setAuthorizations(new Authorizations(auths));
Result result = table2.get(get);
cellScanner = result.cellScanner();
boolean advance = cellScanner.advance();
if (nullExpected) {
assertTrue(!advance);
return null;
}
current = cellScanner.current();
assertArrayEquals(CellUtil.cloneRow(current), row);
assertEquals(expected, TestCoprocessorForTagsAtSink.tags.size());
boolean foundNonVisTag = false;
for(Tag t : TestCoprocessorForTagsAtSink.tags) {
if(t.getType() == NON_VIS_TAG_TYPE) {
assertEquals(TEMP, Bytes.toString(t.getValue()));
foundNonVisTag = true;
break;
}
}
doAssert(row, visString);
assertTrue(foundNonVisTag);
return null;
}
}
};
USER1.runAs(scanAction);
}
示例6: scanUIDTable
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
public void scanUIDTable() throws IOException {
// TableConfiguration tableConfiguration = getTableConfiguration();
final HBaseUniqueIdForwardMapTable uidTable = new HBaseUniqueIdForwardMapTable(hBaseConnection);
// UniqueIdCache uniqueIdCache = getUinqueIdCache(tableConfiguration);
final Scan scan = new Scan().setMaxVersions(1).addFamily(Bytes.toBytes("i"));
final Table tableInterface = uidTable.getTable();
final ResultScanner scanner = tableInterface.getScanner(scan);
final Writer writerU = Files.newBufferedWriter(new File("UID_U.csv").toPath(), UTF_8);
final Writer writerV = Files.newBufferedWriter(new File("UID_V.csv").toPath(), UTF_8);
String line = "";
LOGGER.info("Dumping contents of UID table");
for (final Result result : scanner) {
final byte[] rowKey = result.getRow();
String colQual;
String type = "";
byte[] valueColValue = null;
final CellScanner cellScanner = result.cellScanner();
while (cellScanner.advance()) {
final Cell cell = cellScanner.current();
// get the column qualifier
final byte[] bcolQual = new byte[cell.getQualifierLength()];
System.arraycopy(cell.getQualifierArray(), cell.getQualifierOffset(), bcolQual, 0,
cell.getQualifierLength());
colQual = Bytes.toString(bcolQual);
final byte[] bCellVal = new byte[cell.getValueLength()];
System.arraycopy(cell.getValueArray(), cell.getValueOffset(), bCellVal, 0, cell.getValueLength());
if (colQual.equals("t")) {
// type column
type = Bytes.toString(bCellVal);
} else if (colQual.equals("v")) {
// value column
valueColValue = bCellVal;
}
}
if (type.equals("U")) {
// row key is a UID o convert that to hex and convert the value
// col value to a string
line = type + "," + ByteArrayUtils.byteArrayToHex(rowKey) + "," + Bytes.toString(valueColValue);
writerU.write(line + "\n");
} else {
line = type + "," + Bytes.toString(rowKey) + "," + ByteArrayUtils.byteArrayToHex(valueColValue);
writerV.write(line + "\n");
}
}
scanner.close();
HBaseTable.closeTable(tableInterface);
writerU.close();
writerV.close();
}
示例7: verifyAllEditsMadeItIn
import org.apache.hadoop.hbase.client.Result; //導入方法依賴的package包/類
/**
* @param fs
* @param conf
* @param edits
* @param region
* @return Return how many edits seen.
* @throws IOException
*/
private int verifyAllEditsMadeItIn(final FileSystem fs, final Configuration conf,
final Path edits, final HRegion region)
throws IOException {
int count = 0;
// Based on HRegion#replayRecoveredEdits
WAL.Reader reader = null;
try {
reader = WALFactory.createReader(fs, edits, conf);
WAL.Entry entry;
while ((entry = reader.next()) != null) {
WALKey key = entry.getKey();
WALEdit val = entry.getEdit();
count++;
// Check this edit is for this region.
if (!Bytes.equals(key.getEncodedRegionName(),
region.getRegionInfo().getEncodedNameAsBytes())) {
continue;
}
Cell previous = null;
for (Cell cell: val.getCells()) {
if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) continue;
if (previous != null && CellComparator.compareRows(previous, cell) == 0) continue;
previous = cell;
Get g = new Get(CellUtil.cloneRow(cell));
Result r = region.get(g);
boolean found = false;
for (CellScanner scanner = r.cellScanner(); scanner.advance();) {
Cell current = scanner.current();
if (CellComparator.compare(cell, current, true) == 0) {
found = true;
break;
}
}
assertTrue("Failed to find " + cell, found);
}
}
} finally {
if (reader != null) reader.close();
}
return count;
}