本文整理了Java中org.apache.hadoop.hbase.client.Put.getRow()
方法的一些代码示例,展示了Put.getRow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.getRow()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:getRow
暂无
代码示例来源: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
private static Cell createCustomCell(Put put) {
return createCustomCell(put.getRow(), FAMILY, QUALIFIER_FROM_CP, Cell.Type.Put, VALUE);
}
代码示例来源:origin: apache/hbase
@Test
public void testRowIsImmutableOrNot() {
byte[] rowKey = Bytes.toBytes("immutable");
// Test when row key is immutable
Put putRowIsImmutable = new Put(rowKey, true);
assertTrue(rowKey == putRowIsImmutable.getRow()); // No local copy is made
// Test when row key is not immutable
Put putRowIsNotImmutable = new Put(rowKey, 1000L, false);
assertTrue(rowKey != putRowIsNotImmutable.getRow()); // A local copy is made
}
代码示例来源:origin: apache/hbase
@Override
public boolean thenPut(Put put) throws IOException {
preCheck();
RowMutations rowMutations = new RowMutations(put.getRow());
rowMutations.add(put);
return checkAndMutate(row, family, qualifier, op, value, rowMutations);
}
代码示例来源:origin: apache/hbase
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
Put put = (Put) invocation.getArgument(1);
assertEquals("tableName-column1", Bytes.toString(writer.get()));
assertEquals("test", Bytes.toString(put.getRow()));
return null;
}
}).when(ctx).write(any(), any());
代码示例来源:origin: apache/hbase
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArgument(0);
Put put = (Put) invocation.getArgument(1);
assertEquals("row", Bytes.toString(writer.get()));
assertEquals("row", Bytes.toString(put.getRow()));
return null;
}
}).when(ctx).write(any(), any());
代码示例来源:origin: apache/hbase
public static void addReplicationBarrier(Put put, long openSeqNum) throws IOException {
put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(put.getRow())
.setFamily(HConstants.REPLICATION_BARRIER_FAMILY)
.setQualifier(HConstants.SEQNUM_QUALIFIER)
.setTimestamp(put.getTimestamp())
.setType(Type.Put)
.setValue(Bytes.toBytes(openSeqNum))
.build());
}
代码示例来源:origin: apache/hbase
private void recordFailure(final Table table, final Put put, final long keyBase,
final long start, IOException e) {
failedKeySet.add(keyBase);
String exceptionInfo;
if (e instanceof RetriesExhaustedWithDetailsException) {
RetriesExhaustedWithDetailsException aggEx = (RetriesExhaustedWithDetailsException) e;
exceptionInfo = aggEx.getExhaustiveDescription();
} else {
StringWriter stackWriter = new StringWriter();
PrintWriter pw = new PrintWriter(stackWriter);
e.printStackTrace(pw);
pw.flush();
exceptionInfo = StringUtils.stringifyException(e);
}
LOG.error("Failed to insert: " + keyBase + " after " + (System.currentTimeMillis() - start)
+ "ms; region information: " + getRegionDebugInfoSafe(table, put.getRow()) + "; errors: "
+ exceptionInfo);
}
}
代码示例来源:origin: apache/hbase
private static Put addSequenceNum(Put p, long openSeqNum, int replicaId) throws IOException {
return p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(p.getRow())
.setFamily(HConstants.CATALOG_FAMILY)
.setQualifier(getSeqNumColumn(replicaId))
.setTimestamp(p.getTimestamp())
.setType(Type.Put)
.setValue(Bytes.toBytes(openSeqNum))
.build());
}
}
代码示例来源:origin: apache/drill
@Override
public synchronized boolean putIfAbsent(String key, V value) {
try {
Put put = new Put(row(key));
put.addColumn(FAMILY, QUALIFIER, bytes(value));
return hbaseTable.checkAndPut(put.getRow(), FAMILY, QUALIFIER, null /*absent*/, put);
} catch (IOException e) {
throw UserException.dataReadError(e)
.message("Caught error while putting row '%s' into table '%s'", key, hbaseTableName)
.build(logger);
}
}
代码示例来源:origin: apache/hbase
private static void addRegionStateToPut(Put put, RegionState.State state) throws IOException {
put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(put.getRow())
.setFamily(HConstants.CATALOG_FAMILY)
.setQualifier(getRegionStateColumn())
.setTimestamp(put.getTimestamp())
.setType(Cell.Type.Put)
.setValue(Bytes.toBytes(state.name()))
.build());
}
代码示例来源:origin: apache/hbase
private static void addReplicationParent(Put put, List<RegionInfo> parents) throws IOException {
byte[] value = getParentsBytes(parents);
put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
.setFamily(HConstants.REPLICATION_BARRIER_FAMILY).setQualifier(REPLICATION_PARENT_QUALIFIER)
.setTimestamp(put.getTimestamp()).setType(Type.Put).setValue(value).build());
}
代码示例来源:origin: apache/hbase
@Override
public void put(final Put put) throws IOException {
validatePut(put);
ClientServiceCallable<Void> callable =
new ClientServiceCallable<Void>(this.connection, getName(), put.getRow(),
this.rpcControllerFactory.newController(), put.getPriority()) {
@Override
protected Void rpcCall() throws Exception {
MutateRequest request =
RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), put);
doMutate(request);
return null;
}
};
rpcCallerFactory.<Void> newCaller(this.writeRpcTimeoutMs).callWithRetries(callable,
this.operationTimeoutMs);
}
代码示例来源:origin: apache/hbase
public static Put addRegionInfo(final Put p, final RegionInfo hri)
throws IOException {
p.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(p.getRow())
.setFamily(getCatalogFamily())
.setQualifier(HConstants.REGIONINFO_QUALIFIER)
.setTimestamp(p.getTimestamp())
.setType(Type.Put)
.setValue(RegionInfo.toByteArray(hri))
.build());
return p;
}
代码示例来源: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
static int replayEdit(HRegion region, WAL.Entry entry) throws IOException {
if (WALEdit.isMetaEditFamily(entry.getEdit().getCells().get(0))) {
return 0; // handled elsewhere
}
Put put = new Put(CellUtil.cloneRow(entry.getEdit().getCells().get(0)));
for (Cell cell : entry.getEdit().getCells()) put.add(cell);
put.setDurability(Durability.SKIP_WAL);
MutationReplay mutation = new MutationReplay(MutationType.PUT, put, 0, 0);
region.batchReplay(new MutationReplay[] {mutation},
entry.getKey().getSequenceId());
return Integer.parseInt(Bytes.toString(put.getRow()));
}
代码示例来源:origin: apache/hbase
@Test
public void testPutCopyConstructor() throws IOException {
Put origin = new Put(Bytes.toBytes("ROW-01"));
origin.setPriority(100);
byte[] family = Bytes.toBytes("CF-01");
origin.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY)
.setRow(origin.getRow())
.setFamily(family)
.setQualifier(Bytes.toBytes("q"))
.setType(Cell.Type.Put)
.setValue(Bytes.toBytes("value"))
.build());
origin.addColumn(family, Bytes.toBytes("q0"), Bytes.toBytes("V-01"));
origin.addColumn(family, Bytes.toBytes("q1"), 100, Bytes.toBytes("V-01"));
Put clone = new Put(origin);
assertEquals(origin, clone);
origin.addColumn(family, Bytes.toBytes("q2"), Bytes.toBytes("V-02"));
//They should have different cell lists
assertNotEquals(origin.getCellList(family), clone.getCellList(family));
}
代码示例来源:origin: apache/hbase
@Override
public void postPut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
final WALEdit edit, final Durability durability) throws IOException {
HRegion region = (HRegion) c.getEnvironment().getRegion();
super.postPut(c, put, edit, durability);
if (Bytes.equals(put.getRow(), Bytes.toBytes("row2"))) {
region.flush(false);
Assert.assertTrue(region.getMemStoreDataSize() >= 0);
}
}
}
代码示例来源:origin: apache/hbase
@Override
boolean testRow(final int i) throws IOException {
final byte [] bytes = format(i);
// checkAndXXX tests operate on only a single value
// Put a known value so when we go to check it, it is there.
Put put = new Put(bytes);
put.addColumn(FAMILY_ZERO, getQualifier(), bytes);
this.table.put(put);
Delete delete = new Delete(put.getRow());
delete.addColumn(FAMILY_ZERO, getQualifier());
this.table.checkAndMutate(bytes, FAMILY_ZERO).qualifier(getQualifier())
.ifEquals(bytes).thenDelete(delete);
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!