private long getClientTimeStamp() { Long scn = connection.getSCN(); long clientTimeStamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; return clientTimeStamp; }
private long getCurrentScn() { Long scn = connection.getSCN(); long currentScn = scn == null ? HConstants.LATEST_TIMESTAMP : scn; return currentScn; }
private ImmutableMap<String, String> getImmutableCustomTracingAnnotations() { Builder<String, String> result = ImmutableMap.builder(); result.putAll(JDBCUtil.getAnnotations(url, info)); if (getSCN() != null) { result.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, getSCN().toString()); } if (getTenantId() != null) { result.put(PhoenixRuntime.TENANT_ID_ATTRIB, getTenantId() .getString()); } return result.build(); }
private void incrementSequenceValues() throws SQLException { if (sequenceMap == null) { return; } Long scn = statement.getConnection().getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; ConnectionQueryServices services = statement.getConnection().getQueryServices(); services.incrementSequences(nextSequences, timestamp, srcSequenceValues, sqlExceptions); setSequenceValues(srcSequenceValues, dstSequenceValues, sqlExceptions); int offset = nextSequences.size(); for (int i = 0; i < currentSequences.size(); i++) { dstSequenceValues[sequencePosition[offset+i]] = services.currentSequenceValue(currentSequences.get(i), timestamp); } }
final Iterator<Map.Entry<TableRef, MultiRowMutationState>> iterator = this.mutations.entrySet().iterator(); if (!iterator.hasNext()) { return Collections.emptyIterator(); } Long scn = connection.getSCN(); final long serverTimestamp = getTableTimestamp(tableTimestamp, scn); final long mutationTimestamp = getMutationTimestamp(scn);
Long scn = statement.getConnection().getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; services.validateSequences(nextSequences, timestamp, srcSequenceValues, sqlExceptions, action);
public static long getResolvedTimestamp(PhoenixConnection connection, boolean isTransactional, long defaultResolvedTimestamp) { MutationState mutationState = connection.getMutationState(); Long scn = connection.getSCN(); return scn != null ? scn : (isTransactional && mutationState.isTransactionStarted()) ? convertToMilliseconds(mutationState.getInitialWritePointer()) : defaultResolvedTimestamp; }
tableMetadata.addAll(metaConnection.getMutationState().toMutations(metaConnection.getSCN()).next().getSecond()); metaConnection.rollback(); PColumn column = new PColumnImpl(PNameFactory.newName("COLUMN_QUALIFIER"), colUpsert.execute(); tableMetadata.addAll(metaConnection.getMutationState().toMutations(metaConnection.getSCN()).next().getSecond()); metaConnection.rollback(); metaConnection.getQueryServices().addColumn(tableMetadata, sysCatalogPTable, Collections.<String,List<Pair<String,Object>>>emptyMap(), Collections.<String>emptySet(), Lists.newArrayList(column));
props.setProperty(PhoenixRuntime.BUILD_INDEX_AT_ATTRIB, Long.toString(connection.getSCN()+1)); PhoenixConnection conn = new PhoenixConnection(connection, connection.getQueryServices(), props); MetaDataClient newClientAtNextTimeStamp = new MetaDataClient(conn);
PTable table = tableRef.getTable(); physicalTableName = table.getPhysicalName().getBytes(); Long currentSCN = context.getConnection().getSCN(); if (null == currentSCN) { currentSCN = HConstants.LATEST_TIMESTAMP;
SchemaUtil.getFunctionKey(tenantId == null ? ByteUtil.EMPTY_BYTE_ARRAY : tenantId.getBytes(), Bytes.toBytes(functionName)); Long scn = connection.getSCN(); long clientTimeStamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; try {
public MutationState createSequence(CreateSequenceStatement statement, long startWith, long incrementBy, long cacheSize, long minValue, long maxValue) throws SQLException { Long scn = connection.getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString(); String schemaName=statement.getSequenceName().getSchemaName(); if (SchemaUtil.isNamespaceMappingEnabled(null, connection.getQueryServices().getProps())) { if (schemaName == null || schemaName.equals(StringUtil.EMPTY_STRING)) { schemaName = connection.getSchema(); } if (schemaName != null) { FromCompiler.getResolverForSchema(schemaName, connection); } } return createSequence(tenantId, schemaName, statement .getSequenceName().getTableName(), statement.ifNotExists(), startWith, incrementBy, cacheSize, statement.getCycle(), minValue, maxValue, timestamp); }
Long scn = connection.getSCN(); String schema = table.getName().getSchemaName(); if (connection.getSchema() != null) {
projectedColumns.add(projectedColumn); Long scn = statement.getConnection().getSCN(); PTable tempTable = new PTableImpl.Builder() .setType(PTableType.SUBQUERY)
final long msMinBetweenUpdates = props .getLong(QueryServices.MIN_STATS_UPDATE_FREQ_MS_ATTRIB, QueryServicesOptions.DEFAULT_MIN_STATS_UPDATE_FREQ_MS); Long scn = connection.getSCN(); long clientTimeStamp = connection.getSCN() == null ? HConstants.LATEST_TIMESTAMP : scn; long msSinceLastUpdate = Long.MAX_VALUE; if (checkLastStatsUpdateTime) {
byte[] key = SchemaUtil.getSchemaKey(schemaName); Long scn = connection.getSCN(); long clientTimeStamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; List<Mutation> schemaMetaData = Lists.newArrayListWithExpectedSize(2);
public MutationState dropSequence(DropSequenceStatement statement) throws SQLException { Long scn = connection.getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; String schemaName = connection.getSchema() != null && statement.getSequenceName().getSchemaName() == null ? connection.getSchema() : statement.getSequenceName().getSchemaName(); String sequenceName = statement.getSequenceName().getTableName(); String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString(); try { connection.getQueryServices().dropSequence(tenantId, schemaName, sequenceName, timestamp); } catch (SequenceNotFoundException e) { if (statement.ifExists()) { return new MutationState(0, 0, connection); } throw e; } return new MutationState(1, 1000, connection); }
MutationPlan mutationPlan = getMutationPlanForBuildingIndex(index, dataTableRef); Scan scan = mutationPlan.getContext().getScan(); Long scn = connection.getSCN(); try { if (ScanUtil.isDefaultTimeRange(scan.getTimeRange())) {
public boolean startTransaction(Provider provider) throws SQLException { if (provider == null) { return false; } if (!connection.getQueryServices().getProps() .getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TXN_IF_TXN_DISABLED).build().buildException(); } if (connection.getSCN() != null) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET).build().buildException(); } if (phoenixTransactionContext == PhoenixTransactionContext.NULL_CONTEXT) { phoenixTransactionContext = provider.getTransactionProvider().getTransactionContext(connection); } else { if (provider != phoenixTransactionContext.getProvider()) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.CANNOT_MIX_TXN_PROVIDERS) .setMessage(phoenixTransactionContext.getProvider().name() + " and " + provider.name()).build() .buildException(); } } if (!isTransactionStarted()) { // Clear any transactional state in case transaction was ended outside // of Phoenix so we don't carry the old transaction state forward. We // cannot call reset() here due to the case of having mutations and // then transitioning from non transactional to transactional (which // would end up clearing our uncommitted state). resetTransactionalState(); phoenixTransactionContext.begin(); return true; } return false; }
Long scn = connection.getSCN(); long ts = (scn == null ? table.getTimeStamp() : scn);