MCPcopy Create free account
hub / github.com/antlr/codebuff / readFrom

Method readFrom

output/java_guava/1.4.19/BloomFilter.java:516–545  ·  view source on GitHub ↗

Reads a byte stream, which was written by plain #writeTo(OutputStream), into a BloomFilter . The Funnel to be used is not encoded in the stream, so it must be provided here. Warning: the funnel provided must behave identically to the one used to populate the o

(InputStream in, Funnel<T> funnel)

Source from the content-addressed store, hash-verified

514
515
516 public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel)
517 throws IOException {
518 checkNotNull(in, "InputStream");
519 checkNotNull(funnel, "Funnel");
520 int strategyOrdinal = -1;
521 int numHashFunctions = -1;
522 int dataLength = -1;
523 try {
524 DataInputStream din = new DataInputStream(in);
525 // currently this assumes there is no negative ordinal; will have to be updated if we
526 // add non-stateless strategies (for which we've reserved negative ordinals; see
527 // Strategy.ordinal()).
528 strategyOrdinal = din.readByte();
529 numHashFunctions = UnsignedBytes.toInt(din.readByte());
530 dataLength = din.readInt();
531 Strategy strategy = BloomFilterStrategies.values() [strategyOrdinal];
532 long[] data = new long[dataLength];
533 for (int i = 0; i < data.length; i++) {
534 data[i] = din.readLong();
535 }
536 return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
537 } catch (RuntimeException e) {
538 IOException ioException = new IOException("Unable to deserialize BloomFilter from InputStream." + " strategyOrdinal: "
539 + strategyOrdinal
540 + " numHashFunctions: "
541 + numHashFunctions + " dataLength: " + dataLength);
542 ioException.initCause(e);
543 throw ioException;
544 }
545 }
546}

Callers

nothing calls this directly

Calls 6

toIntMethod · 0.95
readByteMethod · 0.65
readIntMethod · 0.65
valuesMethod · 0.65
readLongMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected