public ClientHashAggregatingResultIterator(StatementContext context, ResultIterator resultIterator, Aggregators aggregators, List<Expression> groupByExpressions, OrderBy orderBy) { Objects.requireNonNull(resultIterator); Objects.requireNonNull(aggregators); Objects.requireNonNull(groupByExpressions); this.resultIterator = resultIterator; this.aggregators = aggregators; this.groupByExpressions = groupByExpressions; this.orderBy = orderBy; memoryChunk = context.getConnection().getQueryServices().getMemoryManager().allocate(CLIENT_HASH_AGG_MEMORY_CHUNK_SIZE); }
@Override public List<HRegionLocation> getRegionBoundaries(StatementContext context, byte[] tableName) throws SQLException{ return context.getConnection().getQueryServices().getAllTableRegions(tableName); } }
@Override public MutationState execute() throws SQLException { Object consistency = getProps().get(PhoenixRuntime.CONSISTENCY_ATTRIB.toUpperCase()); if(consistency != null) { if (((String)consistency).equalsIgnoreCase(Consistency.TIMELINE.toString())){ getContext().getConnection().setConsistency(Consistency.TIMELINE); } else { getContext().getConnection().setConsistency(Consistency.STRONG); } } return new MutationState(0, 0, context.getConnection()); } };
/** * @return true if scanners could be left open and records retrieved by simply advancing them on * the server side. To make sure HBase doesn't cancel the leases and close the open * scanners, we need to periodically renew leases. To look at the earliest HBase version * that supports renewing leases, see * {@link MetaDataProtocol#MIN_RENEW_LEASE_VERSION} */ public static boolean isPacingScannersPossible(StatementContext context) { return context.getConnection().getQueryServices().isRenewingLeasesEnabled(); }
@Override public MutationState updateData(MutationPlan plan) throws SQLException { return new MutationState(0, 0, plan.getContext().getConnection()); }
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.dropIndex(ExecutableDropIndexStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.dropColumn(ExecutableDropColumnStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.dropSchema(ExecutableDropSchemaStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.changePermissions(ExecutableChangePermsStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.alterIndex(ExecutableAlterIndexStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.dropFunction(ExecutableDropFunctionStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.useSchema(ExecutableUseSchemaStatement.this); } };
@Override public MutationState updateData(MutationPlan plan) throws SQLException { MutationState state = plan.execute(); plan.getContext().getConnection().commit(); return state; }
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.dropTable(ExecutableDropTableStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.updateStatistics(ExecutableUpdateStatisticsStatement.this); } };
@Override public MutationState execute() throws SQLException { MetaDataClient client = new MetaDataClient(getContext().getConnection()); return client.addColumn(ExecutableAddColumnStatement.this); } };
public static boolean forceRowKeyOrder(StatementContext context) { return context.getConnection().getQueryServices().getProps() .getBoolean(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, QueryServicesOptions.DEFAULT_FORCE_ROW_KEY_ORDER); }
public ServerCache createServerCache(byte[] cacheId, QueryPlan delegate) throws SQLException, IOException { PTable cacheUsingTable = delegate.getTableRef().getTable(); ConnectionQueryServices services = delegate.getContext().getConnection().getQueryServices(); List<HRegionLocation> locations = services.getAllTableRegions( cacheUsingTable.getPhysicalName().getBytes()); int nRegions = locations.size(); Set<HRegionLocation> servers = new HashSet<>(nRegions); cacheUsingTableMap.put(Bytes.mapKey(cacheId), cacheUsingTable); return new ServerCache(cacheId, servers, new ImmutableBytesWritable( new byte[]{}), services, false); }
@Override public Expression create(List<Expression> children, StatementContext context) throws SQLException { QueryServices services = context.getConnection().getQueryServices(); boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX); if (useByteBasedRegex) { return new ByteBasedRegexpReplaceFunction(children); } else { return new StringBasedRegexpReplaceFunction(children); } } }
private static boolean useByteBasedRegex(StatementContext context) { return context .getConnection() .getQueryServices() .getProps() .getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX); }