private static <T> void assertPositionValue(Block block, int position, T expectedValue) { if (expectedValue == null) { assertTrue(block.isNull(position)); return; } assertFalse(block.isNull(position)); if (expectedValue instanceof Slice) { Slice expectedSliceValue = (Slice) expectedValue; int length = block.getSliceLength(position); assertEquals(length, expectedSliceValue.length()); Slice actual = block.getSlice(position, 0, length); assertEquals(actual, expectedSliceValue); } else if (expectedValue instanceof Slice[]) { // array or row Block actual = block.getObject(position, Block.class); assertBlock(actual, (Slice[]) expectedValue); } else if (expectedValue instanceof Slice[][]) { // map Block actual = block.getObject(position, Block.class); // a map is exposed as a block alternating key and value entries, so we need to flatten the expected values array assertBlock(actual, flattenMapEntries((Slice[][]) expectedValue)); } else { throw new IllegalArgumentException(expectedValue.getClass().getName()); } }
private static <T> void verifyBlock(Block block, T[] expectedValues) { assertBlock(block, expectedValues); assertColumnarRow(block, expectedValues); assertDictionaryBlock(block, expectedValues); assertRunLengthEncodedBlock(block, expectedValues); int offset = 1; int length = expectedValues.length - 2; Block blockRegion = block.getRegion(offset, length); T[] expectedValuesRegion = Arrays.copyOfRange(expectedValues, offset, offset + length); assertBlock(blockRegion, expectedValuesRegion); assertColumnarRow(blockRegion, expectedValuesRegion); assertDictionaryBlock(blockRegion, expectedValuesRegion); assertRunLengthEncodedBlock(blockRegion, expectedValuesRegion); }
private static void verifyBlock(Block block, Slice[][][] expectedValues) { assertBlock(block, expectedValues); assertColumnarMap(block, expectedValues); assertDictionaryBlock(block, expectedValues); assertRunLengthEncodedBlock(block, expectedValues); int offset = 1; int length = expectedValues.length - 2; Block blockRegion = block.getRegion(offset, length); Slice[][][] expectedValuesRegion = Arrays.copyOfRange(expectedValues, offset, offset + length); assertBlock(blockRegion, expectedValuesRegion); assertColumnarMap(blockRegion, expectedValuesRegion); assertDictionaryBlock(blockRegion, expectedValuesRegion); assertRunLengthEncodedBlock(blockRegion, expectedValuesRegion); }
private static <T> void verifyBlock(Block block, T[] expectedValues) { assertBlock(block, expectedValues); assertColumnarArray(block, expectedValues); assertDictionaryBlock(block, expectedValues); assertRunLengthEncodedBlock(block, expectedValues); int offset = 1; int length = expectedValues.length - 2; Block blockRegion = block.getRegion(offset, length); T[] expectedValuesRegion = Arrays.copyOfRange(expectedValues, offset, offset + length); assertBlock(blockRegion, expectedValuesRegion); assertColumnarArray(blockRegion, expectedValuesRegion); assertDictionaryBlock(blockRegion, expectedValuesRegion); assertRunLengthEncodedBlock(blockRegion, expectedValuesRegion); }
private static <T> void assertDictionaryBlock(Block block, T[] expectedValues) { DictionaryBlock dictionaryBlock = createTestDictionaryBlock(block); T[] expectedDictionaryValues = createTestDictionaryExpectedValues(expectedValues); assertBlock(dictionaryBlock, expectedDictionaryValues); assertColumnarArray(dictionaryBlock, expectedDictionaryValues); assertRunLengthEncodedBlock(dictionaryBlock, expectedDictionaryValues); }
private static <T> void assertRunLengthEncodedBlock(Block block, T[] expectedValues) { for (int position = 0; position < block.getPositionCount(); position++) { RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position); T[] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position); assertBlock(runLengthEncodedBlock, expectedDictionaryValues); assertColumnarRow(runLengthEncodedBlock, expectedDictionaryValues); } }
private static <T> void assertRunLengthEncodedBlock(Block block, T[] expectedValues) { for (int position = 0; position < block.getPositionCount(); position++) { RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position); T[] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position); assertBlock(runLengthEncodedBlock, expectedDictionaryValues); assertColumnarArray(runLengthEncodedBlock, expectedDictionaryValues); } }
private static void assertDictionaryBlock(Block block, Slice[][][] expectedValues) { DictionaryBlock dictionaryBlock = createTestDictionaryBlock(block); Slice[][][] expectedDictionaryValues = createTestDictionaryExpectedValues(expectedValues); assertBlock(dictionaryBlock, expectedDictionaryValues); assertColumnarMap(dictionaryBlock, expectedDictionaryValues); assertRunLengthEncodedBlock(dictionaryBlock, expectedDictionaryValues); }
private static void assertRunLengthEncodedBlock(Block block, Slice[][][] expectedValues) { for (int position = 0; position < block.getPositionCount(); position++) { RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position); Slice[][][] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position); assertBlock(runLengthEncodedBlock, expectedDictionaryValues); assertColumnarMap(runLengthEncodedBlock, expectedDictionaryValues); } }
private static <T> void assertDictionaryBlock(Block block, T[] expectedValues) { DictionaryBlock dictionaryBlock = createTestDictionaryBlock(block); T[] expectedDictionaryValues = createTestDictionaryExpectedValues(expectedValues); assertBlock(dictionaryBlock, expectedDictionaryValues); assertColumnarRow(dictionaryBlock, expectedDictionaryValues); assertRunLengthEncodedBlock(dictionaryBlock, expectedDictionaryValues); }