コード例 #1
0
 /**
  * Serializes the data set to file using the following format:
  *
  * <ul>
  *   <li>FuzzySet --&gt;FuzzySetVersion,HashFunctionName,BloomSize,
  *       NumBitSetWords,BitSetWord<sup>NumBitSetWords</sup>
  *   <li>HashFunctionName --&gt; {@link DataOutput#writeString(String) String} The name of a
  *       ServiceProvider registered {@link HashFunction}
  *   <li>FuzzySetVersion --&gt; {@link DataOutput#writeInt Uint32} The version number of the
  *       {@link FuzzySet} class
  *   <li>BloomSize --&gt; {@link DataOutput#writeInt Uint32} The modulo value used to project
  *       hashes into the field's Bitset
  *   <li>NumBitSetWords --&gt; {@link DataOutput#writeInt Uint32} The number of longs (as returned
  *       from {@link FixedBitSet#getBits})
  *   <li>BitSetWord --&gt; {@link DataOutput#writeLong Long} A long from the array returned by
  *       {@link FixedBitSet#getBits}
  * </ul>
  *
  * @param out Data output stream
  * @throws IOException If there is a low-level I/O error
  */
 public void serialize(DataOutput out) throws IOException {
   out.writeInt(VERSION_CURRENT);
   out.writeInt(bloomSize);
   long[] bits = filter.getBits();
   out.writeInt(bits.length);
   for (int i = 0; i < bits.length; i++) {
     // Can't used VLong encoding because cant cope with negative numbers
     // output by FixedBitSet
     out.writeLong(bits[i]);
   }
 }
コード例 #2
0
ファイル: JaspellLookup.java プロジェクト: rmuir/lucene-solr
 private void writeRecursively(DataOutput out, TSTNode node) throws IOException {
   if (node == null) {
     return;
   }
   out.writeString(new String(new char[] {node.splitchar}, 0, 1));
   byte mask = 0;
   if (node.relatives[TSTNode.LOKID] != null) mask |= LO_KID;
   if (node.relatives[TSTNode.EQKID] != null) mask |= EQ_KID;
   if (node.relatives[TSTNode.HIKID] != null) mask |= HI_KID;
   if (node.data != null) mask |= HAS_VALUE;
   out.writeByte(mask);
   if (node.data != null) {
     out.writeLong(((Number) node.data).longValue());
   }
   writeRecursively(out, node.relatives[TSTNode.LOKID]);
   writeRecursively(out, node.relatives[TSTNode.EQKID]);
   writeRecursively(out, node.relatives[TSTNode.HIKID]);
 }
コード例 #3
0
 // pre-order traversal
 private void writeRecursively(DataOutput out, TernaryTreeNode node) throws IOException {
   // write out the current node
   out.writeString(new String(new char[] {node.splitchar}, 0, 1));
   // prepare a mask of kids
   byte mask = 0;
   if (node.eqKid != null) mask |= EQ_KID;
   if (node.loKid != null) mask |= LO_KID;
   if (node.hiKid != null) mask |= HI_KID;
   if (node.token != null) mask |= HAS_TOKEN;
   if (node.val != null) mask |= HAS_VALUE;
   out.writeByte(mask);
   if (node.token != null) out.writeString(node.token);
   if (node.val != null) out.writeLong(((Number) node.val).longValue());
   // recurse and write kids
   if (node.loKid != null) {
     writeRecursively(out, node.loKid);
   }
   if (node.eqKid != null) {
     writeRecursively(out, node.eqKid);
   }
   if (node.hiKid != null) {
     writeRecursively(out, node.hiKid);
   }
 }