本文整理匯總了Java中org.apache.hadoop.hbase.client.Increment.getRow方法的典型用法代碼示例。如果您正苦於以下問題:Java Increment.getRow方法的具體用法?Java Increment.getRow怎麽用?Java Increment.getRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.Increment
的用法示例。
在下文中一共展示了Increment.getRow方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onAfterCoalesce
import org.apache.hadoop.hbase.client.Increment; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void onAfterCoalesce(Iterable<Increment> increments) {
for (Increment inc : increments) {
byte[] row = inc.getRow();
Map<byte[], NavigableMap<byte[], Long>> families = null;
try {
families = (Map<byte[], NavigableMap<byte[], Long>>)
refGetFamilyMap.invoke(inc);
} catch (Exception e) {
Throwables.propagate(e);
}
for (byte[] family : families.keySet()) {
NavigableMap<byte[], Long> qualifiers = families.get(family);
for (Map.Entry<byte[], Long> entry : qualifiers.entrySet()) {
byte[] qualifier = entry.getKey();
Long count = entry.getValue();
StringBuilder b = new StringBuilder(20);
b.append(new String(row, Charsets.UTF_8));
b.append(':');
b.append(new String(qualifier, Charsets.UTF_8));
String key = b.toString();
Assert.assertEquals("Expected counts don't match observed for " + key,
expectedCounts.get(key), count);
}
}
}
}
示例2: getIncrementCurrentValue
import org.apache.hadoop.hbase.client.Increment; //導入方法依賴的package包/類
/**
* Do a specific Get on passed <code>columnFamily</code> and column qualifiers from
* <code>incrementCoordinates</code> only.
*
* @param increment
* @param columnFamily
* @param increments
* @return Return the Cells to Increment
* @throws IOException
*/
private List<Cell> getIncrementCurrentValue(final Increment increment, byte[] columnFamily,
final List<Cell> increments, final IsolationLevel isolation) throws IOException {
Get get = new Get(increment.getRow());
if (isolation != null) get.setIsolationLevel(isolation);
for (Cell cell : increments) {
get.addColumn(columnFamily, CellUtil.cloneQualifier(cell));
}
TimeRange tr = increment.getTimeRange();
if (tr != null) {
get.setTimeRange(tr.getMin(), tr.getMax());
}
return get(get, false);
}
示例3: applyIncrementsToColumnFamily
import org.apache.hadoop.hbase.client.Increment; //導入方法依賴的package包/類
/**
* Apply increments to a column family.
*
* @param sortedIncrements The passed in increments to apply MUST be sorted so that they match the
* order that they appear in the Get results (get results will be sorted on return).
* Otherwise, we won't be able to find the existing values if the cells are not specified
* in order by the client since cells are in an array list.
* @return Resulting increments after <code>sortedIncrements</code> have been applied to current
* values (if any -- else passed increment is the final result).
* @throws IOException
* @islation Isolation level to use when running the 'get'. Pass null for default.
*/
private List<Cell> applyIncrementsToColumnFamily(Increment increment, byte[] columnFamilyName,
List<Cell> sortedIncrements, long now, long mvccNum, List<Cell> allKVs,
final IsolationLevel isolation) throws IOException {
List<Cell> results = new ArrayList<Cell>(sortedIncrements.size());
byte[] row = increment.getRow();
// Get previous values for all columns in this family
List<Cell> currentValues =
getIncrementCurrentValue(increment, columnFamilyName, sortedIncrements, isolation);
// Iterate the input columns and update existing values if they were found,
// otherwise
// add new column initialized to the increment amount
int idx = 0;
for (int i = 0; i < sortedIncrements.size(); i++) {
Cell inc = sortedIncrements.get(i);
long incrementAmount = getLongValue(inc);
// If increment amount == 0, then don't write this Increment to the WAL.
boolean writeBack = (incrementAmount != 0);
// Carry forward any tags that might have been added by a coprocessor.
List<Tag> tags = Tag.carryForwardTags(inc);
Cell currentValue = null;
long ts = now;
if (idx < currentValues.size() && CellUtil.matchingQualifier(currentValues.get(idx), inc)) {
currentValue = currentValues.get(idx);
ts = Math.max(now, currentValue.getTimestamp());
incrementAmount += getLongValue(currentValue);
// Carry forward all tags
tags = Tag.carryForwardTags(tags, currentValue);
if (i < (sortedIncrements.size() - 1) && !CellUtil
.matchingQualifier(inc, sortedIncrements.get(i + 1))) idx++;
}
// Append new incremented KeyValue to list
byte[] qualifier = CellUtil.cloneQualifier(inc);
byte[] incrementAmountInBytes = Bytes.toBytes(incrementAmount);
tags = carryForwardTTLTag(tags, increment);
Cell newValue =
new KeyValue(row, 0, row.length, columnFamilyName, 0, columnFamilyName.length, qualifier,
0, qualifier.length, ts, KeyValue.Type.Put, incrementAmountInBytes, 0,
incrementAmountInBytes.length, tags);
// Don't set an mvcc if none specified. The mvcc may be assigned later in
// case where we
// write the memstore AFTER we sync our edit to the log.
if (mvccNum != MultiVersionConcurrencyControl.NO_WRITE_NUMBER) {
CellUtil.setSequenceId(newValue, mvccNum);
}
// Give coprocessors a chance to update the new cell
if (coprocessorHost != null) {
newValue = coprocessorHost
.postMutationBeforeWAL(RegionObserver.MutationType.INCREMENT, increment, currentValue,
newValue);
}
allKVs.add(newValue);
if (writeBack) {
results.add(newValue);
}
}
return results;
}