public void doHashFileTest(long size, long confidence) throws Exception {
        File tmp = File.createTempFile("hhhhhhh", "ff");

        System.out.println(tmp.getAbsolutePath());
        System.out.println(new Date() + " writing...");

        HashFileBuilder hashWrite = new HashFileBuilder(tmp.getAbsolutePath(),
                size);

        for (long i = 0; i < size; i++) {
            byte[] k = Long.valueOf(i).toString().getBytes();
            byte[] v = Long.valueOf(-i).toString().getBytes();
            hashWrite.add(k, v);
            if (i % 1000000 == 0) {
                System.out.println(new Date() + " wrote: " + i);
            }
        }

        System.out.println(new Date() + " finishing...");
        hashWrite.finish();

        System.out.println(new Date() + " checking iter...");
        int found = 0;
        for (HashEntry entry : HashFile.elements(tmp.getAbsolutePath())) {
            byte[] k = entry.getKey();
            byte[] v = entry.getValue();
            long kk = Long.parseLong(new String(k));
            long kv = Long.parseLong(new String(v));
            Assert.assertTrue(kk == -kv);
            found += 1;
        }

        Assert.assertTrue(found == size);
        Random rand = new Random();

        System.out.println(new Date() + " checking find...");
        HashFile hRead = new HashFile(tmp.getAbsolutePath());
        for (long t = 0; t < confidence; t++) {
            int i = size < Integer.MAX_VALUE ? rand.nextInt((int) size)
                    : (int) (Math.abs(rand.nextLong()) % size);

            byte[] k = Integer.valueOf(i).toString().getBytes();
            byte[] v = Integer.valueOf(-i).toString().getBytes();
            long kk = Long.parseLong(new String(k));
            long kv = Long.parseLong(new String(v));

            byte[] f = hRead.get(k);
            if (f == null) {
                System.out.println("failed on " + i);
            }

            Assert.assertNotNull(f);

            long kf = Long.parseLong(new String(f));

            Assert.assertTrue(kv == kf);
            Assert.assertTrue(kk == -kf);
        }

        System.out.println(new Date() + " checking not found...");
        HashFile hRead2 = new HashFile(tmp.getAbsolutePath());
        for (long t = 0; t < confidence; t++) {
            int r = size < Integer.MAX_VALUE ? rand.nextInt((int) size)
                    : (int) (Math.abs(rand.nextLong()) % size);
            long i = size + r + 1;

            byte[] k = Long.valueOf(i).toString().getBytes();
            byte[] f = hRead2.get(k);
            Assert.assertNull(f);
        }
        System.out.println(new Date() + " done...");

        tmp.delete();
    }