• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PrestoException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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) {
        throw new PrestoException(RAPTOR_ERROR, e);
    }

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


示例17: testAssignRandomNodeWhenBackupAvailable

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Test
public void testAssignRandomNodeWhenBackupAvailable()
        throws InterruptedException, URISyntaxException
{
    InMemoryNodeManager nodeManager = new InMemoryNodeManager();
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    NodeSupplier nodeSupplier = new RaptorNodeSupplier(nodeManager, connectorId);
    PrestoNode node = new PrestoNode(UUID.randomUUID().toString(), new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN);
    nodeManager.addNode(connectorId.toString(), node);
    RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, true);

    deleteShardNodes();

    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource partitionSplit = getSplits(raptorSplitManagerWithBackup, layout);
    List<ConnectorSplit> batch = getFutureValue(partitionSplit.getNextBatch(1), PrestoException.class);
    assertEquals(getOnlyElement(getOnlyElement(batch).getAddresses()), node.getHostAndPort());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:TestRaptorSplitManager.java


示例18: getFormattedSql

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
private String getFormattedSql(CreateView statement)
{
    Query query = statement.getQuery();
    String sql = formatSql(query);

    // verify round-trip
    Statement parsed;
    try {
        parsed = sqlParser.createStatement(sql);
    }
    catch (ParsingException e) {
        throw new PrestoException(INTERNAL_ERROR, "Formatted query does not parse: " + query);
    }
    if (!query.equals(parsed)) {
        throw new PrestoException(INTERNAL_ERROR, "Query does not round-trip: " + query);
    }

    return sql;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:CreateViewTask.java


示例19: testRollback

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Test
public void testRollback()
{
    long tableId = createTable("test");
    List<ColumnInfo> columns = ImmutableList.of(new ColumnInfo(1, BIGINT));
    List<ShardInfo> shards = ImmutableList.of(shardInfo(UUID.randomUUID(), "node1"));

    shardManager.createTable(tableId, columns);

    long transactionId = shardManager.beginTransaction();
    shardManager.rollbackTransaction(transactionId);

    try {
        shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty());
        fail("expected exception");
    }
    catch (PrestoException e) {
        assertEquals(e.getErrorCode(), TRANSACTION_CONFLICT.toErrorCode());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:TestDatabaseShardManager.java


示例20: testTransactionAbort

import com.facebook.presto.spi.PrestoException; //导入依赖的package包/类
@Test
public void testTransactionAbort()
        throws Exception
{
    // start table creation
    long transactionId = 1;
    ConnectorOutputTableHandle outputHandle = metadata.beginCreateTable(SESSION, getOrdersTable());

    // transaction is in progress
    assertTrue(transactionExists(transactionId));
    assertNull(transactionSuccessful(transactionId));

    // force transaction to abort
    shardManager.rollbackTransaction(transactionId);
    assertTrue(transactionExists(transactionId));
    assertFalse(transactionSuccessful(transactionId));

    // commit table creation
    try {
        metadata.finishCreateTable(SESSION, outputHandle, ImmutableList.of());
        fail("expected exception");
    }
    catch (PrestoException e) {
        assertEquals(e.getErrorCode(), TRANSACTION_CONFLICT.toErrorCode());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestRaptorMetadata.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModernRoboticsI2cGyro类代码示例发布时间:2022-05-23
下一篇:
Java HttpCallback类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap