本文整理了Java中com.facebook.presto.spi.block.Block.getLoadedBlock()
方法的一些代码示例,展示了Block.getLoadedBlock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getLoadedBlock()
方法的具体详情如下:
包路径:com.facebook.presto.spi.block.Block
类名称:Block
方法名:getLoadedBlock
[英]Returns a block that assures all data is in memory. May return the same block if all block data is already in memory.
This allows streaming data sources to skip sections that are not accessed in a query.
[中]返回一个确保所有数据都在内存中的块。如果所有块数据都已在内存中,则可能返回相同的块。
这允许流数据源跳过查询中未访问的部分。
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
return block.getLoadedBlock();
}
}
代码示例来源:origin: prestodb/presto
@Override
public Optional<Block> replacementBlockForWrite(Block block)
{
return Optional.of(block.getLoadedBlock());
}
}
代码示例来源:origin: prestodb/presto
@Override
public void load(LazyBlock lazyBlock)
{
if (block == null) {
return;
}
lazyBlock.setBlock(coercer.apply(block.getLoadedBlock()));
// clear reference to loader to free resources, since load was successful
block = null;
}
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
Block loadedValueBlock = value.getLoadedBlock();
if (loadedValueBlock == value) {
return this;
}
return new RunLengthEncodedBlock(loadedValueBlock, positionCount);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
if (keyBlock != keyBlock.getLoadedBlock()) {
// keyBlock has to be loaded since MapBlock constructs hash table eagerly.
throw new IllegalStateException();
}
Block loadedValueBlock = valueBlock.getLoadedBlock();
if (loadedValueBlock == valueBlock) {
return this;
}
return new SingleMapBlock(
offset,
positionCount,
keyBlock,
loadedValueBlock,
hashTable,
keyType,
keyNativeHashCode,
keyBlockNativeEquals);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
if (keyBlock != keyBlock.getLoadedBlock()) {
// keyBlock has to be loaded since MapBlock constructs hash table eagerly.
throw new IllegalStateException();
}
Block loadedValueBlock = valueBlock.getLoadedBlock();
if (loadedValueBlock == valueBlock) {
return this;
}
return createMapBlockInternal(
startOffset,
positionCount,
Optional.ofNullable(mapIsNull),
offsets,
keyBlock,
loadedValueBlock,
hashTables,
keyType,
keyBlockNativeEquals,
keyNativeHashCode);
}
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
Block loadedValuesBlock = values.getLoadedBlock();
if (loadedValuesBlock == values) {
return this;
}
return createArrayBlockInternal(
arrayOffset,
positionCount,
valueIsNull,
offsets,
loadedValuesBlock);
}
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
boolean allLoaded = true;
Block[] loadedFieldBlocks = new Block[fieldBlocks.length];
for (int i = 0; i < fieldBlocks.length; i++) {
loadedFieldBlocks[i] = fieldBlocks[i].getLoadedBlock();
if (loadedFieldBlocks[i] != fieldBlocks[i]) {
allLoaded = false;
}
}
if (allLoaded) {
return this;
}
return new SingleRowBlock(rowIndex, loadedFieldBlocks);
}
}
代码示例来源:origin: prestodb/presto
/**
* Returns a page that assures all data is in memory.
* May return the same page if all page data is already in memory.
* <p>
* This allows streaming data sources to skip sections that are not
* accessed in a query.
*/
public Page getLoadedPage()
{
boolean allLoaded = true;
Block[] loadedBlocks = new Block[blocks.length];
for (int i = 0; i < blocks.length; i++) {
loadedBlocks[i] = blocks[i].getLoadedBlock();
if (loadedBlocks[i] != blocks[i]) {
allLoaded = false;
}
}
if (allLoaded) {
return this;
}
return new Page(loadedBlocks);
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
boolean allLoaded = true;
Block[] loadedFieldBlocks = new Block[fieldBlocks.length];
for (int i = 0; i < fieldBlocks.length; i++) {
loadedFieldBlocks[i] = fieldBlocks[i].getLoadedBlock();
if (loadedFieldBlocks[i] != fieldBlocks[i]) {
allLoaded = false;
}
}
if (allLoaded) {
return this;
}
return createRowBlockInternal(
startOffset,
positionCount,
rowIsNull,
fieldBlockOffsets,
loadedFieldBlocks);
}
}
代码示例来源:origin: prestodb/presto
public DictionaryAwarePageProjectionWork(@Nullable ConnectorSession session, DriverYieldSignal yieldSignal, Page page, SelectedPositions selectedPositions)
{
this.session = session;
this.yieldSignal = requireNonNull(yieldSignal, "yieldSignal is null");
Block block = requireNonNull(page, "page is null").getBlock(0).getLoadedBlock();
this.block = block;
this.selectedPositions = requireNonNull(selectedPositions, "selectedPositions is null");
Optional<Block> dictionary = Optional.empty();
if (block instanceof RunLengthEncodedBlock) {
dictionary = Optional.of(((RunLengthEncodedBlock) block).getValue());
}
else if (block instanceof DictionaryBlock) {
dictionary = Optional.of(((DictionaryBlock) block).getDictionary());
}
// Try use dictionary processing first; if it fails, fall back to the generic case
dictionaryProcessingProjectionWork = createDictionaryBlockProjection(dictionary);
fallbackProcessingProjectionWork = null;
}
代码示例来源:origin: prestodb/presto
@Override
protected Page computeNext()
{
try {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedIOException();
}
int batchSize = reader.nextBatch();
if (batchSize <= 0) {
return endOfData();
}
Block[] blocks = new Block[types.size()];
for (int i = 0; i < types.size(); i++) {
blocks[i] = reader.readBlock(types.get(i), i).getLoadedBlock();
}
return new Page(batchSize, blocks);
}
catch (IOException e) {
throw new PrestoException(HIVE_WRITER_DATA_ERROR, "Failed to read temporary data");
}
}
}
代码示例来源:origin: prestodb/presto
@Override
public Block getLoadedBlock()
{
Block loadedDictionary = dictionary.getLoadedBlock();
if (loadedDictionary == dictionary) {
return this;
}
return new DictionaryBlock(idsOffset, getPositionCount(), loadedDictionary, ids, false, randomDictionaryId());
}
代码示例来源:origin: prestodb/presto
@Override
public Work<Block> project(ConnectorSession session, DriverYieldSignal yieldSignal, Page page, SelectedPositions selectedPositions)
{
return new CompletedWork<>(page.getBlock(0).getLoadedBlock());
}
}
代码示例来源:origin: prestodb/presto
@Override
public SelectedPositions filter(ConnectorSession session, Page page)
{
Block block = page.getBlock(0).getLoadedBlock();
if (block instanceof RunLengthEncodedBlock) {
Block value = ((RunLengthEncodedBlock) block).getValue();
Optional<boolean[]> selectedPosition = processDictionary(session, value);
// single value block is always considered effective, but the processing could have thrown
// in that case we fallback and process again so the correct error message sent
if (selectedPosition.isPresent()) {
return SelectedPositions.positionsRange(0, selectedPosition.get()[0] ? page.getPositionCount() : 0);
}
}
if (block instanceof DictionaryBlock) {
DictionaryBlock dictionaryBlock = (DictionaryBlock) block;
// Attempt to process the dictionary. If dictionary is processing has not been considered effective, an empty response will be returned
Optional<boolean[]> selectedDictionaryPositions = processDictionary(session, dictionaryBlock.getDictionary());
// record the usage count regardless of dictionary processing choice, so we have stats for next time
lastDictionaryUsageCount += page.getPositionCount();
// if dictionary was processed, produce a dictionary block; otherwise do normal processing
if (selectedDictionaryPositions.isPresent()) {
return selectDictionaryPositions(dictionaryBlock, selectedDictionaryPositions.get());
}
}
return filter.filter(session, new Page(block));
}
代码示例来源:origin: prestodb/presto
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);
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public Optional<Block> replacementBlockForWrite(Block block)
{
return Optional.of(block.getLoadedBlock());
}
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public Block getLoadedBlock()
{
Block loadedValueBlock = value.getLoadedBlock();
if (loadedValueBlock == value) {
return this;
}
return new RunLengthEncodedBlock(loadedValueBlock, positionCount);
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public Block getLoadedBlock()
{
boolean allLoaded = true;
Block[] loadedFieldBlocks = new Block[fieldBlocks.length];
for (int i = 0; i < fieldBlocks.length; i++) {
loadedFieldBlocks[i] = fieldBlocks[i].getLoadedBlock();
if (loadedFieldBlocks[i] != fieldBlocks[i]) {
allLoaded = false;
}
}
if (allLoaded) {
return this;
}
return new SingleRowBlock(rowIndex, loadedFieldBlocks);
}
}
代码示例来源:origin: com.facebook.presto/presto-spi
@Override
public Block getLoadedBlock()
{
Block loadedDictionary = dictionary.getLoadedBlock();
if (loadedDictionary == dictionary) {
return this;
}
return new DictionaryBlock(idsOffset, getPositionCount(), loadedDictionary, ids, false, randomDictionaryId());
}
内容来源于网络,如有侵权,请联系作者删除!