MCPcopy Create free account
hub / github.com/apache/orc / runTest

Method runTest

java/core/src/test/org/apache/orc/impl/TestBitPack.java:75–115  ·  view source on GitHub ↗
(int numBits)

Source from the content-addressed store, hash-verified

73 }
74
75 private void runTest(int numBits) throws IOException {
76 long[] inp = new long[SIZE];
77 for (int i = 0; i < SIZE; i++) {
78 long val = 0;
79 if (numBits <= 32) {
80 if (numBits == 1) {
81 val = -1 * rand.nextInt(2);
82 } else {
83 val = rand.nextInt((int) Math.pow(2, numBits - 1));
84 }
85 } else {
86 val = nextLong(rand, (long) Math.pow(2, numBits - 2));
87 }
88 if (val % 2 == 0) {
89 val = -val;
90 }
91 inp[i] = val;
92 }
93 long[] deltaEncoded = deltaEncode(inp);
94 long minInput = Collections.min(Longs.asList(deltaEncoded));
95 long maxInput = Collections.max(Longs.asList(deltaEncoded));
96 long rangeInput = maxInput - minInput;
97 SerializationUtils utils = new SerializationUtils();
98 int fixedWidth = utils.findClosestNumBits(rangeInput);
99 TestInStream.OutputCollector collect = new TestInStream.OutputCollector();
100 OutStream output = new OutStream("test", new StreamOptions(SIZE), collect);
101 utils.writeInts(deltaEncoded, 0, deltaEncoded.length, fixedWidth, output);
102 output.flush();
103 ByteBuffer inBuf = ByteBuffer.allocate(collect.buffer.size());
104 collect.buffer.setByteBuffer(inBuf, 0, collect.buffer.size());
105 inBuf.flip();
106 long[] buff = new long[SIZE];
107 utils.readInts(buff, 0, SIZE, fixedWidth,
108 InStream.create("test", new BufferChunk(inBuf,0), 0,
109 inBuf.remaining()));
110 for (int i = 0; i < SIZE; i++) {
111 buff[i] = utils.zigzagDecode(buff[i]);
112 }
113 assertEquals(numBits, fixedWidth);
114 assertArrayEquals(inp, buff);
115 }
116
117 @Test
118 public void test01BitPacking1Bit() throws IOException {

Callers 15

test01BitPacking1BitMethod · 0.95
test02BitPacking2BitMethod · 0.95
test03BitPacking3BitMethod · 0.95
test04BitPacking4BitMethod · 0.95
test05BitPacking5BitMethod · 0.95
test06BitPacking6BitMethod · 0.95
test07BitPacking7BitMethod · 0.95
test08BitPacking8BitMethod · 0.95
test09BitPacking9BitMethod · 0.95
test10BitPacking10BitMethod · 0.95
test11BitPacking11BitMethod · 0.95
test12BitPacking12BitMethod · 0.95

Calls 12

nextLongMethod · 0.95
deltaEncodeMethod · 0.95
findClosestNumBitsMethod · 0.95
writeIntsMethod · 0.95
flushMethod · 0.95
readIntsMethod · 0.95
createMethod · 0.95
zigzagDecodeMethod · 0.95
nextIntMethod · 0.80
setByteBufferMethod · 0.80
flipMethod · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected