本文整理了Java中io.airlift.stats.cardinality.HyperLogLog.serialize()
方法的一些代码示例,展示了HyperLogLog.serialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HyperLogLog.serialize()
方法的具体详情如下:
包路径:io.airlift.stats.cardinality.HyperLogLog
类名称:HyperLogLog
方法名:serialize
暂无
代码示例来源:origin: prestodb/presto
@Override
public void serialize(HyperLogLogState state, BlockBuilder out)
{
if (state.getHyperLogLog() == null) {
out.appendNull();
}
else {
HYPER_LOG_LOG.writeSlice(out, state.getHyperLogLog().serialize());
}
}
代码示例来源:origin: prestodb/presto
@ScalarFunction
@Description("an empty HyperLogLog instance")
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice emptyApproxSet()
{
return ApproximateSetAggregation.newHyperLogLog().serialize();
}
}
代码示例来源:origin: prestodb/presto
private static Slice nextHyperLogLog(Random random)
{
HyperLogLog hll = HyperLogLog.newInstance(HYPER_LOG_LOG_BUCKETS);
int size = random.nextInt(MAX_HYPER_LOG_LOG_ELEMENTS);
for (int i = 0; i < size; i++) {
hll.add(random.nextLong());
}
return hll.serialize();
}
代码示例来源:origin: prestodb/presto
@ScalarFunction
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value)
{
HyperLogLog hll = HyperLogLog.newInstance(4096);
hll.add(value);
return hll.serialize();
}
}
代码示例来源:origin: prestodb/presto
@ScalarOperator(CAST)
@SqlType(StandardTypes.P4_HYPER_LOG_LOG)
public static Slice castToP4Hll(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice slice)
{
HyperLogLog hll = HyperLogLog.newInstance(slice);
hll.makeDense();
return hll.serialize();
}
代码示例来源:origin: prestodb/presto
@Override
public Object getExpectedValue(int start, int length)
{
if (length == 0) {
return null;
}
HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
for (int i = start; i < start + length; i++) {
hll.add(i);
}
hll.makeDense();
return new SqlVarbinary(hll.serialize().getBytes());
}
}
代码示例来源:origin: prestodb/presto
@Override
public Block[] getSequenceBlocks(int start, int length)
{
BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
for (int i = start; i < start + length; i++) {
HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
hll.add(i);
hll.makeDense();
HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
}
return new Block[] {blockBuilder.build()};
}
代码示例来源:origin: prestodb/presto
public Slice serialize()
{
try (SliceOutput output = new DynamicSliceOutput(estimatedSerializedSize())) {
output.appendByte(UNCOMPRESSED_FORMAT);
Slice serializedHll = hll.serialize();
output.appendInt(serializedHll.length());
output.appendBytes(serializedHll);
output.appendInt(maxHashes);
output.appendInt(minhash.size());
for (long key : minhash.keySet()) {
output.appendLong(key);
}
for (short value : minhash.values()) {
output.appendShort(value);
}
return output.slice();
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
代码示例来源:origin: prestosql/presto
private static Slice nextHyperLogLog(Random random)
{
HyperLogLog hll = HyperLogLog.newInstance(HYPER_LOG_LOG_BUCKETS);
int size = random.nextInt(MAX_HYPER_LOG_LOG_ELEMENTS);
for (int i = 0; i < size; i++) {
hll.add(random.nextLong());
}
return hll.serialize();
}
代码示例来源:origin: prestosql/presto
@ScalarFunction
@Description("an empty HyperLogLog instance")
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice emptyApproxSet()
{
return ApproximateSetAggregation.newHyperLogLog().serialize();
}
}
代码示例来源:origin: io.prestosql/presto-main
@ScalarFunction
@Description("an empty HyperLogLog instance")
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice emptyApproxSet()
{
return ApproximateSetAggregation.newHyperLogLog().serialize();
}
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
@Override
public void serialize(HyperLogLogState state, BlockBuilder out)
{
if (state.getHyperLogLog() == null) {
out.appendNull();
}
else {
HYPER_LOG_LOG.writeSlice(out, state.getHyperLogLog().serialize());
}
}
代码示例来源:origin: io.prestosql/presto-main
@Override
public void serialize(HyperLogLogState state, BlockBuilder out)
{
if (state.getHyperLogLog() == null) {
out.appendNull();
}
else {
HYPER_LOG_LOG.writeSlice(out, state.getHyperLogLog().serialize());
}
}
代码示例来源:origin: com.facebook.presto/presto-thrift-connector-api
private static Slice nextHyperLogLog(Random random)
{
HyperLogLog hll = HyperLogLog.newInstance(HYPER_LOG_LOG_BUCKETS);
int size = random.nextInt(MAX_HYPER_LOG_LOG_ELEMENTS);
for (int i = 0; i < size; i++) {
hll.add(random.nextLong());
}
return hll.serialize();
}
代码示例来源:origin: io.prestosql/presto-main
@ScalarOperator(CAST)
@SqlType(StandardTypes.P4_HYPER_LOG_LOG)
public static Slice castToP4Hll(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice slice)
{
HyperLogLog hll = HyperLogLog.newInstance(slice);
hll.makeDense();
return hll.serialize();
}
代码示例来源:origin: prestosql/presto
@ScalarOperator(CAST)
@SqlType(StandardTypes.P4_HYPER_LOG_LOG)
public static Slice castToP4Hll(@SqlType(StandardTypes.HYPER_LOG_LOG) Slice slice)
{
HyperLogLog hll = HyperLogLog.newInstance(slice);
hll.makeDense();
return hll.serialize();
}
代码示例来源:origin: prestosql/presto
@ScalarFunction
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value)
{
HyperLogLog hll = HyperLogLog.newInstance(4096);
hll.add(value);
return hll.serialize();
}
}
代码示例来源:origin: com.facebook.presto/presto-tests
@ScalarFunction
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value)
{
HyperLogLog hll = HyperLogLog.newInstance(4096);
hll.add(value);
return hll.serialize();
}
}
代码示例来源:origin: io.prestosql/presto-main
@Override
public Block[] getSequenceBlocks(int start, int length)
{
BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
for (int i = start; i < start + length; i++) {
HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
hll.add(i);
hll.makeDense();
HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
}
return new Block[] {blockBuilder.build()};
}
代码示例来源:origin: prestosql/presto
@Override
public Block[] getSequenceBlocks(int start, int length)
{
BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(null, length);
for (int i = start; i < start + length; i++) {
HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
hll.add(i);
hll.makeDense();
HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());
}
return new Block[] {blockBuilder.build()};
}
内容来源于网络,如有侵权,请联系作者删除!