private PrestoThriftService openClient(PrestoThriftSplit split) { if (split.getHosts().isEmpty()) { return client.get(thriftHeaders); } String hosts = split.getHosts().stream() .map(host -> host.toHostAddress().toString()) .collect(joining(",")); return client.get(Optional.of(hosts), thriftHeaders); }
private ListenableFuture<PrestoThriftSplitBatch> sendSplitRequest(@Nullable PrestoThriftId nextToken) { long start = System.nanoTime(); ListenableFuture<PrestoThriftSplitBatch> future = client.get(thriftHeaders).getIndexSplits( schemaTableName, lookupColumnNames, outputColumnNames, keys, outputConstraint, MAX_SPLIT_COUNT, new PrestoThriftNullableToken(nextToken)); future = catchingThriftException(future); future.addListener(() -> readTimeNanos.addAndGet(System.nanoTime() - start), directExecutor()); return future; }
@Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { return client.get(thriftHeaderProvider.getHeaders(session)).listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
@Override public List<String> listSchemaNames(ConnectorSession session) { try { return client.get(thriftHeaderProvider.getHeaders(session)).listSchemaNames(); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
private PrestoThriftNullableTableMetadata getTableMetadata(SchemaTableName schemaTableName) { // treat invalid names as not found PrestoThriftSchemaTableName name; try { name = new PrestoThriftSchemaTableName(schemaTableName); } catch (IllegalArgumentException e) { return new PrestoThriftNullableTableMetadata(null); } try { return client.get().getTableMetadata(name); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } } }
@Override public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { ThriftTableLayoutHandle layoutHandle = (ThriftTableLayoutHandle) layout; return new ThriftSplitSource( client.get(thriftHeaderProvider.getHeaders(session)), new PrestoThriftSchemaTableName(layoutHandle.getSchemaName(), layoutHandle.getTableName()), layoutHandle.getColumns().map(ThriftSplitManager::columnNames), tupleDomainToThriftTupleDomain(layoutHandle.getConstraint())); }
@Override protected T get(Injector injector, Annotation annotation) { return injector.getInstance(key).get(); } }
@Override protected T get(Injector injector, Annotation annotation) { return injector.getInstance(key).get(); } }
default T get() { return get(Optional.empty()); }
default T get(Optional<String> addressSelectionContext) { return get(addressSelectionContext, ImmutableMap.of()); }
T get(Optional<String> addressSelectionContext, Map<String, String> headers); }
default T get() { return get(Optional.empty()); }
default T get(Optional<String> addressSelectionContext) { return get(addressSelectionContext, ImmutableMap.of()); }
T get(Optional<String> addressSelectionContext, Map<String, String> headers); }
private PrestoThriftService openClient(PrestoThriftSplit split) { if (split.getHosts().isEmpty()) { return client.get(thriftHeaders); } String hosts = split.getHosts().stream() .map(host -> host.toHostAddress().toString()) .collect(joining(",")); return client.get(Optional.of(hosts), thriftHeaders); }
private ListenableFuture<PrestoThriftSplitBatch> sendSplitRequest(@Nullable PrestoThriftId nextToken) { long start = System.nanoTime(); ListenableFuture<PrestoThriftSplitBatch> future = client.get(thriftHeaders).getIndexSplits( schemaTableName, lookupColumnNames, outputColumnNames, keys, outputConstraint, MAX_SPLIT_COUNT, new PrestoThriftNullableToken(nextToken)); future = catchingThriftException(future); future.addListener(() -> readTimeNanos.addAndGet(System.nanoTime() - start), directExecutor()); return future; }
@Override public List<String> listSchemaNames(ConnectorSession session) { try { return client.get(thriftHeaderProvider.getHeaders(session)).listSchemaNames(); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
@Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { try { return client.get(thriftHeaderProvider.getHeaders(session)).listTables(new PrestoThriftNullableSchemaName(schemaNameOrNull)).stream() .map(PrestoThriftSchemaTableName::toSchemaTableName) .collect(toImmutableList()); } catch (PrestoThriftServiceException | TException e) { throw toPrestoException(e); } }
@Override public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { ThriftTableLayoutHandle layoutHandle = (ThriftTableLayoutHandle) layout; return new ThriftSplitSource( client.get(thriftHeaderProvider.getHeaders(session)), new PrestoThriftSchemaTableName(layoutHandle.getSchemaName(), layoutHandle.getTableName()), layoutHandle.getColumns().map(ThriftSplitManager::columnNames), tupleDomainToThriftTupleDomain(layoutHandle.getConstraint())); }