本文整理了Java中org.apache.hadoop.hbase.client.Put.getFamilyCellMap()
方法的一些代码示例,展示了Put.getFamilyCellMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.getFamilyCellMap()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:getFamilyCellMap
暂无
代码示例来源:origin: apache/hbase
public static void validatePut(Put put, int maxKeyValueSize) throws IllegalArgumentException {
if (put.isEmpty()) {
throw new IllegalArgumentException("No columns to insert");
}
if (maxKeyValueSize > 0) {
for (List<Cell> list : put.getFamilyCellMap().values()) {
for (Cell cell : list) {
if (cell.getSerializedSize() > maxKeyValueSize) {
throw new IllegalArgumentException("KeyValue size too large");
}
}
}
}
}
代码示例来源:origin: apache/hbase
/**
* During replay, there could exist column families which are removed between region server
* failure and replay
*/
@Override
protected void checkAndPreparePut(Put p) throws IOException {
Map<byte[], List<Cell>> familyCellMap = p.getFamilyCellMap();
List<byte[]> nonExistentList = null;
for (byte[] family : familyCellMap.keySet()) {
if (!region.htableDescriptor.hasColumnFamily(family)) {
if (nonExistentList == null) {
nonExistentList = new ArrayList<>();
}
nonExistentList.add(family);
}
}
if (nonExistentList != null) {
for (byte[] family : nonExistentList) {
// Perhaps schema was changed between crash and replay
LOG.info("No family for " + Bytes.toString(family) + " omit from reply.");
familyCellMap.remove(family);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void postPut(final ObserverContext<RegionCoprocessorEnvironment> c,
final Put put, final WALEdit edit, final Durability durability) {
if (aclRegion) {
updateACL(c.getEnvironment(), put.getFamilyCellMap());
}
}
代码示例来源:origin: apache/hbase
@Override
public void checkAndPreparePut(Put p) throws IOException {
region.checkFamilies(p.getFamilyCellMap().keySet(), p.getDurability());
}
代码示例来源:origin: apache/hive
private void writePut(PutWritable put) throws IOException {
ImmutableBytesWritable row = new ImmutableBytesWritable(put.getPut().getRow());
SortedMap<byte[], List<Cell>> cells = put.getPut().getFamilyCellMap();
for (Map.Entry<byte[], List<Cell>> entry : cells.entrySet()) {
Collections.sort(entry.getValue(), new CellComparatorImpl());
for (Cell c : entry.getValue()) {
try {
fileWriter.write(row, KeyValueUtil.copyToNewKeyValue(c));
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e,
final Put put, final WALEdit edit, final Durability durability)
throws IOException {
PREPUT_INVOCATIONS.incrementAndGet();
Map<byte[], List<Cell>> familyMap = put.getFamilyCellMap();
if (familyMap.containsKey(test)) {
PREPUT_BYPASSES.incrementAndGet();
e.bypass();
}
}
}
代码示例来源:origin: apache/hbase
map.put(row, cells);
for (List<Cell> l: put.getFamilyCellMap().values()) {
cells.addAll(l);
代码示例来源:origin: apache/hbase
@Override
public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put m, WALEdit edit,
Durability durability) throws IOException {
byte[] attribute = m.getAttribute(NON_VISIBILITY);
byte[] cf = null;
List<Cell> updatedCells = new ArrayList<>();
if (attribute != null) {
for (List<? extends Cell> edits : m.getFamilyCellMap().values()) {
for (Cell cell : edits) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
if (cf == null) {
cf = CellUtil.cloneFamily(kv);
}
Tag tag = new ArrayBackedTag((byte) NON_VIS_TAG_TYPE, attribute);
List<Tag> tagList = new ArrayList<>(PrivateCellUtil.getTags(cell).size() + 1);
tagList.add(tag);
tagList.addAll(PrivateCellUtil.getTags(cell));
Cell newcell = PrivateCellUtil.createCell(kv, tagList);
((List<Cell>) updatedCells).add(newcell);
}
}
m.getFamilyCellMap().remove(cf);
// Update the family map
m.getFamilyCellMap().put(cf, updatedCells);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
final WALEdit edit, final Durability durability) throws IOException {
if (put.getAttribute("ttl") != null) {
Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
ttls.put(
TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength())),
Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
c.bypass();
} else if (put.getAttribute("versions") != null) {
Cell cell = put.getFamilyCellMap().values().stream().findFirst().get().get(0);
versions.put(
TableName.valueOf(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength())),
Bytes.toInt(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
c.bypass();
}
}
代码示例来源:origin: apache/hbase
protected CellSetModel buildModelFromPut(Put put) {
RowModel row = new RowModel(put.getRow());
long ts = put.getTimestamp();
for (List<Cell> cells: put.getFamilyCellMap().values()) {
for (Cell cell: cells) {
row.addCell(new CellModel(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell),
ts != HConstants.LATEST_TIMESTAMP ? ts : cell.getTimestamp(),
CellUtil.cloneValue(cell)));
}
}
CellSetModel model = new CellSetModel();
model.addRow(row);
return model;
}
代码示例来源:origin: apache/hive
@Test
public void testPut() throws Exception {
byte[] row = Bytes.toBytes("test-row");
// Initialize a result
KeyValue[] kvs = new KeyValue[] {
new KeyValue(row, Bytes.toBytes("cfa"),
Bytes.toBytes("col1"), Bytes.toBytes("cfacol1")),
new KeyValue(row, Bytes.toBytes("cfa"),
Bytes.toBytes("col2"), Bytes.toBytes("cfacol2"))
};
Put expected = new Put(row);
for (int i = 0; i < kvs.length; i++) {
expected.add(kvs[i]);
}
PutWritable actual = copy(new PutWritable(expected), new PutWritable());
Assert.assertArrayEquals(expected.getRow(), actual.getPut().getRow());
Assert.assertEquals(expected.getFamilyCellMap().keySet(),
actual.getPut().getFamilyCellMap().keySet());
}
代码示例来源:origin: apache/hbase
Map<byte[],? extends Collection<Cell>> families = put.getFamilyCellMap();
AuthResult authResult = permissionGranted(OpType.PUT,
user, env, families, Action.WRITE);
if (bytes != null) {
if (cellFeaturesEnabled) {
addCellPermissions(bytes, put.getFamilyCellMap());
} else {
throw new DoNotRetryIOException("Cell ACLs cannot be persisted");
代码示例来源:origin: apache/hive
private void deserializeAndSerializeHiveAvro(HBaseSerDe serDe, Result r, Put p,
Object[] expectedFieldsData, String expectedDeserializedAvroString)
throws SerDeException, IOException {
StructObjectInspector soi = (StructObjectInspector) serDe.getObjectInspector();
List<? extends StructField> fieldRefs = soi.getAllStructFieldRefs();
Object row = serDe.deserialize(new ResultWritable(r));
for (int j = 0; j < fieldRefs.size(); j++) {
Object fieldData = soi.getStructFieldData(row, fieldRefs.get(j));
assertNotNull(fieldData);
assertEquals(expectedFieldsData[j], fieldData.toString().trim());
}
assertEquals(expectedDeserializedAvroString, SerDeUtils.getJSONString(row, soi));
// Now serialize
Put put = ((PutWritable) serDe.serialize(row, soi)).getPut();
assertNotNull(put);
assertEquals(p.getFamilyCellMap(), put.getFamilyCellMap());
}
代码示例来源:origin: apache/hbase
assertEquals(1, put.getFamilyCellMap().get(CONTENTS_FAMILY).size());
KeyValue kv = (KeyValue)put.getFamilyCellMap().get(CONTENTS_FAMILY).get(0);
代码示例来源:origin: apache/hbase
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> e, final Put put,
final WALEdit edit, final Durability durability) throws IOException {
byte[] attribute = put.getAttribute("visibility");
byte[] cf = null;
List<Cell> updatedCells = new ArrayList<>();
if (attribute != null) {
for (List<? extends Cell> edits : put.getFamilyCellMap().values()) {
for (Cell cell : edits) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
if (cf == null) {
cf = CellUtil.cloneFamily(kv);
}
Tag tag = new ArrayBackedTag(TAG_TYPE, attribute);
List<Tag> tagList = new ArrayList<>(1);
tagList.add(tag);
KeyValue newKV = new KeyValue(CellUtil.cloneRow(kv), 0, kv.getRowLength(),
CellUtil.cloneFamily(kv), 0, kv.getFamilyLength(), CellUtil.cloneQualifier(kv), 0,
kv.getQualifierLength(), kv.getTimestamp(),
KeyValue.Type.codeToType(kv.getTypeByte()), CellUtil.cloneValue(kv), 0,
kv.getValueLength(), tagList);
((List<Cell>) updatedCells).add(newKV);
}
}
put.getFamilyCellMap().remove(cf);
// Update the family map
put.getFamilyCellMap().put(cf, updatedCells);
}
}
}
代码示例来源:origin: apache/hbase
out.setDurability(durabilityFromHBase(in.getDurability()));
for (Map.Entry<byte [], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
byte[] family = entry.getKey();
for (Cell cell : entry.getValue()) {
代码示例来源:origin: apache/hbase
Put put = setupPut(rand, key, value, numFamilies);
WALEdit walEdit = new WALEdit();
walEdit.add(put.getFamilyCellMap());
RegionInfo hri = region.getRegionInfo();
final WALKeyImpl logkey =
代码示例来源:origin: apache/hbase
if (bytes != null) {
if (cellFeaturesEnabled) {
addCellPermissions(bytes, put.getFamilyCellMap());
} else {
throw new DoNotRetryIOException("Cell ACLs cannot be persisted");
代码示例来源:origin: apache/hbase
final Put put, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<Cell>> familyMap = put.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
代码示例来源:origin: apache/hbase
final Put put, final WALEdit edit,
final Durability durability) throws IOException {
Map<byte[], List<Cell>> familyMap = put.getFamilyCellMap();
RegionCoprocessorEnvironment e = c.getEnvironment();
assertNotNull(e);
内容来源于网络,如有侵权,请联系作者删除!