~pbeaman/akiban-persistit/buffer-pool-warmup-sorted

« back to all changes in this revision

Viewing changes to src/test/java/com/persistit/MVCCPruneTest.java

Merge from eclipse_canonical_format

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
            store(ex1, KEY, VALUE_TRX1);
154
154
            assertEquals("value from trx1 store", VALUE_TRX1, fetch(ex1, KEY));
155
155
            trx1.rollback();
156
 
        } catch (RollbackException e) {
 
156
        } catch (final RollbackException e) {
157
157
            // Expected
158
158
        } finally {
159
159
            trx1.end();
237
237
 
238
238
        assertEquals("had split before inserting max number of keys", true, hadSplit);
239
239
 
240
 
        Value ex1Value = ex1.getValue();
 
240
        final Value ex1Value = ex1.getValue();
241
241
        ex1.ignoreMVCCFetch(true);
242
242
        ex1.clear().append(Key.BEFORE);
243
243
        while (ex1.next()) {
244
 
            boolean isMVV = MVV.isArrayMVV(ex1Value.getEncodedBytes(), 0, ex1Value.getEncodedSize());
 
244
            final boolean isMVV = MVV.isArrayMVV(ex1Value.getEncodedBytes(), 0, ex1Value.getEncodedSize());
245
245
            assertEquals("last key is MVV", ex1.getKey().decodeString().equals(curKey), isMVV);
246
246
        }
247
247
        ex1.ignoreMVCCFetch(false);
265
265
                trx1.end();
266
266
            }
267
267
        }
268
 
        int VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE = 2;
 
268
        final int VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE = 2;
269
269
        assertEquals("stored versions", VERSIONS.length + 1 - VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE,
270
270
                storedVersionCount(ex2, KEY));
271
271
 
272
272
        trx1.begin();
273
273
        try {
274
 
            String value = VALUE + "_final";
 
274
            final String value = VALUE + "_final";
275
275
            store(ex1, KEY, value);
276
276
            assertEquals("trx value fetched before pre-prune pre-commit", value, fetch(ex1, KEY));
277
277
 
304
304
            }
305
305
        }
306
306
 
307
 
        int VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE = 5;
 
307
        final int VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE = 5;
308
308
 
309
309
        assertEquals("stored versions pre-prune", VERSIONS.length - VERSIONS_NOW_REMOVED_BY_PRUNING_BEFORE_STORE,
310
310
                storedVersionCount(ex2, KEY));
400
400
 
401
401
        int count = 0;
402
402
        ex1.clear().append(Key.BEFORE);
403
 
        while(ex1.traverse(Key.GT, true, 100)) {
 
403
        while (ex1.traverse(Key.GT, true, 100)) {
404
404
            ++count;
405
405
        }
406
406
        assertEquals("Traversed count", 1, count);
407
407
        ex1.clear();
408
 
        boolean hasChildren = ex1.hasChildren();
 
408
        final boolean hasChildren = ex1.hasChildren();
409
409
        assertEquals("Has children", true, hasChildren);
410
410
    }
411
411
 
413
413
    // Test helper methods
414
414
    //
415
415
 
416
 
    private void prune(Exchange ex, Object k) throws PersistitException {
 
416
    private void prune(final Exchange ex, final Object k) throws PersistitException {
417
417
        _persistit.getTransactionIndex().cleanup();
418
418
        ex.clear().append(k);
419
419
        ex.prune();
427
427
        }
428
428
 
429
429
        @Override
430
 
        public void sawVersion(long version, int offset, int valueLength) throws PersistitException {
 
430
        public void sawVersion(final long version, final int offset, final int valueLength) throws PersistitException {
431
431
            _versions.add(version);
432
432
        }
433
433
 
436
436
        }
437
437
    }
438
438
 
439
 
    private int storedVersionCount(Exchange ex, Object k1) throws PersistitException {
 
439
    private int storedVersionCount(final Exchange ex, final Object k1) throws PersistitException {
440
440
        ex.ignoreMVCCFetch(true);
441
441
        try {
442
442
            ex.clear().append(k1);
443
443
            ex.fetch();
444
444
 
445
 
            VersionInfoVisitor visitor = new VersionInfoVisitor();
446
 
            Value value = ex.getValue();
 
445
            final VersionInfoVisitor visitor = new VersionInfoVisitor();
 
446
            final Value value = ex.getValue();
447
447
            MVV.visitAllVersions(visitor, value.getEncodedBytes(), 0, value.getEncodedSize());
448
448
 
449
449
            ex.clear().getValue().clear();
453
453
        }
454
454
    }
455
455
 
456
 
    private void storePrimordial(Exchange ex, Object k, Object v) throws PersistitException {
 
456
    private void storePrimordial(final Exchange ex, final Object k, final Object v) throws PersistitException {
457
457
        if (trx1.isActive()) {
458
458
            throw new IllegalStateException("Can only store primordial when outside transaction");
459
459
        }