@Test
    public void testRangeDistributionLosslessReset() throws ParseException {
        int db = 1;
        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[] bp = new VisitorIterator.BucketProgress[2];
        bp[0] = iter.getNext();
        bp[1] = iter.getNext();

        String serialized = p.toString();

        assertFalse(src.isLosslessResetPossible());

        iter.update(bp[1].getSuperbucket(), new BucketId());
        assertEquals(p.getActiveBucketCount(), 1);

        iter.setDistributionBitCount(11);

        assertFalse(src.isLosslessResetPossible());
        assertEquals(p.getDistributionBitCount(), 1); // Still at 1

        assertFalse(iter.hasNext());
        assertFalse(iter.isDone());
        assertEquals(p.getActiveBucketCount(), 1);

        // Updating the active bucket allows the reset to take place
        iter.update(new BucketId(1, 0), new BucketId());

        assertTrue(iter.hasNext());
        assertFalse(iter.isDone());

        // Should not be any buckets pending/active and the cursor should be
        // back at 0
        assertEquals(p.getPendingBucketCount(), 0);
        assertEquals(p.getActiveBucketCount(), 0);
        assertEquals(p.getFinishedBucketCount(), 0);
        assertEquals(p.getBucketCursor(), 0);
        assertEquals(p.getDistributionBitCount(), 11);

        bp[0] = iter.getNext();
        assertEquals(bp[0].getSuperbucket(), new BucketId(11, 0));

        // Ensure resetting also works when you're importing existing
        // progress
        p = new ProgressToken(serialized);
        idFactory = new BucketIdFactory();
        iter = VisitorIterator.createFromDocumentSelection(
                "id.group != \"yahoo.com\"", idFactory, 1, p);

        iter.setDistributionBitCount(11);

        assertEquals(p.getPendingBucketCount(), 0);
        assertEquals(p.getActiveBucketCount(), 0);
        assertEquals(p.getFinishedBucketCount(), 0);
        assertEquals(p.getBucketCursor(), 0);
        assertEquals(p.getDistributionBitCount(), 11);

        bp[0] = iter.getNext();
        assertEquals(bp[0].getSuperbucket(), new BucketId(11, 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