本文整理了Java中org.apache.hadoop.hbase.client.Put.heapSize()
方法的一些代码示例,展示了Put.heapSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.heapSize()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:heapSize
暂无
代码示例来源:origin: apache/hbase
@Test
public void testCancelPeriodicFlush() throws InterruptedException, ExecutionException {
Put put = new Put(Bytes.toBytes(0)).addColumn(CF, CQ, VALUE);
try (AsyncBufferedMutatorImpl mutator = (AsyncBufferedMutatorImpl) CONN
.getBufferedMutatorBuilder(TABLE_NAME).setWriteBufferPeriodicFlush(1, TimeUnit.SECONDS)
.setWriteBufferSize(10 * put.heapSize()).build()) {
List<CompletableFuture<?>> futures = new ArrayList<>();
futures.add(mutator.mutate(put));
Timeout task = mutator.periodicFlushTask;
// we should have scheduled a periodic flush task
assertNotNull(task);
for (int i = 1;; i++) {
futures.add(mutator.mutate(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, VALUE)));
if (mutator.periodicFlushTask == null) {
break;
}
}
assertTrue(task.isCancelled());
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
AsyncTable<?> table = CONN.getTable(TABLE_NAME);
for (int i = 0; i < futures.size(); i++) {
assertArrayEquals(VALUE, table.get(new Get(Bytes.toBytes(i))).get().getValue(CF, CQ));
}
}
}
代码示例来源:origin: apache/hbase
Put put3 = new Put(DUMMY_BYTES_3);
put3.addColumn(DUMMY_BYTES_3, DUMMY_BYTES_3, DUMMY_BYTES_3);
putSizeSN += (put1.heapSize() + put2.heapSize());
putSizeSN2 += put3.heapSize();
puts.add(put1);
puts.add(put2);
代码示例来源:origin: apache/hbase
try (AsyncBufferMutatorForTest mutator =
new AsyncBufferMutatorForTest(AsyncConnectionImpl.RETRY_TIMER, CONN.getTable(TABLE_NAME),
10 * put.heapSize(), TimeUnit.MILLISECONDS.toNanos(200))) {
CompletableFuture<?> future = mutator.mutate(put);
Timeout task = mutator.periodicFlushTask;
代码示例来源:origin: forcedotcom/phoenix
private int comparePuts(Put p1, Put p2) {
int p1Size = p1.size();
int p2Size = p2.size();
int compare = p1Size - p2Size;
if (compare == 0) {
// TODO: make this a real comparison
// this is a little cheating, but we don't really need to worry too much about this being
// the same - chances are that exact matches here are really the same update.
return Longs.compare(p1.heapSize(), p2.heapSize());
}
return compare;
}
代码示例来源:origin: apache/phoenix
private int comparePuts(Put p1, Put p2) {
int p1Size = p1.size();
int p2Size = p2.size();
int compare = p1Size - p2Size;
if (compare == 0) {
// TODO: make this a real comparison
// this is a little cheating, but we don't really need to worry too much about this being
// the same - chances are that exact matches here are really the same update.
return Longs.compare(p1.heapSize(), p2.heapSize());
}
return compare;
}
代码示例来源:origin: apache/hbase
assertEquals(p1.heapSize(), mutator.getCurrentWriteBufferSize());
assertTrue(iter1.next() == p1);
assertEquals(0, mutator.getUnflushedSize());
assertEquals(1, mutator.size());
assertEquals(1, mutator.getUnflushedSize());
assertEquals(p1.heapSize(), mutator.getCurrentWriteBufferSize());
代码示例来源:origin: org.apache.hbase/hbase-client
Put put3 = new Put(DUMMY_BYTES_3);
put3.addColumn(DUMMY_BYTES_3, DUMMY_BYTES_3, DUMMY_BYTES_3);
putSizeSN += (put1.heapSize() + put2.heapSize());
putSizeSN2 += put3.heapSize();
puts.add(put1);
puts.add(put2);
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
private int comparePuts(Put p1, Put p2) {
int p1Size = p1.size();
int p2Size = p2.size();
int compare = p1Size - p2Size;
if (compare == 0) {
// TODO: make this a real comparison
// this is a little cheating, but we don't really need to worry too much about this being
// the same - chances are that exact matches here are really the same update.
return Longs.compare(p1.heapSize(), p2.heapSize());
}
return compare;
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
private int comparePuts(Put p1, Put p2) {
int p1Size = p1.size();
int p2Size = p2.size();
int compare = p1Size - p2Size;
if (compare == 0) {
// TODO: make this a real comparison
// this is a little cheating, but we don't really need to worry too much about this being
// the same - chances are that exact matches here are really the same update.
return Longs.compare(p1.heapSize(), p2.heapSize());
}
return compare;
}
代码示例来源:origin: com.moz.fiji.schema/fiji-schema
"Cannot write to BufferedWriter instance in state %s.", mState);
if (mPutBuffer.containsKey(entityId)) {
mCurrentWriteBufferSize -= mPutBuffer.get(entityId).heapSize();
mPutBuffer.get(entityId).add(family, qualifier,
timestamp, value);
mCurrentWriteBufferSize += mPutBuffer.get(entityId).heapSize();
} else {
final Put put = new Put(entityId.getHBaseRowKey())
.add(family, qualifier, timestamp, value);
mPutBuffer.put(entityId, put);
mCurrentWriteBufferSize += put.heapSize();
代码示例来源:origin: co.cask.hbase/hbase
currentWriteBufferSize += aPut.heapSize();
代码示例来源:origin: org.apache.hbase/hbase-client
assertEquals(p1.heapSize(), mutator.getCurrentWriteBufferSize());
assertTrue(iter1.next() == p1);
assertEquals(0, mutator.getUnflushedSize());
assertEquals(1, mutator.size());
assertEquals(1, mutator.getUnflushedSize());
assertEquals(p1.heapSize(), mutator.getCurrentWriteBufferSize());
代码示例来源:origin: co.cask.hbase/hbase
private void doPut(final List<Put> puts) throws IOException {
int n = 0;
for (Put put : puts) {
validatePut(put);
writeBuffer.add(put);
currentWriteBufferSize += put.heapSize();
// we need to periodically see if the writebuffer is full instead of waiting until the end of the List
n++;
if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize) {
flushCommits();
}
}
if (autoFlush || currentWriteBufferSize > writeBufferSize) {
flushCommits();
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testCancelPeriodicFlush() throws InterruptedException, ExecutionException {
Put put = new Put(Bytes.toBytes(0)).addColumn(CF, CQ, VALUE);
try (AsyncBufferedMutatorImpl mutator = (AsyncBufferedMutatorImpl) CONN
.getBufferedMutatorBuilder(TABLE_NAME).setWriteBufferPeriodicFlush(1, TimeUnit.SECONDS)
.setWriteBufferSize(10 * put.heapSize()).build()) {
List<CompletableFuture<?>> futures = new ArrayList<>();
futures.add(mutator.mutate(put));
Timeout task = mutator.periodicFlushTask;
// we should have scheduled a periodic flush task
assertNotNull(task);
for (int i = 1;; i++) {
futures.add(mutator.mutate(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, VALUE)));
if (mutator.periodicFlushTask == null) {
break;
}
}
assertTrue(task.isCancelled());
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
AsyncTable<?> table = CONN.getTable(TABLE_NAME);
for (int i = 0; i < futures.size(); i++) {
assertArrayEquals(VALUE, table.get(new Get(Bytes.toBytes(i))).get().getValue(CF, CQ));
}
}
}
代码示例来源:origin: org.apache.hbase/hbase-server
try (AsyncBufferMutatorForTest mutator =
new AsyncBufferMutatorForTest(AsyncConnectionImpl.RETRY_TIMER, CONN.getTable(TABLE_NAME),
10 * put.heapSize(), TimeUnit.MILLISECONDS.toNanos(200))) {
CompletableFuture<?> future = mutator.mutate(put);
Timeout task = mutator.periodicFlushTask;
代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client
@Test
@Ignore(value="We need a better test now that BigtableBufferedMutator has different logic")
public void testBufferSizeFlush() throws Exception {
int maxSize = 1024;
BufferedMutatorParams params = new BufferedMutatorParams(sharedTestEnv.getDefaultTableName())
.writeBufferSize(maxSize);
try (BufferedMutator mutator = getConnection().getBufferedMutator(params)) {
// HBase 1.0.0 has a bug in it. It returns maxSize instead of the buffer size for
// getWriteBufferSize. https://issues.apache.org/jira/browse/HBASE-13113
Assert.assertTrue(
0 == mutator.getWriteBufferSize() || maxSize == mutator.getWriteBufferSize());
Put put = getPut();
mutator.mutate(put);
Assert.assertTrue(mutator.getWriteBufferSize() > 0);
Put largePut = new Put(dataHelper.randomData("testrow-"));
largePut.addColumn(COLUMN_FAMILY, qualifier,
Bytes.toBytes(RandomStringUtils.randomAlphanumeric(maxSize * 2)));
long heapSize = largePut.heapSize();
Assert.assertTrue("largePut heapsize is : " + heapSize, heapSize > maxSize);
mutator.mutate(largePut);
// HBase 1.0.0 has a bug in it. It returns maxSize instead of the buffer size for
// getWriteBufferSize. https://issues.apache.org/jira/browse/HBASE-13113
Assert.assertTrue(
0 == mutator.getWriteBufferSize() || maxSize == mutator.getWriteBufferSize());
}
}
内容来源于网络,如有侵权,请联系作者删除!