@Test
    public void testRangeDistributionIncreaseMultipleBits() throws ParseException {
        int db = 16;
        BucketIdFactory idFactory = new BucketIdFactory();
        ProgressToken p = new ProgressToken();

        VisitorIterator iter = VisitorIterator.createFromDocumentSelection(
                "id.group != \"yahoo.com\"", idFactory, db, p);

        // For this test, have 3 finished bucket, 2 pending and 1 active
        for (int i = 0; i < 3; ++i) {
            iter.update(iter.getNext().getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        }

        VisitorIterator.BucketProgress[] bpp = new VisitorIterator.BucketProgress[2];
        bpp[0] = iter.getNext();
        bpp[1] = iter.getNext();
        VisitorIterator.BucketProgress bpa = iter.getNext(); // Leave this hanging as active
        iter.update(bpp[0].getSuperbucket(), new BucketId());
        iter.update(bpp[1].getSuperbucket(), new BucketId());

        iter.setDistributionBitCount(20);
        // ProgressToken doesn't change yet, since it had active buckets
        assertEquals(p.getDistributionBitCount(), 16);
        assertEquals(iter.getDistributionBitCount(), 20);
        assertEquals(iter.getBucketSource().getDistributionBitCount(), 20);

        assertFalse(iter.hasNext());
        assertFalse(iter.isDone());
        assertTrue(iter.getBucketSource().shouldYield());
        assertEquals(p.getPendingBucketCount(), 2);
        assertEquals(p.getActiveBucketCount(), 1);

        // Finish active, triggering the consistency fixes
        iter.update(bpa.getSuperbucket(), ProgressToken.FINISHED_BUCKET);

        assertEquals(p.getDistributionBitCount(), 20);
        assertEquals(p.getPendingBucketCount(), 32);
        assertEquals(p.getActiveBucketCount(), 0);
        // Each bucket with db:16 becomes equal to 16 buckets with db:20, so
        // the bucket space position must be 16 * 6 = 96
        assertEquals(p.getBucketCursor(), 96);
        // Each finished bucket also covers less ground, so count is upped
        // accordingly
        assertEquals(p.getFinishedBucketCount(), 16 * 4);

        // Remove pending that came from the split
        // Bucket space that should be covered by the 32 buckets is [48, 80)
        // when using 20 distribution bits
        for (int i = 0; i < 32; ++i) {
            long testKey = ProgressToken.makeNthBucketKey(i + 48, 20);
            VisitorIterator.BucketProgress bp = iter.getNext();
            assertEquals(bp.getSuperbucket(), new BucketId(ProgressToken.keyToBucketId(testKey)));
            iter.update(bp.getSuperbucket(), ProgressToken.FINISHED_BUCKET);
        }
        assertEquals(p.getPendingBucketCount(), 0);
        assertEquals(p.getFinishedBucketCount(), 16 * 6);

        // Bucket source should now begin returning from bucket 20:0x6000
        assertEquals(iter.getNext().getSuperbucket(), new BucketId(20, 0x6000));
    }
Test increasing the distribution bits for a full bucket space range
source with no finished, active or pending buckets
@throws ParseException upon docsel parse failure (shouldn't happen)
documentapi/src/test/java/com/yahoo/documentapi/VisitorIteratorTestCase.java