use of io.trino.annotation.UsedByGeneratedCode in project trino by trinodb.
the class KillQueryProcedure method killQuery.
@UsedByGeneratedCode
public void killQuery(String queryId, String message, ConnectorSession session) {
QueryId query = parseQueryId(queryId);
try {
checkState(dispatchManager.isPresent(), "No dispatch manager is set. kill_query procedure should be executed on coordinator.");
DispatchQuery dispatchQuery = dispatchManager.get().getQuery(query);
checkCanKillQueryOwnedBy(((FullConnectorSession) session).getSession().getIdentity(), dispatchQuery.getSession().getIdentity(), accessControl);
// check before killing to provide the proper error message (this is racy)
if (dispatchQuery.isDone()) {
throw new TrinoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
}
dispatchQuery.fail(createKillQueryException(message));
// verify if the query was killed (if not, we lost the race)
checkState(dispatchQuery.isDone(), "Failure to fail the query: %s", query);
if (!ADMINISTRATIVELY_KILLED.toErrorCode().equals(dispatchQuery.getErrorCode().orElse(null))) {
throw new TrinoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
}
} catch (NoSuchElementException e) {
throw new TrinoException(NOT_FOUND, "Target query not found: " + queryId);
}
}
use of io.trino.annotation.UsedByGeneratedCode in project trino by trinodb.
the class ArrayConcatFunction method concat.
@UsedByGeneratedCode
public static Block concat(Type elementType, Object state, Block[] blocks) {
int resultPositionCount = 0;
// fast path when there is at most one non empty block
Block nonEmptyBlock = null;
for (int i = 0; i < blocks.length; i++) {
resultPositionCount += blocks[i].getPositionCount();
if (blocks[i].getPositionCount() > 0) {
nonEmptyBlock = blocks[i];
}
}
if (nonEmptyBlock == null) {
return blocks[0];
}
if (resultPositionCount == nonEmptyBlock.getPositionCount()) {
return nonEmptyBlock;
}
PageBuilder pageBuilder = (PageBuilder) state;
if (pageBuilder.isFull()) {
pageBuilder.reset();
}
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
Block block = blocks[blockIndex];
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
}
pageBuilder.declarePositions(resultPositionCount);
return blockBuilder.getRegion(blockBuilder.getPositionCount() - resultPositionCount, resultPositionCount);
}
use of io.trino.annotation.UsedByGeneratedCode in project trino by trinodb.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, Object value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeObject(blockBuilder, value);
return blockBuilder.build();
}
use of io.trino.annotation.UsedByGeneratedCode in project trino by trinodb.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, boolean value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeBoolean(blockBuilder, value);
return blockBuilder.build();
}
use of io.trino.annotation.UsedByGeneratedCode in project trino by trinodb.
the class ArrayConcatUtils method prependElement.
// Usage of prependElement: ElementToArrayConcatFunction
@UsedByGeneratedCode
public static Block prependElement(Type elementType, Slice value, Block block) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
elementType.writeSlice(blockBuilder, value);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
return blockBuilder.build();
}
Aggregations