Java Code Examples for io.prestosql.spi.block.Block#getLoadedBlock()
The following examples show how to use
io.prestosql.spi.block.Block#getLoadedBlock() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrcBlockFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public final Block load() { checkState(!loaded, "Already loaded"); checkState(currentPageId == expectedPageId, "ORC reader has been advanced beyond block"); loaded = true; try { Block block = blockReader.readBlock(); if (loadFully) { block = block.getLoadedBlock(); } return block; } catch (IOException | RuntimeException e) { throw exceptionTransform.apply(e); } }
Example 2
Source File: ReaderProjectionsAdapter.java From presto with Apache License 2.0 | 6 votes |
/** * Applies dereference operations on the input block to extract the required internal block. If the input block is lazy * in a nested manner, this implementation avoids loading the entire input block. */ private Block loadInternalBlock(List<Integer> dereferences, Block parentBlock) { if (dereferences.size() == 0) { return parentBlock.getLoadedBlock(); } ColumnarRow columnarRow = toColumnarRow(parentBlock); int dereferenceIndex = dereferences.get(0); List<Integer> remainingDereferences = dereferences.subList(1, dereferences.size()); Block fieldBlock = columnarRow.getField(dereferenceIndex); Block loadedInternalBlock = loadInternalBlock(remainingDereferences, fieldBlock); // Field blocks provided by ColumnarRow can have a smaller position count, because they do not store nulls. // The following step adds null elements (when required) to the loaded block. return adaptNulls(columnarRow, loadedInternalBlock); }
Example 3
Source File: TestDictionaryAwarePageFilter.java From presto with Apache License 2.0 | 5 votes |
private static void testFilter(DictionaryAwarePageFilter filter, Block block, boolean filterRange) { IntSet actualSelectedPositions = toSet(filter.filter(null, new Page(block))); block = block.getLoadedBlock(); IntSet expectedSelectedPositions = new IntArraySet(block.getPositionCount()); for (int position = 0; position < block.getPositionCount(); position++) { if (isSelected(filterRange, block.getLong(position, 0))) { expectedSelectedPositions.add(position); } } assertEquals(actualSelectedPositions, expectedSelectedPositions); }
Example 4
Source File: TestDictionaryAwarePageProjection.java From presto with Apache License 2.0 | 5 votes |
private static void testProjectRange(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield, boolean produceLazyBlock) { if (produceLazyBlock) { block = lazyWrapper(block); } DriverYieldSignal yieldSignal = new DriverYieldSignal(); Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10)); Block result; if (forceYield) { result = projectWithYield(work, yieldSignal); } else { assertTrue(work.process()); result = work.getResult(); } if (produceLazyBlock) { assertInstanceOf(result, LazyBlock.class); assertFalse(result.isLoaded()); assertFalse(block.isLoaded()); result = result.getLoadedBlock(); } assertBlockEquals( BIGINT, result, block.getRegion(5, 10)); assertInstanceOf(result, expectedResultType); }
Example 5
Source File: TestDictionaryAwarePageProjection.java From presto with Apache License 2.0 | 5 votes |
private static void testProjectList(Block block, Class<? extends Block> expectedResultType, DictionaryAwarePageProjection projection, boolean forceYield, boolean produceLazyBlock) { if (produceLazyBlock) { block = lazyWrapper(block); } DriverYieldSignal yieldSignal = new DriverYieldSignal(); int[] positions = {0, 2, 4, 6, 8, 10}; Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsList(positions, 0, positions.length)); Block result; if (forceYield) { result = projectWithYield(work, yieldSignal); } else { assertTrue(work.process()); result = work.getResult(); } if (produceLazyBlock) { assertInstanceOf(result, LazyBlock.class); assertFalse(result.isLoaded()); assertFalse(block.isLoaded()); result = result.getLoadedBlock(); } assertBlockEquals( BIGINT, result, block.copyPositions(positions, 0, positions.length)); assertInstanceOf(result, expectedResultType); }
Example 6
Source File: TestDictionaryAwarePageProjection.java From presto with Apache License 2.0 | 5 votes |
private static void testProjectFastReturnIgnoreYield(Block block, DictionaryAwarePageProjection projection, boolean produceLazyBlock) { if (produceLazyBlock) { block = lazyWrapper(block); } DriverYieldSignal yieldSignal = new DriverYieldSignal(); Work<Block> work = projection.project(null, yieldSignal, new Page(block), SelectedPositions.positionsRange(5, 10)); yieldSignal.setWithDelay(1, executor); yieldSignal.forceYieldForTesting(); // yield signal is ignored given the block has already been loaded assertTrue(work.process()); Block result = work.getResult(); yieldSignal.reset(); if (produceLazyBlock) { assertInstanceOf(result, LazyBlock.class); assertFalse(result.isLoaded()); assertFalse(block.isLoaded()); result = result.getLoadedBlock(); } assertBlockEquals( BIGINT, result, block.getRegion(5, 10)); assertInstanceOf(result, DictionaryBlock.class); }