com.facebook.presto.spi.predicate.Range Java Examples
The following examples show how to use
com.facebook.presto.spi.predicate.Range.
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: Elasticsearch2Client.java From presto-connectors with Apache License 2.0 | 5 votes |
public static Collection<Range> getRangesFromDomain(Domain domain) throws TableNotFoundException { Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges(); return rangeBuilder; }
Example #2
Source File: Elasticsearch6Client.java From presto-connectors with Apache License 2.0 | 5 votes |
public static Collection<Range> getRangesFromDomain(Domain domain) throws TableNotFoundException { Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges(); return rangeBuilder; }
Example #3
Source File: HbaseClient.java From presto-connectors with Apache License 2.0 | 5 votes |
/** * Gets a collection of Hbase Range objects from the given Presto domain. * This maps the column constraints of the given Domain to an Hbase Range scan. * * @param domain Domain, can be null (returns (-inf, +inf) Range) * @return A collection of Hbase Range objects * @throws TableNotFoundException If the Hbase table is not found */ public static Collection<Range> getRangesFromDomain(Optional<Domain> domain) throws TableNotFoundException { // if we have no predicate pushdown, use the full range if (!domain.isPresent()) { return ImmutableSet.of(); } Collection<Range> rangeBuilder = domain.get().getValues().getRanges().getOrderedRanges(); return rangeBuilder; }
Example #4
Source File: Elasticsearch5Client.java From presto-connectors with Apache License 2.0 | 5 votes |
public static Collection<Range> getRangesFromDomain(Domain domain) throws TableNotFoundException { Collection<Range> rangeBuilder = domain.getValues().getRanges().getOrderedRanges(); return rangeBuilder; }
Example #5
Source File: HbaseClient.java From presto-connectors with Apache License 2.0 | 4 votes |
/** * Fetches the TabletSplitMetadata for a query against an Hbase table. * <p> * Does a whole bunch of fun stuff! Splitting on row ID ranges, applying secondary indexes, column pruning, * all sorts of sweet optimizations. What you have here is an important method. * * @param session Current session * @param schema Schema name * @param table Table Name * @param rowIdDomain Domain for the row ID * @param constraints Column constraints for the query * @return List of TabletSplitMetadata objects for Presto */ public List<TabletSplitMetadata> getTabletSplits( ConnectorSession session, String schema, String table, Optional<Domain> rowIdDomain, List<HbaseColumnConstraint> constraints) //HbaseRowSerializer serializer { try { TableName tableName = TableName.valueOf(schema, table); LOG.debug("Getting tablet splits for table %s", tableName); // Get the initial Range based on the row ID domain Collection<Range> rowIdRanges = getRangesFromDomain(rowIdDomain); //serializer // Split the ranges on tablet boundaries, if enabled // Create TabletSplitMetadata objects for each range boolean fetchTabletLocations = HbaseSessionProperties.isOptimizeLocalityEnabled(session); LOG.debug("Fetching tablet locations: %s", fetchTabletLocations); ImmutableList.Builder<TabletSplitMetadata> builder = ImmutableList.builder(); if (rowIdRanges.size() == 0) { //无 rowkey过滤 LOG.warn("This request has no rowkey filter"); } List<Scan> rowIdScans = rowIdRanges.size() == 0 ? Arrays.asList(new Scan()) : rowIdRanges.stream().map(HbaseClient::getScanFromPrestoRange).collect(Collectors.toList()); for (Scan scan : rowIdScans) { TableInputFormat tableInputFormat = getNewTableInputFormat(connection, tableName); tableInputFormat.setConf(connection.getConfiguration()); tableInputFormat.setScan(scan); JobContext context = new JobContextImpl(new JobConf(), null); List<TableSplit> splits = tableInputFormat.getSplits(context) .stream().map(x -> (TableSplit) x).collect(Collectors.toList()); for (TableSplit split : splits) { TabletSplitMetadata metadata = new TabletSplitMetadata( split.getTable().getName(), split.getStartRow(), split.getEndRow(), TabletSplitMetadata.convertScanToString(split.getScan()), split.getRegionLocation(), split.getLength()); builder.add(metadata); } } List<TabletSplitMetadata> tabletSplits = builder.build(); // Log some fun stuff and return the tablet splits LOG.debug("Number of splits for table %s is %d with %d ranges", tableName, tabletSplits.size(), rowIdRanges.size()); return tabletSplits; } catch (Exception e) { throw new PrestoException(UNEXPECTED_HBASE_ERROR, "Failed to get splits from Hbase", e); } }