/// <summary> /// Serializes the data set to file using the following format: /// <list type="bullet"> /// <item><description>FuzzySet -->FuzzySetVersion,HashFunctionName,BloomSize, /// NumBitSetWords,BitSetWord<sup>NumBitSetWords</sup></description></item> /// <item><description>HashFunctionName --> String (<see cref="DataOutput.WriteString(string)"/>) The /// name of a ServiceProvider registered <see cref="HashFunction"/></description></item> /// <item><description>FuzzySetVersion --> Uint32 (<see cref="DataOutput.WriteInt32(int)"/>) The version number of the <see cref="FuzzySet"/> class</description></item> /// <item><description>BloomSize --> Uint32 (<see cref="DataOutput.WriteInt32(int)"/>) The modulo value used /// to project hashes into the field's Bitset</description></item> /// <item><description>NumBitSetWords --> Uint32 (<see cref="DataOutput.WriteInt32(int)"/>) The number of /// longs (as returned from <see cref="FixedBitSet.GetBits()"/>)</description></item> /// <item><description>BitSetWord --> Long (<see cref="DataOutput.WriteInt64(long)"/>) A long from the array /// returned by <see cref="FixedBitSet.GetBits()"/></description></item> /// </list> /// </summary> /// <param name="output">Data output stream.</param> /// <exception cref="System.IO.IOException">If there is a low-level I/O error.</exception> public virtual void Serialize(DataOutput output) { output.WriteInt32(VERSION_CURRENT); output.WriteInt32(_bloomSize); var bits = _filter.GetBits(); output.WriteInt32(bits.Length); foreach (var t in bits) { // Can't used VLong encoding because cant cope with negative numbers // output by FixedBitSet output.WriteInt64(t); } }
public long RamBytesUsed() { return(RamUsageEstimator.SizeOf(_filter.GetBits())); }