本文整理了Java中org.apache.hadoop.hbase.KeyValue.getSerializedSize()
方法的一些代码示例,展示了KeyValue.getSerializedSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.getSerializedSize()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.KeyValue
类名称:KeyValue
方法名:getSerializedSize
暂无
代码示例来源:origin: apache/hbase
@Override
public int write(OutputStream out, boolean withTags) throws IOException {
int len = getSerializedSize(withTags);
out.write(this.bytes, this.offset, len);
return len;
}
代码示例来源:origin: apache/hbase
@Override
public int getSerializedSize() {
return this.kv.getSerializedSize();
}
代码示例来源:origin: apache/hbase
/**
* Write out a KeyValue in the manner in which we used to when KeyValue was a Writable but do
* not require a {@link DataOutput}, just take plain {@link OutputStream}
* Named <code>oswrite</code> so does not clash with {@link #write(KeyValue, DataOutput)}
* @param kv
* @param out
* @param withTags
* @return Length written on stream
* @throws IOException
* @see #create(DataInput) for the inverse function
* @see #write(KeyValue, DataOutput)
* @see KeyValueUtil#oswrite(Cell, OutputStream, boolean)
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Instead use {@link #write(OutputStream, boolean)}
*/
@Deprecated
public static long oswrite(final KeyValue kv, final OutputStream out, final boolean withTags)
throws IOException {
ByteBufferUtils.putInt(out, kv.getSerializedSize(withTags));
return (long) kv.write(out, withTags) + Bytes.SIZEOF_INT;
}
代码示例来源:origin: apache/hbase
private long cellBeforeFlushSize() {
// make one cell
byte[] row = Bytes.toBytes("A");
byte[] val = Bytes.toBytes("A" + 0);
KeyValue kv =
new KeyValue(row, Bytes.toBytes("testfamily"), Bytes.toBytes("testqualifier"),
System.currentTimeMillis(), val);
return ClassSize.align(
ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + KeyValue.FIXED_OVERHEAD + kv.getSerializedSize());
}
代码示例来源:origin: apache/hbase
private long cellAfterFlushSize() {
// make one cell
byte[] row = Bytes.toBytes("A");
byte[] val = Bytes.toBytes("A" + 0);
KeyValue kv =
new KeyValue(row, Bytes.toBytes("testfamily"), Bytes.toBytes("testqualifier"),
System.currentTimeMillis(), val);
return toCellChunkMap ?
ClassSize.align(
ClassSize.CELL_CHUNK_MAP_ENTRY + kv.getSerializedSize()) :
ClassSize.align(
ClassSize.CELL_ARRAY_MAP_ENTRY + KeyValue.FIXED_OVERHEAD + kv.getSerializedSize());
}
}
代码示例来源:origin: apache/hbase
@Override
public void doAnAction() throws Exception {
int valSize = r.nextInt(3);
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]);
int size = kv.getSerializedSize();
ByteBufferKeyValue newCell = (ByteBufferKeyValue) mslab.copyCellInto(kv);
totalAllocated.addAndGet(size);
allocsByThisThread.add(new AllocRecord(newCell.getBuffer(), newCell.getOffset(), size));
}
};
代码示例来源:origin: apache/hbase
/**
* Verify KeyValue format related functions: write() and getSerializedSize().
* Should have the same behaviors as {@link KeyValue}.
*/
@Test
public void testWriteIntoKeyValueFormat() throws IOException {
// Verify getSerializedSize().
assertEquals(kv0.getSerializedSize(true), ic0.getSerializedSize(true)); // with tags
assertEquals(kv0.getSerializedSize(false), ic0.getSerializedSize(false)); // without tags
// Verify writing into ByteBuffer.
ByteBuffer bbufIC = ByteBuffer.allocate(ic0.getSerializedSize(true));
ic0.write(bbufIC, 0);
ByteBuffer bbufKV = ByteBuffer.allocate(kv0.getSerializedSize(true));
kv0.write(bbufKV, 0);
assertTrue(bbufIC.equals(bbufKV));
// Verify writing into OutputStream.
testWriteIntoOutputStream(ic0, kv0, true); // with tags
testWriteIntoOutputStream(ic0, kv0, false); // without tags
}
代码示例来源:origin: apache/hbase
Bytes.toBytes("testqualifier"), System.currentTimeMillis(), val);
long oneCellOnCCMHeapSize =
(long) ClassSize.CELL_CHUNK_MAP_ENTRY + ClassSize.align(kv.getSerializedSize());
long oneCellOnCSLMHeapSize =
ClassSize.align(ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + kv.heapSize());
代码示例来源:origin: apache/hbase
int valSize = rand.nextInt(3);
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]);
int size = kv.getSerializedSize();
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
代码示例来源:origin: apache/hbase
int valSize = rand.nextInt(1000);
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]);
int size = kv.getSerializedSize();
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
代码示例来源:origin: apache/hbase
int valSize = rand.nextInt(1000);
KeyValue kv = new KeyValue(rk, cf, q, new byte[valSize]);
int size = kv.getSerializedSize();
ByteBufferKeyValue newKv = (ByteBufferKeyValue) mslab.copyCellInto(kv);
if (newKv.getBuffer() != lastBuffer) {
代码示例来源:origin: apache/hbase
ClassSize.CONCURRENT_SKIPLISTMAP_ENTRY + KeyValue.FIXED_OVERHEAD + kv.getSerializedSize());
ClassSize.CELL_CHUNK_MAP_ENTRY + ClassSize.align(kv.getSerializedSize());
totalHeapSize = MutableSegment.DEEP_OVERHEAD + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM
+ numOfCells * oneCellOnCCMHeapSize;
代码示例来源:origin: apache/hbase
/**
* @param ic An instance of IndividualBytesFieldCell to compare.
* @param kv An instance of KeyValue to compare.
* @param withTags Whether to write tags.
*/
private void testWriteIntoOutputStream(IndividualBytesFieldCell ic, KeyValue kv, boolean withTags)
throws IOException {
ByteArrayOutputStream outIC = new ByteArrayOutputStream(ic.getSerializedSize(withTags));
ByteArrayOutputStream outKV = new ByteArrayOutputStream(kv.getSerializedSize(withTags));
// compare the number of bytes written
assertEquals(kv.write(outKV, withTags), ic.write(outIC, withTags));
// compare the underlying byte array
assertArrayEquals(outKV.getBuffer(), outIC.getBuffer());
}
代码示例来源:origin: apache/hbase
ClassSize.CELL_CHUNK_MAP_ENTRY + ClassSize.align(kv.getSerializedSize());
totalHeapSize = MutableSegment.DEEP_OVERHEAD + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM
+ numOfCells * oneCellOnCCMHeapSize;
代码示例来源:origin: apache/hbase
(long) ClassSize.CELL_CHUNK_MAP_ENTRY + ClassSize.align(kv.getSerializedSize());
totalHeapSize = MutableSegment.DEEP_OVERHEAD + CellChunkImmutableSegment.DEEP_OVERHEAD_CCM
+ numOfCells * oneCellOnCCMHeapSize;
代码示例来源:origin: apache/hbase
assertTrue(KeyOnlyKeyValue.getValueLength() == keyOnlyByteBufferedCell
.getValueLength());
assertEquals(8 + keyLen + (lenAsVal ? 4 : 0), KeyOnlyKeyValue.getSerializedSize());
assertEquals(8 + keyLen + (lenAsVal ? 4 : 0), keyOnlyCell.getSerializedSize());
if (keyOnlyByteBufferedCell.getValueLength() > 0) {
代码示例来源:origin: org.apache.hbase/hbase-common
@Override
public int write(OutputStream out, boolean withTags) throws IOException {
int len = getSerializedSize(withTags);
out.write(this.bytes, this.offset, len);
return len;
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
@Override
public int write(OutputStream out, boolean withTags) throws IOException {
int len = getSerializedSize(withTags);
out.write(this.bytes, this.offset, len);
return len;
}
代码示例来源:origin: org.apache.hbase/hbase-common
/**
* @param ic An instance of IndividualBytesFieldCell to compare.
* @param kv An instance of KeyValue to compare.
* @param withTags Whether to write tags.
*/
private void testWriteIntoOutputStream(IndividualBytesFieldCell ic, KeyValue kv, boolean withTags)
throws IOException {
ByteArrayOutputStream outIC = new ByteArrayOutputStream(ic.getSerializedSize(withTags));
ByteArrayOutputStream outKV = new ByteArrayOutputStream(kv.getSerializedSize(withTags));
// compare the number of bytes written
assertEquals(kv.write(outKV, withTags), ic.write(outIC, withTags));
// compare the underlying byte array
assertArrayEquals(outKV.getBuffer(), outIC.getBuffer());
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
/**
* @param ic An instance of IndividualBytesFieldCell to compare.
* @param kv An instance of KeyValue to compare.
* @param withTags Whether to write tags.
*/
private void testWriteIntoOutputStream(IndividualBytesFieldCell ic, KeyValue kv, boolean withTags)
throws IOException {
ByteArrayOutputStream outIC = new ByteArrayOutputStream(ic.getSerializedSize(withTags));
ByteArrayOutputStream outKV = new ByteArrayOutputStream(kv.getSerializedSize(withTags));
// compare the number of bytes written
assertEquals(kv.write(outKV, withTags), ic.write(outIC, withTags));
// compare the underlying byte array
assertArrayEquals(outKV.getBuffer(), outIC.getBuffer());
}
内容来源于网络,如有侵权,请联系作者删除!