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

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

        VisitorIterator.DistributionRangeBucketSource src
                = (VisitorIterator.DistributionRangeBucketSource)iter.getBucketSource();

        VisitorIterator.BucketProgress[] bpp = new VisitorIterator.BucketProgress[4];
        for (int i = 0; i < 4; ++i) {
            bpp[i] = iter.getNext();
        }
        for (int i = 0; i < 2; ++i) {
            iter.update(bpp[i].getSuperbucket(), new BucketId());
        }

        assertFalse(src.isLosslessResetPossible());

        // Now 2 pending, 2 active

        iter.setDistributionBitCount(9);
        assertEquals(p.getDistributionBitCount(), 11);
        assertEquals(p.getActiveBucketCount(), 2);
        assertEquals(p.getPendingBucketCount(), 2);
        assertTrue(iter.getBucketSource().shouldYield());
        // Update as pending, still with old count since there's 1 more active
        // with bpp[2]. Have progress so that lossless reset isn't possible
        iter.update(bpp[3].getSuperbucket(), new BucketId(15, bpp[3].getSuperbucket().getId()));

        iter.setDistributionBitCount(12);
        assertEquals(p.getActiveBucketCount(), 1);
        assertEquals(p.getPendingBucketCount(), 3);
        assertTrue(iter.getBucketSource().shouldYield());

        // Serialize before token is updated to 12 bits
        String serialized = p.toString();

        iter.update(bpp[2].getSuperbucket(), ProgressToken.FINISHED_BUCKET);

        assertEquals(p.getActiveBucketCount(), 0);
        // All active buckets are at db=11, so they should be split once each
        assertEquals(p.getPendingBucketCount(), 3 * 2);
        assertFalse(iter.getBucketSource().shouldYield());
        assertEquals(p.getFinishedBucketCount(), 2);

        // Ensure we get a consistent progress token imported
        ProgressToken p2 = new ProgressToken(serialized);
        assertEquals(p2.getDistributionBitCount(), 11); // Not yet updated

        BucketIdFactory idFactory2 = new BucketIdFactory();
        VisitorIterator iter2 = VisitorIterator.createFromDocumentSelection(
                "id.group != \"yahoo.com\"", idFactory2, 1, p2);

        // Not yet updated, since we don't trust the initial BucketIdFactory
        assertEquals(iter2.getDistributionBitCount(), 11);
        assertEquals(p2.getDistributionBitCount(), 11);
        iter2.setDistributionBitCount(12);
        // Now it has been updated
        assertEquals(p2.getDistributionBitCount(), 12);
        assertEquals(p2.getPendingBucketCount(), 8);
        assertEquals(p2.getBucketCursor(), 8);
        assertEquals(p2.getFinishedBucketCount(), 0);
    }
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