本文整理汇总了Java中org.apache.hadoop.hbase.CellUtil.cloneQualifier方法的典型用法代码示例。如果您正苦于以下问题:Java CellUtil.cloneQualifier方法的具体用法?Java CellUtil.cloneQualifier怎么用?Java CellUtil.cloneQualifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.CellUtil
的用法示例。
在下文中一共展示了CellUtil.cloneQualifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recoverClusteringResult
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
public static Result recoverClusteringResult(Result raw, byte[] family, byte[] qualifier) {
if (raw == null) return null;
byte[][] indexColumn = IndexPutParser.parseIndexRowKey(raw.getRow());
List<KeyValue> list = new ArrayList<>(raw.listCells().size() + 1);
for (Cell cell : raw.listCells()) {
byte[] tag = cell.getTagsArray();
if (tag != null && tag.length > KeyValue.MAX_TAGS_LENGTH) tag = null;
KeyValue kv =
new KeyValue(indexColumn[0], CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell),
cell.getTimestamp(), KeyValue.Type.codeToType(cell.getTypeByte()),
CellUtil.cloneValue(cell), tag);
list.add(kv);
}
list.add(new KeyValue(indexColumn[0], family, qualifier, indexColumn[1]));
Collections.sort(list, KeyValue.COMPARATOR);
return new Result(list);
}
示例2: resultToString
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
protected String resultToString(Result result) {
StringBuilder sb = new StringBuilder();
sb.append("{").append(keyToString(result.getRow())).append(":");
for (Cell cell : result.listCells()) {
byte[] f = CellUtil.cloneFamily(cell);
byte[] q = CellUtil.cloneQualifier(cell);
RangeDescription range = rangeMap.get(Bytes.add(f, q));
sb.append("[").append(Bytes.toString(f)).append(":").append(Bytes.toString(q)).append("->");
if (notPrintingSet.contains(q)) sb.append("skipped random value");
else sb.append(DataType.byteToString(range.dataType, CellUtil.cloneValue(cell)));
sb.append("]");
}
sb.append("}");
return sb.toString();
}
示例3: stringifyKvs
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
static String stringifyKvs(Collection<Cell> kvs) {
StringBuilder out = new StringBuilder();
out.append("[");
if (kvs != null) {
for (Cell kv : kvs) {
byte[] col = CellUtil.cloneQualifier(kv);
byte[] val = CellUtil.cloneValue(kv);
if (Bytes.equals(col, COUNTER)) {
out.append(Bytes.toStringBinary(col) + ":" +
Bytes.toInt(val) + " ");
} else {
out.append(Bytes.toStringBinary(col) + ":" +
Bytes.toStringBinary(val) + " ");
}
}
}
out.append("]");
return out.toString();
}
示例4: parsePut
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override protected Map<TableName, Put> parsePut(Put put, boolean serverSide) {
Map<TableName, Put> map = new HashMap<>();
byte[] row = put.getRow();
for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) {
byte[] family = entry.getKey();
for (Cell cell : entry.getValue()) {
byte[] q = CellUtil.cloneQualifier(cell);
if (tableRelation.isIndexColumn(family, q)) {
TableName indexTableName = tableRelation.getIndexTableName(family, q);
Put newPut = new Put(getIndexRow(row, CellUtil.cloneValue(cell)));
if (serverSide) newPut
.addColumn(IndexType.SEDONDARY_FAMILY_BYTES, (byte[]) null, cell.getTimestamp(),
null);
else newPut.addColumn(IndexType.SEDONDARY_FAMILY_BYTES, null, null);
map.put(indexTableName, newPut);
}
}
}
tableRelation.getIndexFamilyMap();
return map;
}
示例5: SerializableCell
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
* Copy data from {@code Cell} instance.
*
* @param cell
*/
public SerializableCell( Cell cell ) {
rowKey = CellUtil.cloneRow(cell);
family = CellUtil.cloneFamily(cell);
qualifier = CellUtil.cloneQualifier(cell);
value = CellUtil.cloneValue(cell);
timestamp = cell.getTimestamp();
type = cell.getTypeByte();
}
示例6: deleteFromHBase
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));
List<TColumn> columns = new ArrayList<TColumn>();
long rowTimestamp = in.getTimeStamp();
if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
out.setTimestamp(rowTimestamp);
}
// Map<family, List<KeyValue>>
for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
in.getFamilyCellMap().entrySet()) {
TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
byte[] family = CellUtil.cloneFamily(cell);
byte[] qualifier = CellUtil.cloneQualifier(cell);
long timestamp = cell.getTimestamp();
if (family != null) {
column.setFamily(family);
}
if (qualifier != null) {
column.setQualifier(qualifier);
}
if (timestamp != HConstants.LATEST_TIMESTAMP) {
column.setTimestamp(timestamp);
}
}
columns.add(column);
}
out.setColumns(columns);
return out;
}
示例7: assertNResult
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private void assertNResult(Result result, byte [] row,
byte [][] families, byte [][] qualifiers, byte [][] values,
int [][] idxs)
throws Exception {
assertTrue("Expected row [" + Bytes.toString(row) + "] " +
"Got row [" + Bytes.toString(result.getRow()) +"]",
equals(row, result.getRow()));
assertTrue("Expected " + idxs.length + " keys but result contains "
+ result.size(), result.size() == idxs.length);
Cell [] keys = result.rawCells();
for(int i=0;i<keys.length;i++) {
byte [] family = families[idxs[i][0]];
byte [] qualifier = qualifiers[idxs[i][1]];
byte [] value = values[idxs[i][2]];
Cell key = keys[i];
byte[] famb = CellUtil.cloneFamily(key);
byte[] qualb = CellUtil.cloneQualifier(key);
byte[] valb = CellUtil.cloneValue(key);
assertTrue("(" + i + ") Expected family [" + Bytes.toString(family)
+ "] " + "Got family [" + Bytes.toString(famb) + "]",
equals(family, famb));
assertTrue("(" + i + ") Expected qualifier [" + Bytes.toString(qualifier)
+ "] " + "Got qualifier [" + Bytes.toString(qualb) + "]",
equals(qualifier, qualb));
assertTrue("(" + i + ") Expected value [" + Bytes.toString(value) + "] "
+ "Got value [" + Bytes.toString(valb) + "]",
equals(value, valb));
}
}
示例8: parsePutList
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
* override this method to improve performance
*/
@Override protected Map<TableName, List<Put>> parsePutList(List<Put> puts, boolean serverSide) {
Map<TableName, List<Put>> map = new TreeMap<>();
for (Put put : puts) {
byte[] row = put.getRow();
for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) {
byte[] family = entry.getKey();
for (Cell cell : entry.getValue()) {
byte[] q = CellUtil.cloneQualifier(cell);
if (tableRelation.isIndexColumn(family, q)) {
TableName indexTableName = tableRelation.getIndexTableName(family, q);
List<Put> list = map.get(indexTableName);
if (list == null) {
list = new ArrayList<>();
map.put(indexTableName, list);
}
Put newPut = new Put(getIndexRow(row, CellUtil.cloneValue(cell)));
if (serverSide) newPut
.addColumn(IndexType.SEDONDARY_FAMILY_BYTES, (byte[]) null, cell.getTimestamp(),
null);
else newPut.addColumn(IndexType.SEDONDARY_FAMILY_BYTES, null, null);
list.add(newPut);
}
}
}
}
tableRelation.getIndexFamilyMap();
return map;
}
示例9: getMap
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
* Map of families to all versions of its qualifiers and values.
* <p>
* Returns a three level Map of the form:
* <code>Map&family,Map<qualifier,Map<timestamp,value>>></code>
* <p>
* Note: All other map returning methods make use of this map internally.
* @return map from families to qualifiers to versions
*/
public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> getMap() {
if (this.familyMap != null) {
return this.familyMap;
}
if(isEmpty()) {
return null;
}
this.familyMap = new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR);
for(Cell kv : this.cells) {
byte [] family = CellUtil.cloneFamily(kv);
NavigableMap<byte[], NavigableMap<Long, byte[]>> columnMap =
familyMap.get(family);
if(columnMap == null) {
columnMap = new TreeMap<byte[], NavigableMap<Long, byte[]>>
(Bytes.BYTES_COMPARATOR);
familyMap.put(family, columnMap);
}
byte [] qualifier = CellUtil.cloneQualifier(kv);
NavigableMap<Long, byte[]> versionMap = columnMap.get(qualifier);
if(versionMap == null) {
versionMap = new TreeMap<Long, byte[]>(new Comparator<Long>() {
@Override
public int compare(Long l1, Long l2) {
return l2.compareTo(l1);
}
});
columnMap.put(qualifier, versionMap);
}
Long timestamp = kv.getTimestamp();
byte [] value = CellUtil.cloneValue(kv);
versionMap.put(timestamp, value);
}
return this.familyMap;
}
示例10: filterKeyValue
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
public ReturnCode filterKeyValue(Cell cell) {
if (isSystemTable) {
return ReturnCode.INCLUDE;
}
if (prevFam.getBytes() == null
|| (Bytes.compareTo(prevFam.getBytes(), prevFam.getOffset(), prevFam.getLength(),
cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()) != 0)) {
prevFam.set(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
// Similar to VisibilityLabelFilter
familyMaxVersions = cfVsMaxVersions.get(prevFam);
// Family is changed. Just unset curQualifier.
prevQual.unset();
}
if (prevQual.getBytes() == null
|| (Bytes.compareTo(prevQual.getBytes(), prevQual.getOffset(),
prevQual.getLength(), cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength()) != 0)) {
prevQual.set(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength());
currentVersions = 0;
}
currentVersions++;
if (currentVersions > familyMaxVersions) {
return ReturnCode.SKIP;
}
// XXX: Compare in place, don't clone
byte[] family = CellUtil.cloneFamily(cell);
byte[] qualifier = CellUtil.cloneQualifier(cell);
switch (strategy) {
// Filter only by checking the table or CF permissions
case CHECK_TABLE_AND_CF_ONLY: {
if (authManager.authorize(user, table, family, qualifier, Permission.Action.READ)) {
return ReturnCode.INCLUDE;
}
}
break;
// Cell permissions can override table or CF permissions
case CHECK_CELL_DEFAULT: {
if (authManager.authorize(user, table, family, qualifier, Permission.Action.READ) ||
authManager.authorize(user, table, cell, Permission.Action.READ)) {
return ReturnCode.INCLUDE;
}
}
break;
default:
throw new RuntimeException("Unhandled strategy " + strategy);
}
return ReturnCode.SKIP;
}
示例11: parsePermissionRecord
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private static Pair<String, TablePermission> parsePermissionRecord(
byte[] entryName, Cell kv) {
// return X given a set of permissions encoded in the permissionRecord kv.
byte[] family = CellUtil.cloneFamily(kv);
if (!Bytes.equals(family, ACL_LIST_FAMILY)) {
return null;
}
byte[] key = CellUtil.cloneQualifier(kv);
byte[] value = CellUtil.cloneValue(kv);
if (LOG.isDebugEnabled()) {
LOG.debug("Read acl: kv ["+
Bytes.toStringBinary(key)+": "+
Bytes.toStringBinary(value)+"]");
}
// check for a column family appended to the key
// TODO: avoid the string conversion to make this more efficient
String username = Bytes.toString(key);
//Handle namespace entry
if(isNamespaceEntry(entryName)) {
return new Pair<String, TablePermission>(username,
new TablePermission(Bytes.toString(fromNamespaceEntry(entryName)), value));
}
//Handle table and global entry
//TODO global entry should be handled differently
int idx = username.indexOf(ACL_KEY_DELIMITER);
byte[] permFamily = null;
byte[] permQualifier = null;
if (idx > 0 && idx < username.length()-1) {
String remainder = username.substring(idx+1);
username = username.substring(0, idx);
idx = remainder.indexOf(ACL_KEY_DELIMITER);
if (idx > 0 && idx < remainder.length()-1) {
permFamily = Bytes.toBytes(remainder.substring(0, idx));
permQualifier = Bytes.toBytes(remainder.substring(idx+1));
} else {
permFamily = Bytes.toBytes(remainder);
}
}
return new Pair<String,TablePermission>(username,
new TablePermission(TableName.valueOf(entryName), permFamily, permQualifier, value));
}
示例12: applyIncrementsToColumnFamily
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的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;
}
示例13: process
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
public void process(long now, HRegion region,
List<Mutation> mutations, WALEdit walEdit) throws IOException {
// Override the time to avoid race-condition in the unit test caused by
// inacurate timer on some machines
now = myTimer.getAndIncrement();
// Scan both rows
List<Cell> kvs1 = new ArrayList<Cell>();
List<Cell> kvs2 = new ArrayList<Cell>();
doScan(region, new Scan(row1, row1), kvs1);
doScan(region, new Scan(row2, row2), kvs2);
// Assert swapped
if (swapped) {
assertEquals(rowSize, kvs2.size());
assertEquals(row2Size, kvs1.size());
} else {
assertEquals(rowSize, kvs1.size());
assertEquals(row2Size, kvs2.size());
}
swapped = !swapped;
// Add and delete keyvalues
List<List<Cell>> kvs = new ArrayList<List<Cell>>();
kvs.add(kvs1);
kvs.add(kvs2);
byte[][] rows = new byte[][]{row1, row2};
for (int i = 0; i < kvs.size(); ++i) {
for (Cell kv : kvs.get(i)) {
// Delete from the current row and add to the other row
Delete d = new Delete(rows[i]);
KeyValue kvDelete =
new KeyValue(rows[i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv),
kv.getTimestamp(), KeyValue.Type.Delete);
d.addDeleteMarker(kvDelete);
Put p = new Put(rows[1 - i]);
KeyValue kvAdd =
new KeyValue(rows[1 - i], CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv),
now, CellUtil.cloneValue(kv));
p.add(kvAdd);
mutations.add(d);
walEdit.add(kvDelete);
mutations.add(p);
walEdit.add(kvAdd);
}
}
}
示例14: CellModel
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
* Constructor from KeyValue
* @param cell
*/
public CellModel(org.apache.hadoop.hbase.Cell cell) {
this(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), CellUtil
.cloneValue(cell));
}
示例15: getQualifier
import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
public byte[] getQualifier() {
return CellUtil.cloneQualifier(this);
}