@Override public void deserialize(Block block, int index, HyperLogLogState state) { state.setHyperLogLog(HyperLogLog.newInstance(HYPER_LOG_LOG.getSlice(block, index))); } }
private static HyperLogLog getOrCreateHyperLogLog(HyperLogLogState state, double maxStandardError) { HyperLogLog hll = state.getHyperLogLog(); if (hll == null) { hll = HyperLogLog.newInstance(standardErrorToBuckets(maxStandardError)); state.setHyperLogLog(hll); state.addMemoryUsage(hll.estimatedInMemorySize()); } return hll; }
private static HyperLogLog getOrCreateHyperLogLog(@AggregationState HyperLogLogState state) { HyperLogLog hll = state.getHyperLogLog(); if (hll == null) { hll = newHyperLogLog(); state.setHyperLogLog(hll); state.addMemoryUsage(hll.estimatedInMemorySize()); } return hll; }
private static void merge(@AggregationState HyperLogLogState state, HyperLogLog input) { HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }
@CombineFunction public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState) { HyperLogLog input = otherState.getHyperLogLog(); HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }
@CombineFunction public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState) { HyperLogLog input = otherState.getHyperLogLog(); HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }
@Override public void deserialize(Block block, int index, HyperLogLogState state) { if (!block.isNull(index)) { state.setHyperLogLog(HyperLogLog.newInstance(HYPER_LOG_LOG.getSlice(block, index))); } } }
private static HyperLogLog getOrCreateHyperLogLog(HyperLogLogState state) { HyperLogLog hll = state.getHyperLogLog(); if (hll == null) { hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS); state.setHyperLogLog(hll); state.addMemoryUsage(hll.estimatedInMemorySize()); } return hll; }
private static HyperLogLog getOrCreateHyperLogLog(HyperLogLogState state, double maxStandardError) { HyperLogLog hll = state.getHyperLogLog(); if (hll == null) { hll = HyperLogLog.newInstance(standardErrorToBuckets(maxStandardError)); state.setHyperLogLog(hll); state.addMemoryUsage(hll.estimatedInMemorySize()); } return hll; }
@CombineFunction public static void combineState(HyperLogLogState state, HyperLogLogState otherState) { HyperLogLog input = otherState.getHyperLogLog(); HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }
@CombineFunction public static void combineState(HyperLogLogState state, HyperLogLogState otherState) { HyperLogLog input = otherState.getHyperLogLog(); HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }
@InputFunction @IntermediateInputFunction public static void merge(HyperLogLogState state, @SqlType(StandardTypes.HYPER_LOG_LOG) Slice value) { HyperLogLog input = HyperLogLog.newInstance(value); HyperLogLog previous = state.getHyperLogLog(); if (previous == null) { state.setHyperLogLog(input); state.addMemoryUsage(input.estimatedInMemorySize()); } else { state.addMemoryUsage(-previous.estimatedInMemorySize()); previous.mergeWith(input); state.addMemoryUsage(previous.estimatedInMemorySize()); } }