com.google.common.hash.PrimitiveSink Java Examples
The following examples show how to use
com.google.common.hash.PrimitiveSink.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatisticParameters.java From open-rmbt with Apache License 2.0 | 6 votes |
@Override public void funnel(StatisticParameters o, PrimitiveSink into) { into .putUnencodedChars(o.getClass().getCanonicalName()) .putChar(':') .putUnencodedChars(Strings.nullToEmpty(o.lang)) .putFloat(o.quantile) .putInt(o.duration) .putUnencodedChars(Strings.nullToEmpty(o.type)) .putInt(o.maxDevices) .putUnencodedChars(Strings.nullToEmpty(o.networkTypeGroup)) .putDouble(o.accuracy) .putUnencodedChars(Strings.nullToEmpty(o.country)) .putBoolean(o.userServerSelection) .putInt((endDate == null) ? 0 : (int) endDate.getTime()) .putInt(o.province); }
Example #2
Source File: AllowAllToken.java From airpal with Apache License 2.0 | 6 votes |
@Override public Object getCredentials() { AllowAllUser user = (AllowAllUser) getPrincipal(); if (user != null) { return Hashing.sha256().hashObject(user, new Funnel<AllowAllUser>() { @Override public void funnel(AllowAllUser from, PrimitiveSink into) { Set<String> fromGroups = from.getGroups(); String fromName = from.getUserName(); into.putString(fromName, Charsets.UTF_8); for (String fromGroup : fromGroups) { into.putString(fromGroup, Charsets.UTF_8); } } }); } return null; }
Example #3
Source File: CuckooFilterTest.java From guava-probably with Apache License 2.0 | 6 votes |
@Test public void ensureGeneric() { class SuperClass { } class SubClass extends SuperClass { } CuckooFilter<SuperClass> filter = CuckooFilter.create( new Funnel<SuperClass>() { public void funnel(SuperClass from, PrimitiveSink into) { into.putInt(from.hashCode()); } }, 1000, 0.03D); assertTrue(filter.add(new SuperClass())); assertTrue(filter.add(new SubClass())); }
Example #4
Source File: CuckooFilterTest.java From guava-probably with Apache License 2.0 | 6 votes |
@Test public void ensureGeneric() { class SuperClass { } class SubClass extends SuperClass { } CuckooFilter<SuperClass> filter = CuckooFilter.create( new Funnel<SuperClass>() { public void funnel(SuperClass from, PrimitiveSink into) { into.putInt(from.hashCode()); } }, 1000, 0.03D); assertTrue(filter.add(new SuperClass())); assertTrue(filter.add(new SubClass())); }
Example #5
Source File: ShardGroupCompactionImpl.java From usergrid with Apache License 2.0 | 5 votes |
protected void addToHash( final PrimitiveSink into, final Id id ) { final UUID nodeUuid = id.getUuid(); final String nodeType = id.getType(); into.putLong( nodeUuid.getMostSignificantBits() ).putLong( nodeUuid.getLeastSignificantBits() ) .putString( nodeType, CHARSET ); }
Example #6
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { boolean value = random.nextBoolean(); for (PrimitiveSink sink : sinks) { sink.putBoolean(value); } }
Example #7
Source File: EdgeMetadataSerializationV2Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void funnel( final EdgeIdTypeKey from, final PrimitiveSink into ) { final UUID id = from.node.getUuid(); final String type = from.node.getType(); into.putLong( id.getMostSignificantBits() ); into.putLong( id.getLeastSignificantBits() ); into.putString( type, StringHashUtils.UTF8 ); into.putString( from.edgeType, StringHashUtils.UTF8 ); }
Example #8
Source File: EdgeMetadataSerializationV2Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void funnel( final Id from, final PrimitiveSink into ) { final UUID id = from.getUuid(); final String type = from.getType(); into.putLong( id.getMostSignificantBits() ); into.putLong( id.getLeastSignificantBits() ); into.putString( type, StringHashUtils.UTF8 ); }
Example #9
Source File: TileParameters.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public void funnel(TileParameters o, PrimitiveSink into) { into .putUnencodedChars(o.getClass().getCanonicalName()) .putInt(o.size) .putUnencodedChars(o.mapOption) .putFloat(o.quantile) .putDouble(o.transparency) .putUnencodedChars(Strings.nullToEmpty(o.developerCode)); o.path.funnel(o.path, into); FILTER_MAP_FUNNEL.funnel(o.filterMap.entrySet(), into); }
Example #10
Source File: TileParameters.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public void funnel(Entry<String, String> o, PrimitiveSink into) { into .putUnencodedChars(o.getKey()) .putChar(':') .putUnencodedChars(Strings.nullToEmpty(o.getValue())); }
Example #11
Source File: TileParameters.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public void funnel(Path o, PrimitiveSink into) { into .putInt(o.zoom) .putInt(o.x) .putInt(o.y); }
Example #12
Source File: PointTileParameters.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public void funnel(TileParameters o, PrimitiveSink into) { super.funnel(o, into); if (o instanceof PointTileParameters) { final PointTileParameters _o = (PointTileParameters) o; into .putDouble(_o.pointDiameter) .putBoolean(_o.noFill) .putBoolean(_o.noColor); if (highlight != null) into.putUnencodedChars(highlight.toString()); } }
Example #13
Source File: ProbableIntersectionCursorState.java From fdb-record-layer with Apache License 2.0 | 5 votes |
@Override public void funnel(List<Object> objects, PrimitiveSink primitiveSink) { for (Object o : objects) { if (o == null) { primitiveSink.putByte((byte)0x00); } else if (o instanceof byte[]) { primitiveSink.putBytes((byte[])o); } else if (o instanceof ByteString) { primitiveSink.putBytes(((ByteString)o).toByteArray()); } else if (o instanceof ByteBuffer) { primitiveSink.putBytes((ByteBuffer) o); } else if (o instanceof String) { primitiveSink.putString((String)o, Charsets.UTF_8); } else if (o instanceof Float) { primitiveSink.putFloat((float)o); } else if (o instanceof Double) { primitiveSink.putDouble((double)o); } else if (o instanceof Integer) { primitiveSink.putInt((int)o); } else if (o instanceof Long) { primitiveSink.putLong((long) o); } else if (o instanceof Boolean) { primitiveSink.putBoolean((boolean)o); } else if (o instanceof Enum) { primitiveSink.putInt(((Enum)o).ordinal()); } else { primitiveSink.putBytes(Tuple.from(o).pack()); } } }
Example #14
Source File: LocationStrategy.java From datawave with Apache License 2.0 | 5 votes |
public void funnel(RangeSplit rangeSplit, PrimitiveSink sink) { try { for (String location : rangeSplit.getLocations()) { sink.putString(location.trim().toLowerCase()); } } catch (IOException e) { log.error(e); } }
Example #15
Source File: KarelDbCellId.java From kareldb with Apache License 2.0 | 5 votes |
@Override public void funnel(Comparable[] array, PrimitiveSink into) { for (Comparable c : array) { if (c instanceof Boolean) { into.putBoolean((Boolean) c); } else if (c instanceof Integer) { into.putInt((Integer) c); } else if (c instanceof Long) { into.putLong((Long) c); } else if (c instanceof Float) { into.putFloat((Float) c); } else if (c instanceof Double) { into.putDouble((Double) c); } else if (c instanceof ByteString) { into.putBytes(((ByteString) c).getBytes()); } else if (c instanceof String) { into.putString((String) c, UTF_8); } else if (c instanceof BigDecimal) { into.putDouble(((BigDecimal) c).doubleValue()); } else if (c instanceof Date) { into.putLong(((Date) c).getTime()); } else if (c instanceof Time) { into.putLong(((Time) c).getTime()); } else if (c instanceof Timestamp) { into.putLong(((Timestamp) c).getTime()); } else { throw new IllegalArgumentException("Unsupported object of type " + c.getClass().getName()); } } }
Example #16
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { int value = random.nextInt(); for (PrimitiveSink sink : sinks) { sink.putByte((byte) value); } }
Example #17
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { String s = new String(new char[] {randomHighSurrogate(random), randomLowSurrogate(random)}); for (PrimitiveSink sink : sinks) { sink.putUnencodedChars(s); } }
Example #18
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { byte[] value = new byte[random.nextInt(128)]; random.nextBytes(value); int off = random.nextInt(value.length + 1); int len = random.nextInt(value.length - off + 1); for (PrimitiveSink sink : sinks) { sink.putBytes(value, off, len); } }
Example #19
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { byte[] value = new byte[random.nextInt(128)]; random.nextBytes(value); int pos = random.nextInt(value.length + 1); int limit = pos + random.nextInt(value.length - pos + 1); for (PrimitiveSink sink : sinks) { ByteBuffer buffer = ByteBuffer.wrap(value); buffer.position(pos); buffer.limit(limit); sink.putBytes(buffer); assertEquals(limit, buffer.limit()); assertEquals(limit, buffer.position()); } }
Example #20
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { byte[] value = new byte[random.nextInt(128)]; random.nextBytes(value); for (PrimitiveSink sink : sinks) { sink.putBytes(value); } }
Example #21
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { double value = random.nextDouble(); for (PrimitiveSink sink : sinks) { sink.putDouble(value); } }
Example #22
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { char[] value = new char[random.nextInt(128)]; for (int i = 0; i < value.length; i++) { value[i] = (char) random.nextInt(); } String s = new String(value); for (PrimitiveSink sink : sinks) { sink.putUnencodedChars(s); } }
Example #23
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { float value = random.nextFloat(); for (PrimitiveSink sink : sinks) { sink.putFloat(value); } }
Example #24
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { long value = random.nextLong(); for (PrimitiveSink sink : sinks) { sink.putLong(value); } }
Example #25
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { String s = new String(new char[] {randomLowSurrogate(random)}); for (PrimitiveSink sink : sinks) { sink.putUnencodedChars(s); } }
Example #26
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { String s = new String(new char[] {randomHighSurrogate(random)}); for (PrimitiveSink sink : sinks) { sink.putUnencodedChars(s); } }
Example #27
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { int value = random.nextInt(); for (PrimitiveSink sink : sinks) { sink.putInt(value); } }
Example #28
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { char value = (char) random.nextInt(); for (PrimitiveSink sink : sinks) { sink.putChar(value); } }
Example #29
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { short value = (short) random.nextInt(); for (PrimitiveSink sink : sinks) { sink.putShort(value); } }
Example #30
Source File: HashTestUtils.java From zetasketch with Apache License 2.0 | 5 votes |
@Override void performAction(Random random, Iterable<? extends PrimitiveSink> sinks) { String s = new String(new char[] {randomLowSurrogate(random), randomHighSurrogate(random)}); for (PrimitiveSink sink : sinks) { sink.putUnencodedChars(s); } }