当前位置: 首页>>代码示例>>Java>>正文


Java PrestoException类代码示例

本文整理汇总了Java中com.facebook.presto.spi.PrestoException的典型用法代码示例。如果您正苦于以下问题:Java PrestoException类的具体用法?Java PrestoException怎么用?Java PrestoException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PrestoException类属于com.facebook.presto.spi包,在下文中一共展示了PrestoException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processJsonArray

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
public T processJsonArray(JsonParser jsonParser)
        throws IOException
{
    int currentIndex = 0;
    while (true) {
        JsonToken token = jsonParser.nextToken();
        if (token == null) {
            throw new JsonParseException("Unexpected end of array", jsonParser.getCurrentLocation());
        }
        if (token == END_ARRAY) {
            // Index out of bounds
            if (exceptionOnOutOfBounds) {
                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Index out of bounds");
            }
            return null;
        }
        if (currentIndex == index) {
            break;
        }
        currentIndex++;
        jsonParser.skipChildren(); // Skip nested structure if currently at the start of one
    }

    return delegate.extract(jsonParser);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:JsonExtract.java

示例2: advanceNextPosition

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Override
public boolean advanceNextPosition()
{
    try {
        if (closed || !recordReader.hasNext()) {
            close();
            return false;
        }

        row = (OrcStruct) recordReader.next(row);

        // reset loaded flags
        // partition keys are already loaded, but everything else is not
        System.arraycopy(isPartitionColumn, 0, loaded, 0, isPartitionColumn.length);

        return true;
    }
    catch (IOException | RuntimeException e) {
        closeWithSuppression(e);
        throw new PrestoException(HIVE_CURSOR_ERROR, e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:OrcHiveRecordCursor.java

示例3: getWindowFunctionImplementation

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
public WindowFunctionSupplier getWindowFunctionImplementation(Signature signature)
{
    checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature);
    checkArgument(signature.getTypeParameterRequirements().isEmpty(), "%s has unbound type parameters", signature);
    Iterable<SqlFunction> candidates = functions.get(QualifiedName.of(signature.getName()));
    // search for exact match
    for (SqlFunction operator : candidates) {
        Type returnType = typeManager.getType(signature.getReturnType());
        List<Type> argumentTypes = resolveTypes(signature.getArgumentTypes(), typeManager);
        Map<String, Type> boundTypeParameters = operator.getSignature().bindTypeParameters(returnType, argumentTypes, false, typeManager);
        if (boundTypeParameters != null) {
            try {
                return specializedWindowCache.getUnchecked(new SpecializedFunctionKey(operator, boundTypeParameters, signature.getArgumentTypes().size()));
            }
            catch (UncheckedExecutionException e) {
                throw Throwables.propagate(e.getCause());
            }
        }
    }
    throw new PrestoException(FUNCTION_IMPLEMENTATION_MISSING, format("%s not found", signature));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:FunctionRegistry.java

示例4: getPrivileges

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private Set<HivePrivilege> getPrivileges(String user, HiveObjectRef objectReference)
{
    ImmutableSet.Builder<HivePrivilege> privileges = ImmutableSet.builder();
    try (HiveMetastoreClient client = clientProvider.createMetastoreClient()) {
        PrincipalPrivilegeSet privilegeSet = client.getPrivilegeSet(objectReference, user, null);

        if (privilegeSet != null) {
            Map<String, List<PrivilegeGrantInfo>> userPrivileges = privilegeSet.getUserPrivileges();
            if (userPrivileges != null) {
                privileges.addAll(toGrants(userPrivileges.get(user)));
            }
            for (List<PrivilegeGrantInfo> rolePrivileges : privilegeSet.getRolePrivileges().values()) {
                privileges.addAll(toGrants(rolePrivileges));
            }
            // We do not add the group permissions as Hive does not seem to process these
        }
    }
    catch (TException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }

    return privileges.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:CachingHiveMetastore.java

示例5: toArray

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
public static Block toArray(Type arrayType, ConnectorSession connectorSession, Slice json)
{
    try {
        List<?> array = (List<?>) stackRepresentationToObject(connectorSession, json, arrayType);
        if (array == null) {
            return null;
        }
        Type elementType = ((ArrayType) arrayType).getElementType();
        BlockBuilder blockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), array.size());
        for (Object element : array) {
            appendToBlockBuilder(elementType, element, blockBuilder);
        }
        return blockBuilder.build();
    }
    catch (RuntimeException e) {
        throw new PrestoException(INVALID_CAST_ARGUMENT, "Value cannot be cast to " + arrayType, e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:JsonToArrayCast.java

示例6: loadNodeId

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private int loadNodeId(String nodeIdentifier)
{
    Integer id = dao.getNodeId(nodeIdentifier);
    if (id != null) {
        return id;
    }

    // creating a node is idempotent
    runIgnoringConstraintViolation(() -> dao.insertNode(nodeIdentifier));

    id = dao.getNodeId(nodeIdentifier);
    if (id == null) {
        throw new PrestoException(INTERNAL_ERROR, "node does not exist after insert");
    }
    return id;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:DatabaseShardManager.java

示例7: load

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Override
public final void load(LazyBlock lazyBlock)
{
    if (loaded) {
        return;
    }

    checkState(batchId == expectedBatchId);

    try {
        Block block = recordReader.readBlock(type, columnIndex);
        lazyBlock.setBlock(block);
    }
    catch (IOException e) {
        if (e instanceof OrcCorruptionException) {
            throw new PrestoException(HIVE_BAD_DATA, e);
        }
        throw new PrestoException(HIVE_CURSOR_ERROR, e);
    }

    loaded = true;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:OrcPageSource.java

示例8: subscript

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@UsedByGeneratedCode
public static Object subscript(MethodHandle keyEqualsMethod, Type keyType, Type valueType, Block map, Object key)
{
    for (int position = 0; position < map.getPositionCount(); position += 2) {
        try {
            if ((boolean) keyEqualsMethod.invokeExact(keyType.getObject(map, position), key)) {
                return readNativeValue(valueType, map, position + 1); // position + 1: value position
            }
        }
        catch (Throwable t) {
            Throwables.propagateIfInstanceOf(t, Error.class);
            Throwables.propagateIfInstanceOf(t, PrestoException.class);
            throw new PrestoException(INTERNAL_ERROR, t);
        }
    }
    return null;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:MapSubscriptOperator.java

示例9: dropTable

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Override
public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    HiveTableHandle handle = checkType(tableHandle, HiveTableHandle.class, "tableHandle");
    SchemaTableName tableName = schemaTableName(tableHandle);

    if (!allowDropTable) {
        throw new PrestoException(PERMISSION_DENIED, "DROP TABLE is disabled in this Hive catalog");
    }

    Optional<Table> target = metastore.getTable(handle.getSchemaName(), handle.getTableName());
    if (!target.isPresent()) {
        throw new TableNotFoundException(tableName);
    }
    Table table = target.get();

    if (!session.getUser().equals(table.getOwner())) {
        throw new PrestoException(PERMISSION_DENIED, format("Unable to drop table '%s': owner of the table is different from session user", table));
    }
    metastore.dropTable(handle.getSchemaName(), handle.getTableName());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:HiveMetadata.java

示例10: stop

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@PreDestroy
public void stop()
{
    boolean queryCancelled = false;
    for (QueryExecution queryExecution : queries.values()) {
        QueryInfo queryInfo = queryExecution.getQueryInfo();
        if (queryInfo.getState().isDone()) {
            continue;
        }

        log.info("Server shutting down. Query %s has been cancelled", queryExecution.getQueryInfo().getQueryId());
        queryExecution.fail(new PrestoException(SERVER_SHUTTING_DOWN, "Server is shutting down. Query " + queryInfo.getQueryId() + " has been cancelled"));
        queryCancelled = true;
    }
    if (queryCancelled) {
        try {
            TimeUnit.SECONDS.sleep(5);
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
    queryManagementExecutor.shutdownNow();
    queryExecutor.shutdownNow();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:SqlQueryManager.java

示例11: writeShard

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private void writeShard(UUID shardUuid)
{
    if (backupStore.isPresent() && !backupExists(shardUuid)) {
        throw new PrestoException(RAPTOR_ERROR, "Backup does not exist after write");
    }

    File stagingFile = storageService.getStagingFile(shardUuid);
    File storageFile = storageService.getStorageFile(shardUuid);

    storageService.createParents(storageFile);

    try {
        Files.move(stagingFile.toPath(), storageFile.toPath(), ATOMIC_MOVE);
    }
    catch (IOException e) {
        throw new PrestoException(RAPTOR_ERROR, "Failed to move shard file", e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:OrcStorageManager.java

示例12: arrayPosition

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@UsedByGeneratedCode
public static long arrayPosition(Type type, MethodHandle equalMethodHandle, Block array, Slice element)
{
    int size = array.getPositionCount();
    for (int i = 0; i < size; i++) {
        if (!array.isNull(i)) {
            Slice arrayValue = type.getSlice(array, i);
            try {
                if ((boolean) equalMethodHandle.invokeExact(arrayValue, element)) {
                    return i + 1; // result is 1-based (instead of 0)
                }
            }
            catch (Throwable t) {
                Throwables.propagateIfInstanceOf(t, Error.class);
                Throwables.propagateIfInstanceOf(t, PrestoException.class);
                throw new PrestoException(INTERNAL_ERROR, t);
            }
        }
    }
    return 0;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:ArrayPositionFunction.java

示例13: getColumnInfo

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private List<ColumnInfo> getColumnInfo(OrcReader reader)
{
    // TODO: These should be stored as proper metadata.
    // XXX: Relying on ORC types will not work when more Presto types are supported.

    List<String> names = reader.getColumnNames();
    Type rowType = getType(reader.getFooter().getTypes(), 0);
    if (names.size() != rowType.getTypeParameters().size()) {
        throw new PrestoException(RAPTOR_ERROR, "Column names and types do not match");
    }

    ImmutableList.Builder<ColumnInfo> list = ImmutableList.builder();
    for (int i = 0; i < names.size(); i++) {
        list.add(new ColumnInfo(Long.parseLong(names.get(i)), rowType.getTypeParameters().get(i)));
    }
    return list.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:OrcStorageManager.java

示例14: appendRow

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
public void appendRow(Row row)
{
    List<Object> columns = row.getColumns();
    checkArgument(columns.size() == columnTypes.size());
    for (int channel = 0; channel < columns.size(); channel++) {
        tableInspector.setStructFieldData(orcRow, structFields.get(channel), columns.get(channel));
    }
    try {
        recordWriter.write(serializer.serialize(orcRow, tableInspector));
    }
    catch (IOException e) {
        throw new PrestoException(RAPTOR_ERROR, "Failed to write record", e);
    }
    rowCount++;
    uncompressedSize += row.getSizeInBytes();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:OrcFileWriter.java

示例15: createTableCreationPlan

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private RelationPlan createTableCreationPlan(Analysis analysis)
{
    QualifiedObjectName destination = analysis.getCreateTableDestination().get();

    RelationPlan plan = createRelationPlan(analysis);

    TableMetadata tableMetadata = createTableMetadata(destination, getOutputTableColumns(plan), analysis.getCreateTableProperties(), plan.getSampleWeight().isPresent());
    if (plan.getSampleWeight().isPresent() && !metadata.canCreateSampledTables(session, destination.getCatalogName())) {
        throw new PrestoException(NOT_SUPPORTED, "Cannot write sampled data to a store that doesn't support sampling");
    }

    return createTableWriterPlan(
            analysis,
            plan,
            new CreateName(destination.getCatalogName(), tableMetadata), tableMetadata.getVisibleColumnNames());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:LogicalPlanner.java


注:本文中的com.facebook.presto.spi.PrestoException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。