本文整理汇总了Java中com.clearspring.analytics.stream.cardinality.HyperLogLogPlus.offer方法的典型用法代码示例。如果您正苦于以下问题:Java HyperLogLogPlus.offer方法的具体用法?Java HyperLogLogPlus.offer怎么用?Java HyperLogLogPlus.offer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.clearspring.analytics.stream.cardinality.HyperLogLogPlus
的用法示例。
在下文中一共展示了HyperLogLogPlus.offer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _apply
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Override
public Iterable<Element> _apply(final String line) {
final List<Element> elements = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
final HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(8, 8);
hyperLogLogPlus.offer("B" + i);
final Entity entity = new Entity.Builder()
.group("cardinality")
.vertex("A")
.property("approxCardinality", hyperLogLogPlus)
.build();
elements.add(entity);
}
return elements;
}
示例2: setup
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Before
public void setup() {
hyperLogLogPlusWithCardinality5 = new HyperLogLogPlus(5, 5);
for (int i = 1; i <= 5; i++) {
hyperLogLogPlusWithCardinality5.offer(i);
}
assertEquals(5l, hyperLogLogPlusWithCardinality5.cardinality());
hyperLogLogPlusWithCardinality15 = new HyperLogLogPlus(5, 5);
for (int i = 1; i <= 18; i++) {
hyperLogLogPlusWithCardinality15.offer(i);
}
assertEquals(15l, hyperLogLogPlusWithCardinality15.cardinality());
hyperLogLogPlusWithCardinality31 = new HyperLogLogPlus(5, 5);
for (int i = 1; i <= 32; i++) {
hyperLogLogPlusWithCardinality31.offer(i);
}
assertEquals(31l, hyperLogLogPlusWithCardinality31.cardinality());
}
示例3: createCardinality
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private Entity createCardinality(final Object source,
final Object destination,
final Edge edge) {
final HyperLogLogPlus hllp = new HyperLogLogPlus(5, 5);
hllp.offer(destination);
return new Entity.Builder()
.vertex(source)
.group("cardinality")
.property("edgeGroup", CollectionUtil.treeSet(edge.getGroup()))
.property("hllp", hllp)
.property("count", 1)
.build();
}
示例4: createCardinality
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private Entity createCardinality(final Object source,
final Object destination,
final Edge edge) {
final HyperLogLogPlus hllp = new HyperLogLogPlus(5, 5);
hllp.offer(destination);
return new Entity.Builder()
.vertex(source)
.group("Cardinality")
.property("edgeGroup", CollectionUtil.treeSet(edge.getGroup()))
.property("hllp", hllp)
.property("count", 1L)
.build();
}
开发者ID:gchq,项目名称:gaffer-doc,代码行数:15,代码来源:RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator.java
示例5: getHLLStringForTesting
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private String getHLLStringForTesting(int max) {
HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(HyperUniqueSumAggregationBuilder.SERIALIZED_DENSE_PRECISION, HyperUniqueSumAggregationBuilder.SERIALIZED_SPARSE_PRECISION);
for ( int i = 0; i < max ; i ++){
hyperLogLogPlus.offer(Integer.toString(i));
}
return Base64.getEncoder().encodeToString(HyperUniqueSumAggregator.serializeHyperLogLogPlus(hyperLogLogPlus).bytes);
}
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:8,代码来源:HyperLogLogPlusAggregationPluginTests.java
示例6: getHLLStringForTestingWithWrongPrecision
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private String getHLLStringForTestingWithWrongPrecision(int max) {
HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(HyperUniqueSumAggregationBuilder.SERIALIZED_DENSE_PRECISION + 5, HyperUniqueSumAggregationBuilder.SERIALIZED_SPARSE_PRECISION + 5);
for ( int i = 0; i < max ; i ++){
hyperLogLogPlus.offer(Integer.toString(i));
}
return Base64.getEncoder().encodeToString(HyperUniqueSumAggregator.serializeHyperLogLogPlus(hyperLogLogPlus).bytes);
}
开发者ID:bazaarvoice,项目名称:elasticsearch-hyperloglog,代码行数:8,代码来源:HyperLogLogPlusAggregationPluginTests.java
示例7: call
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Override
public StringQuality call(StringQuality v1, Writable writable) throws Exception {
long valid = v1.getCountValid();
long invalid = v1.getCountInvalid();
long countMissing = v1.getCountMissing();
long countTotal = v1.getCountTotal() + 1;
long empty = v1.getCountEmptyString();
long alphabetic = v1.getCountAlphabetic();
long numerical = v1.getCountNumerical();
long word = v1.getCountWordCharacter();
long whitespaceOnly = v1.getCountWhitespace();
HyperLogLogPlus hll = v1.getHll();
String str = writable.toString();
if (writable instanceof NullWritable)
countMissing++;
else if (meta.isValid(writable))
valid++;
else
invalid++;
if (str == null || str.isEmpty()) {
empty++;
} else {
if (str.matches("[a-zA-Z]"))
alphabetic++;
if (str.matches("\\d+"))
numerical++;
if (str.matches("\\w+"))
word++;
if (str.matches("\\s+"))
whitespaceOnly++;
}
hll.offer(str);
return new StringQuality(valid, invalid, countMissing, countTotal, empty, alphabetic, numerical, word,
whitespaceOnly, hll);
}
示例8: addInput
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Override
public HyperLogLogPlus addInput(HyperLogLogPlus acc, InputT record) {
try {
acc.offer(CoderUtils.encodeToByteArray(inputCoder, record));
} catch (CoderException e) {
throw new IllegalStateException("The input value cannot be encoded: " + e.getMessage(), e);
}
return acc;
}
示例9: testCoder
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Test
public void testCoder() throws Exception {
HyperLogLogPlus hllp = new HyperLogLogPlus(12, 18);
for (int i = 0; i < 10; i++) {
hllp.offer(i);
}
CoderProperties.<HyperLogLogPlus>coderDecodeEncodeEqual(
ApproximateDistinct.HyperLogLogPlusCoder.of(), hllp);
}
示例10: createCardinality
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
protected Entity createCardinality(final Object source,
final Object destination,
final Edge edge) {
final HyperLogLogPlus hllp = new HyperLogLogPlus(5, 5);
hllp.offer(destination);
return new Entity.Builder()
.vertex(source)
.group("Cardinality")
.property("edgeGroup", CollectionUtil.treeSet(edge.getGroup()))
.property("hllp", hllp)
.property("count", 1L)
.build();
}
示例11: testConverter
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Test
public void testConverter() throws ConversionException {
final HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(5, 5);
hyperLogLogPlus.offer("A");
hyperLogLogPlus.offer("B");
assertEquals(hyperLogLogPlus.cardinality(), (long) HYPER_LOG_LOG_PLUS_CONVERTER.convert(hyperLogLogPlus));
final HyperLogLogPlus emptyHyperLogLogPlus = new HyperLogLogPlus(5, 5);
assertEquals(emptyHyperLogLogPlus.cardinality(), (long) HYPER_LOG_LOG_PLUS_CONVERTER.convert(emptyHyperLogLogPlus));
}
示例12: getElementsWithNonStandardProperties
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private static List<Element> getElementsWithNonStandardProperties() {
final List<Element> elements = new ArrayList<>();
final FreqMap freqMap = new FreqMap();
freqMap.put("W", 10L);
freqMap.put("X", 100L);
final HyperLogLogPlus hllpp = new HyperLogLogPlus(5, 5);
hllpp.offer("AAA");
final Entity entity = new Entity.Builder()
.group(TestGroups.ENTITY)
.vertex("A")
.property("freqMap", freqMap)
.property("hllpp", hllpp)
.build();
elements.add(entity);
final Edge edge = new Edge.Builder()
.group(TestGroups.EDGE)
.source("B")
.dest("C")
.directed(true)
.build();
final FreqMap freqMap2 = new FreqMap();
freqMap2.put("Y", 1000L);
freqMap2.put("Z", 10000L);
edge.putProperty("freqMap", freqMap2);
final HyperLogLogPlus hllpp2 = new HyperLogLogPlus(5, 5);
hllpp2.offer("AAA");
hllpp2.offer("BBB");
edge.putProperty("hllpp", hllpp2);
elements.add(edge);
return elements;
}
示例13: getElementsForUserDefinedConversion
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private static List<Element> getElementsForUserDefinedConversion() {
final List<Element> elements = new ArrayList<>();
final FreqMap freqMap = new FreqMap();
freqMap.put("W", 10L);
freqMap.put("X", 100L);
final HyperLogLogPlus hllpp = new HyperLogLogPlus(5, 5);
hllpp.offer("AAA");
final Entity entity = new Entity.Builder()
.group(TestGroups.ENTITY)
.vertex("A")
.property("freqMap", freqMap)
.property("hllpp", hllpp)
.property("myProperty", new MyProperty(10))
.build();
elements.add(entity);
final Edge edge = new Edge.Builder()
.group(TestGroups.EDGE)
.source("B")
.dest("C")
.directed(true)
.build();
final FreqMap freqMap2 = new FreqMap();
freqMap2.put("Y", 1000L);
freqMap2.put("Z", 10000L);
edge.putProperty("freqMap", freqMap2);
final HyperLogLogPlus hllpp2 = new HyperLogLogPlus(5, 5);
hllpp2.offer("AAA");
hllpp2.offer("BBB");
edge.putProperty("hllpp", hllpp2);
edge.putProperty("myProperty", new MyProperty(50));
elements.add(edge);
return elements;
}
示例14: setupHllp
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
private void setupHllp(final int p, final int sp) {
hyperLogLogPlus1 = new HyperLogLogPlus(p, sp);
hyperLogLogPlus1.offer("A");
hyperLogLogPlus1.offer("B");
hyperLogLogPlus2 = new HyperLogLogPlus(p, sp);
hyperLogLogPlus2.offer("C");
hyperLogLogPlus2.offer("D");
}
示例15: testValidHyperLogLogPlusSketchSerialisedCorrectly
import com.clearspring.analytics.stream.cardinality.HyperLogLogPlus; //导入方法依赖的package包/类
@Test
public void testValidHyperLogLogPlusSketchSerialisedCorrectly() throws IOException {
// Given
final String testString = "TestString";
final HyperLogLogPlus sketch = new HyperLogLogPlus(5, 5);
sketch.offer(testString);
// When / Then
runTestWithSketch(sketch);
}