@Test
  public void test_intersection() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(baos);
    
    HLLCounter hll0 = new HLLCounter(true);
    for (int i=0; i<1000000; i++) {
      hll0.put(Hashing.md5().hashString(Integer.toString(i)).toString());
    }

    HLLCounter hll1 = new HLLCounter(true);
    for (int i=10000; i<1100000; i++) {
      hll1.put(Hashing.md5().hashString(Integer.toString(i)).toString());
    }
    HLLWritable hllw = new HLLWritable(hll0);
    hllw.write(out);
    
    hllw.set(hll1);
    hllw.write(out);
    
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
    HLLWritable deser0 = new HLLWritable();
    deser0.readFields(in);
    
    HLLWritable deser1 = new HLLWritable();
    deser1.readFields(in);
    
    assertEquals(998974, HLLCounter.intersect(deser0.get(), deser1.get()));
  }