forked from apache/parquet-mr
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update IntList slab creation to keep bumping up size gradually
- Loading branch information
Piyush Narang
committed
Apr 18, 2016
1 parent
ebf1c58
commit 9617015
Showing
2 changed files
with
122 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
parquet-column/src/test/java/org/apache/parquet/column/values/dictionary/IntListTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.parquet.column.values.dictionary; | ||
|
||
import org.junit.Test; | ||
|
||
import junit.framework.Assert; | ||
|
||
public class IntListTest { | ||
|
||
/** | ||
* Test IntList of fairly small size (< 4K), this tests a single slab being created | ||
*/ | ||
@Test | ||
public void testSmallList() { | ||
int testSize = 100; | ||
doTestIntList(testSize); | ||
} | ||
|
||
/** | ||
* Test IntList > 4K so that we have multiple slabs being created | ||
*/ | ||
@Test | ||
public void testListGreaterThan4K() { | ||
int testSize = 6000; | ||
doTestIntList(testSize); | ||
} | ||
|
||
/** | ||
* Test IntList of a fairly large size (> 300K) so that we have multiple slabs | ||
* created of varying sizes | ||
*/ | ||
@Test | ||
public void testListGreaterThan300K() { | ||
int testSize = 310000; | ||
doTestIntList(testSize); | ||
} | ||
|
||
private void doTestIntList(int testSize) { | ||
IntList testList = new IntList(); | ||
populateList(testList, testSize); | ||
|
||
verifyIteratorResults(testSize, testList); | ||
} | ||
|
||
private void populateList(IntList testList, int size) { | ||
for(int i = 0; i < size; i++) { | ||
testList.add(i); | ||
} | ||
} | ||
|
||
private void verifyIteratorResults(int testSize, IntList testList) { | ||
IntList.IntIterator iterator = testList.iterator(); | ||
int expected = 0; | ||
|
||
while (iterator.hasNext()) { | ||
int val = iterator.next(); | ||
Assert.assertEquals(expected, val); | ||
expected++; | ||
} | ||
|
||
//ensure we have the correct final value of expected | ||
Assert.assertEquals(testSize, expected); | ||
} | ||
} |