Java Code Examples for com.facebook.presto.spi.predicate.TupleDomain#ColumnDomain
The following examples show how to use
com.facebook.presto.spi.predicate.TupleDomain#ColumnDomain .
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: 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 2
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 3
Source File: Elasticsearch2Client.java From presto-connectors with Apache License 2.0 | 4 votes |
private static Map<String, String> getQueryDsl(TupleDomain<ColumnHandle> constraint) { final Map<String, Object> mergeDslMap = new HashMap<>(); Map<String, String> dslCacher = new HashMap<>(); if (constraint.getColumnDomains().isPresent()) { for (TupleDomain.ColumnDomain<ColumnHandle> cd : constraint.getColumnDomains().get()) { ElasticsearchColumnHandle column = (ElasticsearchColumnHandle) cd.getColumn(); String columnName = column.getName(); if ("_type".equals(columnName)) { throw new UnsupportedOperationException("this _type filter have't support!"); } else if (columnName.startsWith("_")) { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(range.isSingleValue(), "dsl is must [=] demo where _dsl = \"..dsl string\""); checkArgument(range.getType() instanceof VarcharType, "_dsl filter is not string"); String dsl = ((Slice) range.getSingleValue()).toStringUtf8(); dslCacher.put(columnName, dsl); if (!"_dsl".equals(columnName)) { dsl = dsl.replace(MatchQueryFunction.MATCH_COLUMN_SEP, columnName.substring(1)); } addEsQueryFilter(mergeDslMap, dsl); }); } else { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(column.getType().equals(range.getType()), "filter type is " + range.getType() + " but column [" + columnName + "] type is " + column.getType()); QueryBuilder queryBuilder = getQueryBuilderFromPrestoRange(columnName, range); addEsQueryFilter(mergeDslMap, queryBuilder.toString()); }); } } } try { String allDsl = mergeDslMap.isEmpty() ? QueryBuilders.boolQuery().toString() : MAPPER.writeValueAsString(mergeDslMap); dslCacher.put("_allDsl", allDsl); return dslCacher; } catch (JsonProcessingException e) { throw new PrestoException(ES_DSL_ERROR, e); } }
Example 4
Source File: Elasticsearch6Client.java From presto-connectors with Apache License 2.0 | 4 votes |
private static Map<String, String> getQueryDsl(TupleDomain<ColumnHandle> constraint) { final Map<String, Object> mergeDslMap = new HashMap<>(); Map<String, String> dslCacher = new HashMap<>(); if (constraint.getColumnDomains().isPresent()) { for (TupleDomain.ColumnDomain<ColumnHandle> cd : constraint.getColumnDomains().get()) { ElasticsearchColumnHandle column = (ElasticsearchColumnHandle) cd.getColumn(); String columnName = column.getName(); if ("_type".equals(columnName)) { throw new UnsupportedOperationException("this _type filter have't support!"); } else if (columnName.startsWith("_")) { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(range.isSingleValue(), "dsl is must [=] demo where _dsl = \"..dsl string\""); checkArgument(range.getType() instanceof VarcharType, "_dsl filter is not string"); String dsl = ((Slice) range.getSingleValue()).toStringUtf8(); dslCacher.put(columnName, dsl); if (!"_dsl".equals(columnName)) { dsl = dsl.replace(MatchQueryFunction.MATCH_COLUMN_SEP, columnName.substring(1)); } addEsQueryFilter(mergeDslMap, dsl); }); } else { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(column.getType().equals(range.getType()), "filter type is " + range.getType() + " but column [" + columnName + "] type is " + column.getType()); QueryBuilder queryBuilder = getQueryBuilderFromPrestoRange(columnName, range); addEsQueryFilter(mergeDslMap, queryBuilder.toString()); }); } } } try { String allDsl = mergeDslMap.isEmpty() ? QueryBuilders.boolQuery().toString() : MAPPER.writeValueAsString(mergeDslMap.get("query")); //es5和 6开始只能返回 query的自节点 dslCacher.put("_allDsl", allDsl); return dslCacher; } catch (JsonProcessingException e) { throw new PrestoException(ES_DSL_ERROR, e); } }
Example 5
Source File: Elasticsearch5Client.java From presto-connectors with Apache License 2.0 | 4 votes |
private static Map<String, String> getQueryDsl(TupleDomain<ColumnHandle> constraint) { final Map<String, Object> mergeDslMap = new HashMap<>(); Map<String, String> dslCacher = new HashMap<>(); if (constraint.getColumnDomains().isPresent()) { for (TupleDomain.ColumnDomain<ColumnHandle> cd : constraint.getColumnDomains().get()) { ElasticsearchColumnHandle column = (ElasticsearchColumnHandle) cd.getColumn(); String columnName = column.getName(); if ("_type".equals(columnName)) { throw new UnsupportedOperationException("this _type filter have't support!"); } else if (columnName.startsWith("_")) { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(range.isSingleValue(), "dsl is must [=] demo where _dsl = \"..dsl string\""); checkArgument(range.getType() instanceof VarcharType, "_dsl filter is not string"); String dsl = ((Slice) range.getSingleValue()).toStringUtf8(); dslCacher.put(columnName, dsl); if (!"_dsl".equals(columnName)) { dsl = dsl.replace(MatchQueryFunction.MATCH_COLUMN_SEP, columnName.substring(1)); } addEsQueryFilter(mergeDslMap, dsl); }); } else { getRangesFromDomain(cd.getDomain()).forEach(range -> { checkArgument(column.getType().equals(range.getType()), "filter type is " + range.getType() + " but column [" + columnName + "] type is " + column.getType()); QueryBuilder queryBuilder = getQueryBuilderFromPrestoRange(columnName, range); addEsQueryFilter(mergeDslMap, queryBuilder.toString()); }); } } } try { String allDsl = mergeDslMap.isEmpty() ? QueryBuilders.boolQuery().toString() : MAPPER.writeValueAsString(mergeDslMap.get("query")); //es5和 6开始只能返回 query的自节点 dslCacher.put("_allDsl", allDsl); return dslCacher; } catch (JsonProcessingException e) { throw new PrestoException(ES_DSL_ERROR, e); } }