com.facebook.presto.spi.ColumnHandle Java Examples
The following examples show how to use
com.facebook.presto.spi.ColumnHandle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParaflowTableLayoutHandle.java From paraflow with Apache License 2.0 | 6 votes |
@JsonCreator public ParaflowTableLayoutHandle( @JsonProperty("table") ParaflowTableHandle table, @JsonProperty("fiberColumn") ParaflowColumnHandle fiberColumn, @JsonProperty("timestampColumn") ParaflowColumnHandle timestampColumn, @JsonProperty("fiberPartitioner") String fiberPartitioner, @JsonProperty("storageFormat") StorageFormat storageFormat, @JsonProperty("predicates") Optional<TupleDomain<ColumnHandle>> predicates) { this.table = requireNonNull(table, "table is null"); this.fiberColumn = requireNonNull(fiberColumn, "fiberColumn is null"); this.timestampColumn = requireNonNull(timestampColumn, "timestampColumn is null"); this.fiberPartitioner = requireNonNull(fiberPartitioner, "fiberPartitioner is null"); this.storageFormat = requireNonNull(storageFormat, "storageFormat is null"); this.predicates = requireNonNull(predicates, "predicates is null"); }
Example #2
Source File: ParaflowPageSourceProvider.java From paraflow with Apache License 2.0 | 6 votes |
@Override public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns) { List<ParaflowColumnHandle> hdfsColumns = columns.stream() .map(col -> (ParaflowColumnHandle) col) .collect(Collectors.toList()); ParaflowSplit paraflowSplit = checkType(split, ParaflowSplit.class, "hdfs split"); Path path = new Path(paraflowSplit.getPath()); Optional<ConnectorPageSource> pageSource = createParaflowPageSource( path, paraflowSplit.getStart(), paraflowSplit.getLen(), hdfsColumns); if (pageSource.isPresent()) { return pageSource.get(); } throw new RuntimeException("Could not find a file reader for split " + paraflowSplit); }
Example #3
Source File: HbaseMetadata.java From presto-connectors with Apache License 2.0 | 6 votes |
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) { HbaseTableHandle handle = (HbaseTableHandle) tableHandle; checkArgument(handle.getConnectorId().equals(connectorId), "tableHandle is not for this connector"); HbaseTable table = client.getTable(handle.toSchemaTableName()); if (table == null) { throw new TableNotFoundException(handle.toSchemaTableName()); } ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); for (HbaseColumnHandle column : table.getColumns()) { columnHandles.put(column.getName(), column); } return columnHandles.build(); }
Example #4
Source File: ElasticsearchMetadata.java From presto-connectors with Apache License 2.0 | 6 votes |
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) { ElasticsearchTableHandle handle = (ElasticsearchTableHandle) tableHandle; checkArgument(handle.getConnectorId().equals(connectorId), "tableHandle is not for this connector"); ElasticsearchTable table = client.getTable(handle.getSchemaTableName()); if (table == null) { throw new TableNotFoundException(handle.getSchemaTableName()); } return table.getColumns().stream().collect(Collectors.toMap(x -> x.getName(), x -> x)); // ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); // for (ElasticsearchColumnHandle column : table.getColumns()) { // columnHandles.put(column.getName(), column); // } // return columnHandles.build(); }
Example #5
Source File: EthereumRecordSetProvider.java From presto-ethereum with Apache License 2.0 | 6 votes |
@Override public RecordSet getRecordSet( ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns ) { EthereumSplit ethereumSplit = convertSplit(split); ImmutableList.Builder<EthereumColumnHandle> handleBuilder = ImmutableList.builder(); for (ColumnHandle handle : columns) { EthereumColumnHandle columnHandle = convertColumnHandle(handle); handleBuilder.add(columnHandle); } return new EthereumRecordSet(web3j, handleBuilder.build(), ethereumSplit); }
Example #6
Source File: KuduMetadata.java From presto-kudu with Apache License 2.0 | 6 votes |
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle connectorTableHandle) { KuduTableHandle tableHandle = fromConnectorTableHandle(session, connectorTableHandle); Schema schema = clientSession.getTableSchema(tableHandle); ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); for (int i = 0; i < schema.getColumnCount(); i++) { ColumnSchema col = schema.getColumnByIndex(i); String name = col.getName(); Type type = TypeHelper.fromKuduColumn(col); KuduColumnHandle columnHandle = new KuduColumnHandle(name, i, type); columnHandles.put(name, columnHandle); } return columnHandles.build(); }
Example #7
Source File: HbaseSplitManager.java From presto-connectors with Apache License 2.0 | 6 votes |
/** * Gets a list of {@link HbaseColumnConstraint} based on the given constraint ID, excluding the row ID column * * @param rowIdName Presto column name mapping to the Hbase row ID * @param constraint Set of query constraints * @return List of all column constraints */ private static List<HbaseColumnConstraint> getColumnConstraints(String rowIdName, TupleDomain<ColumnHandle> constraint) { ImmutableList.Builder<HbaseColumnConstraint> constraintBuilder = ImmutableList.builder(); for (TupleDomain.ColumnDomain<ColumnHandle> columnDomain : constraint.getColumnDomains().get()) { HbaseColumnHandle columnHandle = (HbaseColumnHandle) columnDomain.getColumn(); if (!columnHandle.getName().equals(rowIdName)) { // Family and qualifier will exist for non-row ID columns constraintBuilder.add(new HbaseColumnConstraint( columnHandle.getName(), columnHandle.getFamily().get(), columnHandle.getQualifier().get(), Optional.of(columnDomain.getDomain()), columnHandle.isIndexed())); } } return constraintBuilder.build(); }
Example #8
Source File: KuduMetadata.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { KuduTableHandle handle = fromConnectorTableHandle(session, tableHandle); ConnectorTableLayout layout = new ConnectorTableLayout( new KuduTableLayoutHandle(handle, constraint.getSummary(), desiredColumns)); return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary())); }
Example #9
Source File: ParaflowMetadata.java From paraflow with Apache License 2.0 | 5 votes |
@Override public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { ParaflowTableHandle paraflowTable = checkType(table, ParaflowTableHandle.class, "table"); SchemaTableName tableName = paraflowTable.getSchemaTableName(); ParaflowTableLayoutHandle tableLayout = paraflowMetaDataReader.getTableLayout(connectorId, tableName.getSchemaName(), tableName.getTableName()).orElse(null); if (tableLayout == null) { return ImmutableList.of(); } tableLayout.setPredicates(constraint.getSummary() != null ? Optional.of(constraint.getSummary()) : Optional.empty()); ConnectorTableLayout layout = getTableLayout(session, tableLayout); return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary())); }
Example #10
Source File: KubeRecordSetProvider.java From kubesql with Apache License 2.0 | 5 votes |
@Override public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) { requireNonNull(split, "split is null"); KubeSplit kubeSplit = (KubeSplit) split; ImmutableList.Builder<KubeColumnHandle> handles = ImmutableList.builder(); for (ColumnHandle handle : columns) { handles.add((KubeColumnHandle) handle); } return new KubeRecordSet(kubeTables, kubeSplit, handles.build()); }
Example #11
Source File: EthereumMetadata.java From presto-ethereum with Apache License 2.0 | 5 votes |
@Override public ColumnMetadata getColumnMetadata( ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle ) { convertTableHandle(tableHandle); return convertColumnHandle(columnHandle).getColumnMetadata(); }
Example #12
Source File: KuduMetadata.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) { fromConnectorTableHandle(session, tableHandle); KuduColumnHandle kuduColumnHandle = checkType(columnHandle, KuduColumnHandle.class, "columnHandle"); if (kuduColumnHandle.isVirtualRowId()) { return new ColumnMetadata(KuduColumnHandle.ROW_ID, VarbinaryType.VARBINARY, null, true); } else { return kuduColumnHandle.getColumnMetadata(); } }
Example #13
Source File: ParaflowMetadata.java From paraflow with Apache License 2.0 | 5 votes |
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) { ParaflowTableHandle table = checkType(tableHandle, ParaflowTableHandle.class, "table"); List<ParaflowColumnHandle> cols = paraflowMetaDataReader.getTableColumnHandle(connectorId, table.getSchemaName(), table.getTableName()) .orElse(new ArrayList<>()); Map<String, ColumnHandle> columnMap = new HashMap<>(); for (ParaflowColumnHandle col : cols) { columnMap.putIfAbsent(col.getName(), col); } return columnMap; }
Example #14
Source File: KuduMetadata.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public void renameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target) { KuduTableHandle kuduTableHandle = fromConnectorTableHandle(session, tableHandle); KuduColumnHandle kuduColumnHandle = (KuduColumnHandle) source; clientSession.renameColumn(kuduTableHandle.getSchemaTableName(), kuduColumnHandle.getName(), target); }
Example #15
Source File: KuduPageSourceProvider.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns) { KuduRecordSet recordSet = (KuduRecordSet) recordSetProvider.getRecordSet(transactionHandle, session, split, columns); if (columns.contains(KuduColumnHandle.ROW_ID_HANDLE)) { return new KuduUpdatablePageSource(recordSet); } else { return new RecordPageSource(recordSet); } }
Example #16
Source File: KuduTableLayoutHandle.java From presto-kudu with Apache License 2.0 | 5 votes |
@JsonCreator public KuduTableLayoutHandle(@JsonProperty("tableHandle") KuduTableHandle tableHandle, @JsonProperty("constraintSummary") TupleDomain<ColumnHandle> constraintSummary, @JsonProperty("desiredColumns") Optional<Set<ColumnHandle>> desiredColumns) { this.tableHandle = requireNonNull(tableHandle, "table is null"); this.constraintSummary = constraintSummary; this.desiredColumns = desiredColumns; }
Example #17
Source File: KuduRecordSetProvider.java From presto-kudu with Apache License 2.0 | 5 votes |
@Override public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) { requireNonNull(split, "split is null"); requireNonNull(columns, "columns is null"); KuduSplit kuduSplit = checkType(split, KuduSplit.class, "split is not class KuduSplit"); return new KuduRecordSet(clientSession, kuduSplit, columns); }
Example #18
Source File: KinesisRecordSetProvider.java From presto-kinesis with Apache License 2.0 | 5 votes |
@Override public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) { KinesisSplit kinesisSplit = handleResolver.convertSplit(split); ImmutableList.Builder<KinesisColumnHandle> handleBuilder = ImmutableList.builder(); ImmutableMap.Builder<KinesisColumnHandle, KinesisFieldDecoder<?>> messageFieldDecoderBuilder = ImmutableMap.builder(); KinesisRowDecoder messageDecoder = registry.getRowDecoder(kinesisSplit.getMessageDataFormat()); for (ColumnHandle handle : columns) { KinesisColumnHandle columnHandle = handleResolver.convertColumnHandle(handle); handleBuilder.add(columnHandle); if (!columnHandle.isInternal()) { KinesisFieldDecoder<?> fieldDecoder = registry.getFieldDecoder(kinesisSplit.getMessageDataFormat(), columnHandle.getType().getJavaType(), columnHandle.getDataFormat()); messageFieldDecoderBuilder.put(columnHandle, fieldDecoder); } } ImmutableList<KinesisColumnHandle> handles = handleBuilder.build(); ImmutableMap<KinesisColumnHandle, KinesisFieldDecoder<?>> messageFieldDecoders = messageFieldDecoderBuilder.build(); return new KinesisRecordSet(kinesisSplit, session, clientManager, handles, messageDecoder, messageFieldDecoders, kinesisConnectorConfig); }
Example #19
Source File: KinesisHandleResolver.java From presto-kinesis with Apache License 2.0 | 5 votes |
KinesisColumnHandle convertColumnHandle(ColumnHandle columnHandle) { requireNonNull(columnHandle, "columnHandle is null"); checkArgument(columnHandle instanceof KinesisColumnHandle, "columnHandle is not an instance of KinesisColumnHandle"); KinesisColumnHandle kinesisColumnHandle = (KinesisColumnHandle) columnHandle; checkArgument(kinesisColumnHandle.getConnectorId().equals(connectorId), "columnHandle is not for this connector"); return kinesisColumnHandle; }
Example #20
Source File: KinesisMetadata.java From presto-kinesis with Apache License 2.0 | 5 votes |
@Override public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession connectorSession, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> optional) { KinesisTableHandle tblHandle = handleResolver.convertTableHandle(table); ConnectorTableLayout layout = new ConnectorTableLayout(new KinesisTableLayoutHandle(connectorId, tblHandle)); return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary())); }
Example #21
Source File: KinesisMetadata.java From presto-kinesis with Apache License 2.0 | 5 votes |
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession connectorSession, ConnectorTableHandle tableHandle) { KinesisTableHandle kinesisTableHandle = handleResolver.convertTableHandle(tableHandle); KinesisStreamDescription kinesisStreamDescription = getDefinedTables().get(kinesisTableHandle.toSchemaTableName()); if (kinesisStreamDescription == null) { throw new TableNotFoundException(kinesisTableHandle.toSchemaTableName()); } ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); int index = 0; // Note: partition key and related fields are handled by internalFieldDescriptions below KinesisStreamFieldGroup message = kinesisStreamDescription.getMessage(); if (message != null) { List<KinesisStreamFieldDescription> fields = message.getFields(); if (fields != null) { for (KinesisStreamFieldDescription kinesisStreamFieldDescription : fields) { columnHandles.put(kinesisStreamFieldDescription.getName(), kinesisStreamFieldDescription.getColumnHandle(connectorId, index++)); } } } for (KinesisInternalFieldDescription kinesisInternalFieldDescription : internalFieldDescriptions) { columnHandles.put(kinesisInternalFieldDescription.getName(), kinesisInternalFieldDescription.getColumnHandle(connectorId, index++, kinesisConnectorConfig.isHideInternalColumns())); } return columnHandles.build(); }
Example #22
Source File: KinesisMetadata.java From presto-kinesis with Apache License 2.0 | 5 votes |
@Override public ColumnMetadata getColumnMetadata(ConnectorSession connectorSession, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) { handleResolver.convertTableHandle(tableHandle); KinesisColumnHandle kinesisColumnHandle = handleResolver.convertColumnHandle(columnHandle); return kinesisColumnHandle.getColumnMetadata(); }
Example #23
Source File: ElasticsearchPageSourceProvider.java From presto-connectors with Apache License 2.0 | 5 votes |
@Override public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns) { ElasticsearchSplit elasticsearchSplit = (ElasticsearchSplit) split; ImmutableList.Builder<ElasticsearchColumnHandle> handles = ImmutableList.builder(); for (ColumnHandle handle : requireNonNull(columns, "columns is null")) { handles.add((ElasticsearchColumnHandle) handle); } return new ElasticsearchPageSource(elasticsearchClient, elasticsearchSplit, handles.build()); }
Example #24
Source File: KubeTableLayoutHandle.java From kubesql with Apache License 2.0 | 5 votes |
@JsonCreator public KubeTableLayoutHandle( @JsonProperty("table") KubeTableHandle table, @JsonProperty("constraint") TupleDomain<ColumnHandle> constraint) { this.table = requireNonNull(table, "table is null"); this.constraint = requireNonNull(constraint, "constraint is null"); }
Example #25
Source File: ElasticsearchMetadata.java From presto-connectors with Apache License 2.0 | 5 votes |
@Override public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { ElasticsearchTableHandle tableHandle = (ElasticsearchTableHandle) table; ConnectorTableLayout layout = new ConnectorTableLayout(new ElasticsearchTableLayoutHandle(tableHandle, constraint.getSummary())); return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary())); }
Example #26
Source File: ElasticsearchTableLayoutHandle.java From presto-connectors with Apache License 2.0 | 5 votes |
@JsonCreator public ElasticsearchTableLayoutHandle( @JsonProperty("table") ElasticsearchTableHandle table, @JsonProperty("constraint") TupleDomain<ColumnHandle> constraint) { this.table = requireNonNull(table, "table is null"); this.constraint = requireNonNull(constraint, "constraint is null"); }
Example #27
Source File: HbaseSplitManager.java From presto-connectors with Apache License 2.0 | 5 votes |
private static Optional<Domain> getRangeDomain(String rowIdName, TupleDomain<ColumnHandle> constraint) { if (constraint.getColumnDomains().isPresent()) { for (TupleDomain.ColumnDomain<ColumnHandle> cd : constraint.getColumnDomains().get()) { HbaseColumnHandle col = (HbaseColumnHandle) cd.getColumn(); if (col.getName().equals(rowIdName)) { return Optional.of(cd.getDomain()); } } } return Optional.empty(); }
Example #28
Source File: HbaseTableLayoutHandle.java From presto-connectors with Apache License 2.0 | 5 votes |
@JsonCreator public HbaseTableLayoutHandle( @JsonProperty("table") HbaseTableHandle table, @JsonProperty("constraint") TupleDomain<ColumnHandle> constraint) { this.table = requireNonNull(table, "table is null"); this.constraint = requireNonNull(constraint, "constraint is null"); }
Example #29
Source File: HbaseMetadata.java From presto-connectors with Apache License 2.0 | 5 votes |
@Override public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) { HbaseTableHandle tableHandle = (HbaseTableHandle) table; ConnectorTableLayout layout = new ConnectorTableLayout(new HbaseTableLayoutHandle(tableHandle, constraint.getSummary())); return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary())); }
Example #30
Source File: HbaseRecordSetProvider.java From presto-connectors with Apache License 2.0 | 5 votes |
@Override public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) { requireNonNull(split, "split is null"); HbaseSplit hbaseSplit = (HbaseSplit) split; checkArgument(hbaseSplit.getConnectorId().equals(connectorId), "split is not for this connector"); ImmutableList.Builder<HbaseColumnHandle> handles = ImmutableList.builder(); for (ColumnHandle handle : columns) { handles.add((HbaseColumnHandle) handle); } return new HbaseRecordSet(hbaseClient, session, hbaseSplit, handles.build()); }