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

Method writeTo

output/java_guava/1.4.18/BloomFilter.java:485–498  ·  view source on GitHub ↗

Writes this BloomFilter to an output stream, with a custom format (not Java serialization). This has been measured to save at least 400 bytes compared to regular serialization. Use plain #readFrom(InputStream, Funnel) to reconstruct the written BloomFilter.

(OutputStream out)

Source from the content-addressed store, hash-verified

483
484
485 public void writeTo(OutputStream out) throws IOException {
486 // Serial form:
487 // 1 signed byte for the strategy
488 // 1 unsigned byte for the number of hash functions
489 // 1 big endian int, the number of longs in our bitset
490 // N big endian longs of our bitset
491 DataOutputStream dout = new DataOutputStream(out);
492 dout.writeByte(SignedBytes.checkedCast(strategy.ordinal()));
493 dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor
494 dout.writeInt(bits.data.length);
495 for (long value : bits.data) {
496 dout.writeLong(value);
497 }
498 }
499
500 /**
501 * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a

Callers 1

toByteArrayMethod · 0.45

Calls 6

checkedCastMethod · 0.95
checkedCastMethod · 0.95
writeByteMethod · 0.65
ordinalMethod · 0.65
writeIntMethod · 0.65
writeLongMethod · 0.65

Tested by

no test coverage detected