From 8134a36e824ad9ce1cfc2330f253c7925ac46668 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Mon, 2 Jul 2012 13:55:45 +0000 Subject: [PATCH] PackedInts: backward-compatibility tests. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1356228 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/util/packed/PackedInts.java | 6 +-- .../lucene/util/packed/TestPackedInts.java | 38 +++++++++++++++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java b/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java index dcd39ea2190..a7a14377938 100644 --- a/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java +++ b/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java @@ -62,9 +62,9 @@ public class PackedInts { */ public static final int DEFAULT_BUFFER_SIZE = 1024; // 1K - private final static String CODEC_NAME = "PackedInts"; - private final static int VERSION_START = 0; - private final static int VERSION_CURRENT = VERSION_START; + final static String CODEC_NAME = "PackedInts"; + final static int VERSION_START = 0; + final static int VERSION_CURRENT = VERSION_START; static final int PACKED = 0; static final int PACKED_SINGLE_BLOCK = 1; diff --git a/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java b/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java index d9abf3ee841..0416fc50456 100644 --- a/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java +++ b/lucene/core/src/test/org/apache/lucene/util/packed/TestPackedInts.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.store.*; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util._TestUtil; @@ -53,23 +54,54 @@ public class TestPackedInts extends LuceneTestCase { public void testPackedInts() throws IOException { int num = atLeast(5); for (int iter = 0; iter < num; iter++) { - for(int nbits=1;nbits<63;nbits++) { + for(int nbits=1;nbits<=64;nbits++) { final long maxValue = PackedInts.maxValue(nbits); final int valueCount = 100+random().nextInt(500); final Directory d = newDirectory(); IndexOutput out = d.createOutput("out.bin", newIOContext(random())); PackedInts.Writer w = PackedInts.getWriter( - out, valueCount, nbits, random().nextFloat()*PackedInts.FASTEST); + out, valueCount, nbits, random().nextFloat()); + final long startFp = out.getFilePointer(); + final int actualValueCount = random().nextBoolean() ? valueCount : _TestUtil.nextInt(random(), 0, valueCount); final long[] values = new long[valueCount]; - for(int i=0;i