@Override public String getUserName() throws SQLException { String userName = connection.getQueryServices().getUserName(); return userName == null ? StringUtil.EMPTY_STRING : userName; }
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 void addTable(PTable table, long resolvedTime) throws SQLException { metaData.addTable(table, resolvedTime); // Cascade through to connectionQueryServices too getQueryServices().addTable(table, resolvedTime); }
@Override public void addSchema(PSchema schema) throws SQLException { metaData.addSchema(schema); // Cascade through to connectionQueryServices too getQueryServices().addSchema(schema); }
@Override public void removeSchema(PSchema schema, long schemaTimeStamp) { metaData.removeSchema(schema, schemaTimeStamp); // Cascade through to connectionQueryServices too getQueryServices().removeSchema(schema, schemaTimeStamp); }
@Override public String get(String key, String defaultValue) { return conn.getQueryServices().getProps().get(key, defaultValue); } }
/** * Internally to Phoenix we allow callers to set the query timeout in millis * via the phoenix.query.timeoutMs. Therefore we store the time in millis. */ private int getDefaultQueryTimeoutMillis() { return connection.getQueryServices().getProps().getInt(QueryServices.THREAD_TIMEOUT_MS_ATTRIB, QueryServicesOptions.DEFAULT_THREAD_TIMEOUT_MS); }
public static boolean hasLocalIndexTable(PhoenixConnection connection, byte[] physicalTableName) throws SQLException { try { TableDescriptor desc = connection.getQueryServices().getTableDescriptor(physicalTableName); if(desc == null ) return false; return hasLocalIndexColumnFamily(desc); } catch (TableNotFoundException e) { return false; } }
@Override public void updateResolvedTimestamp(PTable table, long resolvedTime) throws SQLException { metaData.updateResolvedTimestamp(table, resolvedTime); // Cascade through to connectionQueryServices too getQueryServices().updateResolvedTimestamp(table, resolvedTime); }
@Override public void removeFunction(PName tenantId, String functionName, long tableTimeStamp) throws SQLException { metaData.removeFunction(tenantId, functionName, tableTimeStamp); // Cascade through to connectionQueryServices too getQueryServices().removeFunction(tenantId, functionName, tableTimeStamp); }
public TephraTransactionContext(PhoenixConnection connection) throws SQLException { PhoenixTransactionClient client = connection.getQueryServices().initTransactionClient(getProvider()); assert (client instanceof TephraTransactionClient); this.txServiceClient = ((TephraTransactionClient)client).getTransactionClient(); this.txAwares = Collections.emptyList(); this.txContext = new TransactionContext(txServiceClient); }
@Override public void addFunction(PFunction function) throws SQLException { // TODO: since a connection is only used by one thread at a time, // we could modify this metadata in place since it's not shared. if (scn == null || scn > function.getTimeStamp()) { metaData.addFunction(function); } // Cascade through to connectionQueryServices too getQueryServices().addFunction(function); }
private QueryLogger(PhoenixConnection connection) { this.queryId = UUID.randomUUID().toString(); this.queryDisruptor = connection.getQueryServices().getQueryDisruptor(); logLevel = connection.getLogLevel(); log(QueryLogInfo.QUERY_ID_I, queryId); log(QueryLogInfo.START_TIME_I, EnvironmentEdgeManager.currentTimeMillis()); }
public PhoenixConnection(PhoenixConnection connection, MutationState mutationState) throws SQLException { this(connection.getQueryServices(), connection.getURL(), connection .getClientInfo(), connection.getMetaDataCache(), mutationState, connection.isDescVarLengthRowKeyUpgrade(), connection .isRunningUpgrade(), connection.buildingIndex); }
@Override public PeekingResultIterator newIterator(StatementContext context, ResultIterator scanner, Scan scan, String tableName, QueryPlan plan) throws SQLException { if (logger.isDebugEnabled()) logger.debug(LogUtil.addCustomAnnotations("ChunkedResultIteratorFactory.newIterator over " + tableRef.getTable().getPhysicalName().getString() + " with " + scan, ScanUtil.getCustomAnnotations(scan))); return new ChunkedResultIterator(delegateFactory, mutationState, context, tableRef, scan, mutationState.getConnection().getQueryServices().getProps().getLong( QueryServices.SCAN_RESULT_CHUNK_SIZE, QueryServicesOptions.DEFAULT_SCAN_RESULT_CHUNK_SIZE), scanner, plan); } }
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); }
@After public void assertNoUnfreedMemory() throws SQLException { Connection conn = DriverManager.getConnection(getUrl()); try { long unfreedBytes = conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); assertEquals(0,unfreedBytes); } finally { conn.close(); } }
private static boolean useByteBasedRegex(StatementContext context) { return context .getConnection() .getQueryServices() .getProps() .getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX); }
public Table getHTable(PTable table) throws SQLException { Table htable = this.getConnection().getQueryServices().getTable(table.getPhysicalName().getBytes()); if (table.isTransactional() && phoenixTransactionContext.isTransactionRunning()) { // We're only using this table for reading, so we want it wrapped even if it's an index htable = phoenixTransactionContext.getTransactionalTable(htable, table.isImmutableRows() || table.getType() == PTableType.INDEX); } return htable; }