@Override public Block copyRegion(int position, int length) { checkValidRegion(positionCount, position, length); int[] newIds = Arrays.copyOfRange(ids, idsOffset + position, idsOffset + position + length); DictionaryBlock dictionaryBlock = new DictionaryBlock(dictionary, newIds); return dictionaryBlock.compact(); }
/** * Create a new block from the current block by keeping the same elements * only with respect to {@code positions} that starts at {@code offset} and has length of {@code length}. * May return a view over the data in this block or may return a copy */ default Block getPositions(int[] positions, int offset, int length) { checkArrayRange(positions, offset, length); return new DictionaryBlock(offset, length, this, positions, false, randomDictionaryId()); }
private static DictionaryBlock createDictionaryBlock(Slice[] expectedValues, int positionCount) { int dictionarySize = expectedValues.length; int[] ids = new int[positionCount]; for (int i = 0; i < positionCount; i++) { ids[i] = i % dictionarySize; } return new DictionaryBlock(createSlicesBlock(expectedValues), ids); }
private static DictionaryBlock createDictionaryBlock(Slice[] expectedValues, int positionCount) { int dictionarySize = expectedValues.length; int[] ids = new int[positionCount]; for (int i = 0; i < positionCount; i++) { ids[i] = i % dictionarySize; } return new DictionaryBlock(createSlicesBlock(expectedValues), ids); }
private static Block createKeyBlock(int positionCount, List<String> keys) { Block keyDictionaryBlock = createSliceArrayBlock(keys); int[] keyIds = new int[positionCount * keys.size()]; for (int i = 0; i < keyIds.length; i++) { keyIds[i] = i % keys.size(); } return new DictionaryBlock(keyDictionaryBlock, keyIds); }
@Override public Block getLoadedBlock() { Block loadedDictionary = dictionary.getLoadedBlock(); if (loadedDictionary == dictionary) { return this; } return new DictionaryBlock(idsOffset, getPositionCount(), loadedDictionary, ids, false, randomDictionaryId()); }
private static DictionaryBlock createDictionaryBlock(Slice[] expectedValues, int positionCount) { int dictionarySize = expectedValues.length; int[] ids = new int[positionCount]; for (int i = 0; i < positionCount; i++) { ids[i] = i % dictionarySize; } return new DictionaryBlock(createSlicesBlock(expectedValues), ids); }
@Test public void testDictionaryBlock() { Block keyDictionaryBlock = createVariableWidthBlock(EXPECTED_ENTRIES); int[] keyIds = new int[EXPECTED_ENTRIES]; for (int i = 0; i < keyIds.length; i++) { keyIds[i] = i; } checkRetainedSize(new DictionaryBlock(EXPECTED_ENTRIES, keyDictionaryBlock, keyIds), false); }
@Test public void testDictionaryBlock() { Block keyDictionaryBlock = createVariableWidthBlock(EXPECTED_ENTRIES); int[] keyIds = new int[EXPECTED_ENTRIES]; for (int i = 0; i < keyIds.length; i++) { keyIds[i] = i; } checkRetainedSize(new DictionaryBlock(EXPECTED_ENTRIES, keyDictionaryBlock, keyIds), false); }
private static DictionaryBlock createDictionaryBlockWithUnusedEntries(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(-10, dictionarySize); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> (index % dictionarySize) + 10); return new DictionaryBlock(dictionary, ids); }
private static DictionaryBlock createDictionaryBlock(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(0, dictionarySize); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> index % dictionarySize); return new DictionaryBlock(dictionary, ids); }
private static DictionaryBlock createDictionaryBlockWithFailure(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(-10, dictionarySize - 10); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> index % dictionarySize); return new DictionaryBlock(dictionary, ids); }
private static DictionaryBlock createDictionaryBlockWithUnusedEntries(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(-10, dictionarySize); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> (index % dictionarySize) + 10); return new DictionaryBlock(dictionary, ids); }
private static DictionaryBlock createDictionaryBlock(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(0, dictionarySize); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> index % dictionarySize); return new DictionaryBlock(dictionary, ids); }
public static DictionaryBlock createTestDictionaryBlock(Block block) { int[] dictionaryIndexes = createTestDictionaryIndexes(block.getPositionCount()); return new DictionaryBlock(dictionaryIndexes.length, block, dictionaryIndexes); }
private static DictionaryBlock createDictionaryBlock(int dictionarySize, int blockSize) { Block dictionary = createLongSequenceBlock(0, dictionarySize); int[] ids = new int[blockSize]; Arrays.setAll(ids, index -> index % dictionarySize); return new DictionaryBlock(dictionary, ids); }
public static DictionaryBlock createTestDictionaryBlock(Block block) { int[] dictionaryIndexes = createTestDictionaryIndexes(block.getPositionCount()); return new DictionaryBlock(dictionaryIndexes.length, block, dictionaryIndexes); }
@Test public void testDictionaryBlockProcessingWithUnusedFailure() { // match some testFilter(createDictionaryBlockWithUnusedEntries(20, 100), DictionaryBlock.class); // match none testFilter(createDictionaryBlockWithUnusedEntries(20, 0), DictionaryBlock.class); // match all testFilter(new DictionaryBlock(createLongsBlock(4, 5, -1), new int[100]), DictionaryBlock.class); }
@Test public void testDictionaryBlock() { // match some testFilter(createDictionaryBlock(20, 100), LongArrayBlock.class); // match none testFilter(createDictionaryBlock(20, 0), LongArrayBlock.class); // match all testFilter(new DictionaryBlock(createLongSequenceBlock(4, 5), new int[100]), LongArrayBlock.class); }
@Test public void testDictionaryBlockProcessingWithUnusedFailure() { // match some testFilter(createDictionaryBlockWithUnusedEntries(20, 100), DictionaryBlock.class); // match none testFilter(createDictionaryBlockWithUnusedEntries(20, 0), DictionaryBlock.class); // match all testFilter(new DictionaryBlock(createLongsBlock(4, 5, -1), new int[100]), DictionaryBlock.class); }