Java Code Examples for org.apache.phoenix.jdbc.PhoenixConnection#getSCN()

The following examples show how to use org.apache.phoenix.jdbc.PhoenixConnection#getSCN() . 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: FromCompiler.java    From phoenix with Apache License 2.0 5 votes vote down vote up
public SingleTableColumnResolver(PhoenixConnection connection, NamedTableNode table, long timeStamp) throws SQLException  {
    super(connection, 0);
    List<PColumnFamily> families = Lists.newArrayListWithExpectedSize(table.getDynamicColumns().size());
    for (ColumnDef def : table.getDynamicColumns()) {
        if (def.getColumnDefName().getFamilyName() != null) {
            families.add(new PColumnFamilyImpl(PNameFactory.newName(def.getColumnDefName().getFamilyName()),Collections.<PColumn>emptyList()));
        }
    }
    Long scn = connection.getSCN();
    PTable theTable = new PTableImpl(connection.getTenantId(), table.getName().getSchemaName(), table.getName().getTableName(), scn == null ? HConstants.LATEST_TIMESTAMP : scn, families);
    theTable = this.addDynamicColumns(table.getDynamicColumns(), theTable);
    alias = null;
    tableRefs = ImmutableList.of(new TableRef(alias, theTable, timeStamp, !table.getDynamicColumns().isEmpty()));
}
 
Example 2
Source File: FromCompiler.java    From phoenix with Apache License 2.0 4 votes vote down vote up
public SingleTableColumnResolver(PhoenixConnection connection, NamedTableNode table, long timeStamp, Map<String, UDFParseNode> udfParseNodes, boolean isNamespaceMapped) throws SQLException {
    super(connection, 0, false, udfParseNodes, null);
    List<PColumnFamily> families = Lists.newArrayListWithExpectedSize(table.getDynamicColumns().size());
    for (ColumnDef def : table.getDynamicColumns()) {
        if (def.getColumnDefName().getFamilyName() != null) {
            families.add(new PColumnFamilyImpl(PNameFactory.newName(def.getColumnDefName().getFamilyName()),Collections.<PColumn>emptyList()));//, NON_ENCODED_QUALIFIERS));
        }
    }
    Long scn = connection.getSCN();
    String schema = table.getName().getSchemaName();
    if (connection.getSchema() != null) {
        schema = schema != null ? schema : connection.getSchema();
    }

    // Storage scheme and encoding scheme don't matter here since the PTable is being used only for the purposes of create table.
    // The actual values of these two will be determined by the metadata client.
    PName tenantId = connection.getTenantId();
    PTableImpl.checkTenantId(tenantId);
    String tableName = table.getName().getTableName();
    PName name = PNameFactory.newName(SchemaUtil.getTableName(schema, tableName));
    PTable theTable = new PTableImpl.Builder()
            .setTenantId(tenantId)
            .setName(name)
            .setKey(new PTableKey(tenantId, name.getString()))
            .setSchemaName(PNameFactory.newName(schema))
            .setTableName(PNameFactory.newName(tableName))
            .setType(PTableType.VIEW)
            .setViewType(PTable.ViewType.MAPPED)
            .setTimeStamp(scn == null ? HConstants.LATEST_TIMESTAMP : scn)
            .setPkColumns(Collections.emptyList())
            .setAllColumns(Collections.emptyList())
            .setRowKeySchema(RowKeySchema.EMPTY_SCHEMA)
            .setIndexes(Collections.emptyList())
            .setFamilyAttributes(families)
            .setPhysicalNames(Collections.emptyList())
            .setNamespaceMapped(isNamespaceMapped)
            .build();
    theTable = this.addDynamicColumns(table.getDynamicColumns(), theTable);
    alias = null;
    tableRefs = ImmutableList.of(new TableRef(alias, theTable, timeStamp, !table.getDynamicColumns().isEmpty()));
    schemas = ImmutableList.of(new PSchema(theTable.getSchemaName().toString(), timeStamp));
}
 
Example 3
Source File: TransactionUtil.java    From phoenix with Apache License 2.0 4 votes vote down vote up
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;
}