本文整理了Java中org.apache.hadoop.hbase.client.Put.getFamilyMap()
方法的一些代码示例,展示了Put.getFamilyMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.getFamilyMap()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:getFamilyMap
暂无
代码示例来源:origin: apache/kylin
/**
* {@inheritDoc}
*/
@Override
public void put(Put put) throws IOException {
byte[] row = put.getRow();
NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> rowData = forceFind(data, row,
new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR));
for (byte[] family : put.getFamilyMap().keySet()) {
if (columnFamilies.contains(new String(family, StandardCharsets.UTF_8)) == false) {
throw new RuntimeException("Not Exists columnFamily : " + new String(family, StandardCharsets.UTF_8));
}
NavigableMap<byte[], NavigableMap<Long, byte[]>> familyData = forceFind(rowData, family,
new TreeMap<byte[], NavigableMap<Long, byte[]>>(Bytes.BYTES_COMPARATOR));
for (KeyValue kv : put.getFamilyMap().get(family)) {
kv.updateLatestStamp(Bytes.toBytes(System.currentTimeMillis()));
byte[] qualifier = kv.getQualifier();
NavigableMap<Long, byte[]> qualifierData = forceFind(familyData, qualifier,
new TreeMap<Long, byte[]>());
qualifierData.put(kv.getTimestamp(), kv.getValue());
}
}
}
代码示例来源:origin: klout/brickhouse
ArrayList<String> kvList = new ArrayList<String>();
kvList.add(new String(thePut.getRow()));
Map<byte[], List<KeyValue>> familyMap = thePut.getFamilyMap();
for (List<KeyValue> innerList : familyMap.values()) {
for (KeyValue kv : innerList) {
代码示例来源:origin: forcedotcom/phoenix
/**
* Essentially a short-cut from building a {@link Put}.
* @param pk row key
* @param timestamp timestamp of all the keyvalues
* @param values expected value--column pair
* @return a keyvalues that the index contains for a given row at a timestamp with the given value
* -- column pairs.
*/
public static List<KeyValue> getIndexKeyValueForTesting(byte[] pk, long timestamp,
List<Pair<byte[], CoveredColumn>> values) {
int length = 0;
List<ColumnEntry> expected = new ArrayList<ColumnEntry>(values.size());
for (Pair<byte[], CoveredColumn> value : values) {
ColumnEntry entry = new ColumnEntry(value.getFirst(), value.getSecond());
length += value.getFirst().length;
expected.add(entry);
}
byte[] rowKey = CoveredColumnIndexCodec.composeRowKey(pk, length, expected);
Put p = new Put(rowKey, timestamp);
CoveredColumnIndexCodec.addColumnsToPut(p, expected);
List<KeyValue> kvs = new ArrayList<KeyValue>();
for (Entry<byte[], List<KeyValue>> entry : p.getFamilyMap().entrySet()) {
kvs.addAll(entry.getValue());
}
return kvs;
}
代码示例来源:origin: apache/metron
@Override
public void put(Put put) throws IOException {
addToPutLog(put);
byte[] row = put.getRow();
NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> rowData = forceFind(data, row, new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR));
for (byte[] family : put.getFamilyMap().keySet()){
NavigableMap<byte[], NavigableMap<Long, byte[]>> familyData = forceFind(rowData, family, new TreeMap<byte[], NavigableMap<Long, byte[]>>(Bytes.BYTES_COMPARATOR));
for (KeyValue kv : put.getFamilyMap().get(family)){
kv.updateLatestStamp(Bytes.toBytes(System.currentTimeMillis()));
byte[] qualifier = kv.getQualifier();
NavigableMap<Long, byte[]> qualifierData = forceFind(familyData, qualifier, new TreeMap<Long, byte[]>());
qualifierData.put(kv.getTimestamp(), kv.getValue());
}
}
}
代码示例来源:origin: forcedotcom/phoenix
allKvs.addAll(p2.getFamilyMap().get(family));
allKvs.addAll(p1.getFamilyMap().get(family));
codec.verifiers.add(new ListMatchingVerifier("put state 1", p1.getFamilyMap().get(family),
familyRef));
codec.verifiers.add(new ListMatchingVerifier("cleanup state 2", p1.getFamilyMap().get(family),
familyRef));
代码示例来源:origin: forcedotcom/phoenix
allKvs.addAll(p.getFamilyMap().get(family));
代码示例来源:origin: XiaoMi/themis
@Override
public Map<byte[], List<KeyValue>> getFamilyMap() {
return put.getFamilyMap();
}
}
代码示例来源:origin: XiaoMi/themis
@Override
protected boolean hasColumn() {
return put.getFamilyMap() != null && put.getFamilyMap().size() != 0;
}
代码示例来源:origin: sematext/HBaseHUT
public static Result convert(Put put) {
List<KeyValue> kvs = new ArrayList<KeyValue>();
for (List<KeyValue> l : put.getFamilyMap().values()) {
kvs.addAll(l);
}
Result result = new Result(kvs);
return result;
}
代码示例来源:origin: com.cloudera.cdk/cdk-data-hbase
/**
* For each value in put2, add it to put1.
*
* @param put1
* The put to modify
* @param put2
* The put to add to put1
*/
public static void addToPut(Put put1, Put put2) {
Map<byte[], List<KeyValue>> familyMap = put2.getFamilyMap();
for (List<KeyValue> keyValueList : familyMap.values()) {
for (KeyValue keyValue : keyValueList) {
try {
put1.add(keyValue);
} catch (IOException e) {
throw new DatasetIOException("Could not add KeyValue to put", e);
}
}
}
}
代码示例来源:origin: co.cask.hbase/hbase
/**
* Copy constructor. Creates a Put operation cloned from the specified Put.
* @param putToCopy put to copy
*/
public Put(Put putToCopy) {
this(putToCopy.getRow(), putToCopy.ts, putToCopy.getRowLock());
this.familyMap =
new TreeMap<byte [], List<KeyValue>>(Bytes.BYTES_COMPARATOR);
for(Map.Entry<byte [], List<KeyValue>> entry :
putToCopy.getFamilyMap().entrySet()) {
this.familyMap.put(entry.getKey(), entry.getValue());
}
this.writeToWAL = putToCopy.writeToWAL;
}
代码示例来源:origin: co.cask.hbase/hbase
private void validatePut(final Put put) throws IllegalArgumentException{
if (put.isEmpty()) {
throw new IllegalArgumentException("No columns to insert");
}
if (maxKeyValueSize > 0) {
for (List<KeyValue> list : put.getFamilyMap().values()) {
for (KeyValue kv : list) {
if (kv.getLength() > maxKeyValueSize) {
throw new IllegalArgumentException("KeyValue size too large");
}
}
}
}
}
代码示例来源:origin: XiaoMi/themis
public ThemisPut(Put put) throws IOException {
checkContainingPreservedColumns(put.getFamilyMap());
setHBasePut(put);
}
代码示例来源:origin: twitter/hraven
/**
* utitlity function for printing all puts
*/
public void printAllPuts(List<Put> p) {
for (Put p1 : p) {
Map<byte[], List<KeyValue>> d = p1.getFamilyMap();
for (byte[] k : d.keySet()) {
System.out.println(" k " + Bytes.toString(k));
}
for (List<KeyValue> lkv : d.values()) {
for (KeyValue kv : lkv) {
System.out.println("\n row: " + taskKeyConv.fromBytes(kv.getRow())
+ "\n " + Bytes.toString(kv.getQualifier()) + ": " + Bytes.toString(kv.getValue()));
}
}
}
}
代码示例来源:origin: yahoo/simplified-lambda
/**
* {@inheritDoc}
*/
@Override
public void put(Put put) throws IOException {
this.sleeper();
byte[] row = put.getRow();
NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> rowData = forceFind(data, row, new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR));
for (byte[] family : put.getFamilyMap().keySet()) {
if (columnFamilies.contains(new String(family)) == false) {
throw new RuntimeException("Not Exists columnFamily : " + new String(family));
}
NavigableMap<byte[], NavigableMap<Long, byte[]>> familyData = forceFind(rowData, family, new TreeMap<byte[], NavigableMap<Long, byte[]>>(Bytes.BYTES_COMPARATOR));
for (KeyValue kv : put.getFamilyMap().get(family)) {
kv.updateLatestStamp(Bytes.toBytes(System.currentTimeMillis()));
byte[] qualifier = kv.getQualifier();
NavigableMap<Long, byte[]> qualifierData = forceFind(familyData, qualifier, new TreeMap<Long, byte[]>());
qualifierData.put(kv.getTimestamp(), kv.getValue());
}
}
}
代码示例来源:origin: org.apache.hive.hcatalog/hive-hcatalog-hbase-storage-handler
@Override
public void write(WritableComparable<?> key, Object value)
throws IOException {
Put original = toPut(value);
Put put = original;
if (outputVersion != null) {
put = new Put(original.getRow(), outputVersion.longValue());
for (List<? extends Cell> row : original.getFamilyMap().values()) {
for (Cell cell : row) {
KeyValue el = (KeyValue)cell;
put.add(el.getFamily(), el.getQualifier(), el.getValue());
}
}
}
baseWriter.write(key, put);
}
代码示例来源:origin: org.apache.hive.hcatalog/hive-hcatalog-hbase-storage-handler
@Override
public void write(WritableComparable<?> key, Object value)
throws IOException {
Put original = toPut(value);
Put put = original;
if (outputVersion != null) {
put = new Put(original.getRow(), outputVersion.longValue());
for (List<? extends Cell> row : original.getFamilyMap().values()) {
for (Cell cell : row) {
KeyValue el = (KeyValue)cell;
put.add(el.getFamily(), el.getQualifier(), el.getValue());
}
}
}
// we ignore the key
baseWriter.write(EMPTY_LIST, put);
}
代码示例来源:origin: domino-succ/domino
private static Put clonePut(Put put) {
long startId = 0;
long commitId = 1;
Put ret = new Put(put.getRow());
Map<byte[], List<KeyValue>> families = put.getFamilyMap();
Columns cols = new Columns(null);
for (byte[] family : families.keySet()) {
List<KeyValue> columns = families.get(family);
Iterator<KeyValue> it = columns.iterator();
while (it.hasNext()) {
KeyValue kv = it.next();
// byte[] column = DominoConst.getColumnKey(kv.getQualifier(), startId);
byte[] qualifier = kv.getQualifier();
ret.add(family, qualifier, startId, kv.getValue());
cols.add(family, qualifier);
}
}
Map<String, byte[]> attributes = put.getAttributesMap();
for (String key : attributes.keySet()) {
ret.setAttribute(key, attributes.get(key));
}
ret.add(DominoConst.INNER_FAMILY, DominoConst.COLUMNS_COL, startId,
cols.toByteArray());
ret.add(DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId,
DominoConst.versionValue(startId, false));
return ret;
}
代码示例来源:origin: com.cloudera.cdk/cdk-data-hbase
/**
* Given a list of puts, create a new put with the values in each put merged
* together. It is expected that no puts have a value for the same fully
* qualified column. Return the new put.
*
* @param key
* The key of the new put.
* @param putList
* The list of puts to merge
* @return the new Put instance
*/
public static Put mergePuts(byte[] keyBytes, List<Put> putList) {
Put put = new Put(keyBytes);
for (Put putToMerge : putList) {
Map<byte[], List<KeyValue>> familyMap = putToMerge.getFamilyMap();
for (List<KeyValue> keyValueList : familyMap.values()) {
for (KeyValue keyValue : keyValueList) {
try {
put.add(new KeyValue(keyBytes, keyValue.getFamily(), keyValue.getQualifier(), keyValue.getTimestamp(), keyValue.getValue()));
} catch (IOException e) {
throw new DatasetIOException("Could not add KeyValue to put", e);
}
}
}
}
return put;
}
代码示例来源:origin: co.cask.hbase/hbase
protected CellSetModel buildModelFromPut(Put put) {
RowModel row = new RowModel(put.getRow());
long ts = put.getTimeStamp();
for (List<KeyValue> kvs: put.getFamilyMap().values()) {
for (KeyValue kv: kvs) {
row.addCell(new CellModel(kv.getFamily(), kv.getQualifier(),
ts != HConstants.LATEST_TIMESTAMP ? ts : kv.getTimestamp(),
kv.getValue()));
}
}
CellSetModel model = new CellSetModel();
model.addRow(row);
return model;
}
内容来源于网络,如有侵权,请联系作者删除!