use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class BTreeBlockFinderTest method testBtreeSearchIsWorkingAndGivingPorperBlockletWithDictionaryKey2.
@Test
public void testBtreeSearchIsWorkingAndGivingPorperBlockletWithDictionaryKey2() throws KeyGenException {
BtreeBuilder builder = new BlockBTreeBuilder();
List<DataFileFooter> footerList = getFileFooterListWithOnlyDictionaryKey();
BTreeBuilderInfo infos = new BTreeBuilderInfo(footerList, null);
builder.build(infos);
DataRefNode dataBlock = builder.get();
assertTrue(dataBlock != null);
DataRefNodeFinder finder = new BTreeDataRefNodeFinder(new int[] { 2, 2 }, 2, 0);
int[] dimensionBitLength = CarbonUtil.getDimensionBitLength(new int[] { 10000, 10000 }, new int[] { 1, 1 });
KeyGenerator multiDimKeyVarLengthGenerator = new MultiDimKeyVarLengthGenerator(dimensionBitLength);
IndexKey key = new IndexKey(multiDimKeyVarLengthGenerator.generateKey(new int[] { 0, 0 }), null);
DataRefNode findFirstBlock = finder.findFirstDataBlock(dataBlock, key);
assertEquals(0, findFirstBlock.nodeNumber());
DataRefNode findLastBlock = finder.findLastDataBlock(dataBlock, key);
assertEquals(0, findLastBlock.nodeNumber());
}
use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class BTreeBlockFinderTest method getDataFileFooterList.
private List<DataFileFooter> getDataFileFooterList() {
List<DataFileFooter> list = new ArrayList<DataFileFooter>();
try {
int[] dimensionBitLength = CarbonUtil.getDimensionBitLength(new int[] { 10000, 10000 }, new int[] { 1, 1 });
KeyGenerator multiDimKeyVarLengthGenerator = new MultiDimKeyVarLengthGenerator(dimensionBitLength);
int i = 1;
while (i < 1001) {
byte[] startKey = multiDimKeyVarLengthGenerator.generateKey(new int[] { i, i });
byte[] endKey = multiDimKeyVarLengthGenerator.generateKey(new int[] { i + 10, i + 10 });
ByteBuffer buffer = ByteBuffer.allocate(4 + 1);
buffer.rewind();
buffer.put((byte) 1);
buffer.putInt(i);
buffer.array();
byte[] noDictionaryStartKey = buffer.array();
ByteBuffer buffer1 = ByteBuffer.allocate(4 + 1);
buffer1.rewind();
buffer1.put((byte) 1);
buffer1.putInt(i + 10);
buffer1.array();
byte[] noDictionaryEndKey = buffer.array();
DataFileFooter footer = getFileFooter(startKey, endKey, noDictionaryStartKey, noDictionaryEndKey);
list.add(footer);
i = i + 10;
}
} catch (Exception e) {
LOGGER.error(e);
}
return list;
}
use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class BTreeBlockFinderTest method getFileFooterListWithOnlyDictionaryKey.
private List<DataFileFooter> getFileFooterListWithOnlyDictionaryKey() {
List<DataFileFooter> list = new ArrayList<DataFileFooter>();
try {
int[] dimensionBitLength = CarbonUtil.getDimensionBitLength(new int[] { 10000, 10000 }, new int[] { 1, 1 });
KeyGenerator multiDimKeyVarLengthGenerator = new MultiDimKeyVarLengthGenerator(dimensionBitLength);
int i = 1;
while (i < 1001) {
byte[] startKey = multiDimKeyVarLengthGenerator.generateKey(new int[] { i, i });
byte[] endKey = multiDimKeyVarLengthGenerator.generateKey(new int[] { i + 10, i + 10 });
ByteBuffer buffer = ByteBuffer.allocate(1 + 4);
buffer.rewind();
buffer.put((byte) 1);
buffer.putInt(i);
buffer.array();
byte[] noDictionaryStartKey = buffer.array();
ByteBuffer buffer1 = ByteBuffer.allocate(1 + 4);
buffer1.rewind();
buffer1.put((byte) 1);
buffer1.putInt(i + 10);
buffer1.array();
byte[] noDictionaryEndKey = buffer.array();
DataFileFooter footer = getFileFooterWithOnlyDictionaryKey(startKey, endKey, noDictionaryStartKey, noDictionaryEndKey);
list.add(footer);
i = i + 10;
}
} catch (Exception e) {
LOGGER.error(e);
}
return list;
}
use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class KeyGeneratorFactoryUnitTest method testGetKeyGenerator.
@Test
public void testGetKeyGenerator() throws Exception {
int expected = 3;
int[] dimension = new int[] { 1, 2, 3 };
KeyGenerator result = getKeyGenerator(dimension);
assertEquals(expected, result.getDimCount());
}
use of org.apache.carbondata.core.keygenerator.KeyGenerator in project carbondata by apache.
the class KeyGeneratorFactoryUnitTest method testGetKeyGeneratorNegative.
/**
* Return 0 when we provide empty int[] in method.
*
* @throws Exception
*/
@Test
public void testGetKeyGeneratorNegative() throws Exception {
int expected = 0;
int[] dimension = new int[] {};
KeyGenerator result = getKeyGenerator(dimension);
assertEquals(expected, result.getDimCount());
}
Aggregations