while ( (line = bufReader.readLine()) != null )
{
/* After accumulating count_ keys reset the bloom filter. */
if ( keyCount > 0 && keyCount % count_ == 0 )
{
DataOutputBuffer bufOut = new DataOutputBuffer();
BloomFilter.serializer().serialize(bf, bufOut);
System.out.println("Finished serializing the bloom filter");
buffers.add(bufOut);
bf = new BloomFilter(count_, 8);
}
line = line.trim();
bf.add(line);
++keyCount;
}
}
/* Add the bloom filter assuming the last one was left out */
DataOutputBuffer bufOut = new DataOutputBuffer();
BloomFilter.serializer().serialize(bf, bufOut);
buffers.add(bufOut);
int size = buffers.size();
for ( int i = 0; i < size; ++i )
{
DataOutputBuffer buffer = buffers.get(i);
String file = args[1] + System.getProperty("file.separator") + "Bloom-Filter-" + i + ".dat";
RandomAccessFile raf = new RandomAccessFile(file, "rw");
raf.write(buffer.getData(), 0, buffer.getLength());
raf.close();
buffer.close();
}
System.out.println("Done writing the bloom filter to disk");
}