Examples of TableRef


Examples of org.apache.phoenix.schema.TableRef

    }

        @Override
        public TableRef resolveTable(String schemaName, String tableName)
                throws SQLException {
            TableRef tableRef = tableRefs.get(0);
            /*
             * The only case we can definitely verify is when both a schemaName and a tableName
             * are provided. Otherwise, the tableName might be a column family. In this case,
             * this will be validated by resolveColumn.
             */
            if (schemaName != null || tableName != null) {
                String resolvedTableName = tableRef.getTable().getTableName().getString();
                String resolvedSchemaName = tableRef.getTable().getSchemaName().getString();
                if (schemaName != null && tableName != null) {
                    if ( ! ( schemaName.equals(resolvedSchemaName&&
                             tableName.equals(resolvedTableName) )  &&
                             ! schemaName.equals(alias) ) {
                        throw new TableNotFoundException(schemaName, tableName);
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

        }

    @Override
    public ColumnRef resolveColumn(String schemaName, String tableName,
        String colName) throws SQLException {
      TableRef tableRef = tableRefs.get(0);
      boolean resolveCF = false;
      if (schemaName != null || tableName != null) {
          String resolvedTableName = tableRef.getTable().getTableName().getString();
          String resolvedSchemaName = tableRef.getTable().getSchemaName().getString();
          if (schemaName != null && tableName != null) {
                    if ( ! ( schemaName.equals(resolvedSchemaName&&
                             tableName.equals(resolvedTableName) )) {
                        if (!(resolveCF = schemaName.equals(alias))) {
                            throw new ColumnNotFoundException(schemaName, tableName, null, colName);
                        }
                    }
          } else { // schemaName == null && tableName != null
                    if (tableName != null && !tableName.equals(alias) && (!tableName.equals(resolvedTableName) || !resolvedSchemaName.equals(""))) {
                        resolveCF = true;
                   }
          }
         
      }
          PColumn column = resolveCF
                  ? tableRef.getTable().getColumnFamily(tableName).getColumn(colName)
              : tableRef.getTable().getColumn(colName);
            return new ColumnRef(tableRef, column.getPosition());
    }
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

    private List<InputSplit> generateSplits(final QueryPlan qplan, final List<KeyRange> splits) throws IOException {
        Preconditions.checkNotNull(qplan);
        Preconditions.checkNotNull(splits);
        final List<InputSplit> psplits = Lists.newArrayListWithExpectedSize(splits.size());
        final StatementContext context = qplan.getContext();
        final TableRef tableRef = qplan.getTableRef();
        for (KeyRange split : splits) {
            final Scan splitScan = new Scan(context.getScan());
            if (tableRef.getTable().getBucketNum() != null) {
                KeyRange minMaxRange = context.getMinMaxRange();
                if (minMaxRange != null) {
                    minMaxRange = SaltingUtil.addSaltByte(split.getLowerRange(), minMaxRange);
                    split = split.intersect(minMaxRange);
                }
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

        createTestTable(getUrl(),DDL,splits, ts-2);
        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts;
        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
        Connection conn = DriverManager.getConnection(url, props);
        PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
        TableRef tableRef = new TableRef(null,pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), TABLE_NAME)),ts, false);
        List<HRegionLocation> regions = pconn.getQueryServices().getAllTableRegions(tableRef.getTable().getPhysicalName().getBytes());
       
        conn.close();
        initTableValues();
        List<KeyRange> ranges = getSplits(tableRef, scan, regions, scanRanges);
        assertEquals("Unexpected number of splits: " + ranges.size(), expectedSplits.size(), ranges.size());
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

@Category(ClientManagedTimeTest.class)
public class DefaultParallelIteratorsRegionSplitterIT extends BaseParallelIteratorsRegionSplitterIT {
   
    private static List<KeyRange> getSplits(Connection conn, long ts, final Scan scan)
            throws SQLException {
        TableRef tableRef = getTableRef(conn, ts);
        PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
        final List<HRegionLocation> regions =  pconn.getQueryServices().getAllTableRegions(tableRef.getTable().getPhysicalName().getBytes());
        PhoenixStatement statement = new PhoenixStatement(pconn);
        StatementContext context = new StatementContext(statement, null, scan, new SequenceManager(statement));
        DefaultParallelIteratorRegionSplitter splitter = new DefaultParallelIteratorRegionSplitter(context, tableRef, HintNode.EMPTY_HINT_NODE) {
            @Override
            protected List<HRegionLocation> getAllRegions() throws SQLException {
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

        Connection conn = DriverManager.getConnection(url, props);

        Scan scan = new Scan();
       
        ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));
        TableRef table = getTableRef(conn,ts);
        services.getStatsManager().updateStats(table);
        scan.setStartRow(HConstants.EMPTY_START_ROW);
        scan.setStopRow(K1);
        List<KeyRange> keyRanges = getSplits(conn, ts, scan);
        assertEquals("Unexpected number of splits: " + keyRanges, 3, keyRanges.size());
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

        long ts = nextTimestamp();
        initTableValues(ts);
        String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + ts;
        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
        Connection conn = DriverManager.getConnection(url, props);
        TableRef table = getTableRef(conn,ts);

        int updateFreq = 5;
        int maxAge = 10;
        int startTime = 100;
        long waitTime = 5000;
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

        conn.close();
    }

    protected static TableRef getTableRef(Connection conn, long ts) throws SQLException {
        PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
        TableRef table = new TableRef(null,pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), STABLE_NAME)),ts, false);
        return table;
    }
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

            TableName tableNameNode = table.getName();
            String schemaName = tableNameNode.getSchemaName();
            String tableName = tableNameNode.getTableName();
            SQLException sqlE = null;
            long timeStamp = QueryConstants.UNSET_TIMESTAMP;
            TableRef tableRef = null;
            boolean retry = true;
            while (true) {
                try {
                    if (!updateCacheOnlyIfAutoCommit || connection.getAutoCommit()) {
                        timeStamp = Math.abs(client.updateCache(schemaName, tableName));
                    }
                    String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
                    PTable theTable = connection.getPMetaData().getTable(fullTableName);
                    // If dynamic columns have been specified add them to the table declaration
                    if (!table.getDynamicColumns().isEmpty()) {
                        theTable = this.addDynamicColumns(table.getDynamicColumns(), theTable);
                    }
                    tableRef = new TableRef(null, theTable, timeStamp, !table.getDynamicColumns().isEmpty());
                    if (!retry && logger.isDebugEnabled()) {
                        logger.debug("Re-resolved stale table " + fullTableName + " with seqNum " + tableRef.getTable().getSequenceNumber() + " at timestamp " + tableRef.getTable().getTimeStamp() + " with " + tableRef.getTable().getColumns().size() + " columns: " + tableRef.getTable().getColumns());
                    }
                    break;
                } catch (TableNotFoundException e) {
                    sqlE = e;
                }
View Full Code Here

Examples of org.apache.phoenix.schema.TableRef

    }

    @Override
    public ColumnRef resolveColumn(String schemaName, String tableName,
        String colName) throws SQLException {
      TableRef tableRef = tableRefs.get(0);
      boolean resolveCF = false;
      if (schemaName != null || tableName != null) {
          String resolvedTableName = tableRef.getTable().getTableName().getString();
          String resolvedSchemaName = tableRef.getTable().getSchemaName().getString();
          if (schemaName != null && tableName != null) {
                    if ( ! ( schemaName.equals(resolvedSchemaName&&
                             tableName.equals(resolvedTableName) )) {
                        if (!(resolveCF = schemaName.equals(alias))) {
                            throw new ColumnNotFoundException(schemaName, tableName, null, colName);
                        }
                    }
          } else { // schemaName == null && tableName != null
                    if (tableName != null && !tableName.equals(alias) && (!tableName.equals(resolvedTableName) || !resolvedSchemaName.equals(""))) {
                        resolveCF = true;
                   }
          }
         
      }
          PColumn column = resolveCF
                  ? tableRef.getTable().getColumnFamily(tableName).getColumn(colName)
              : tableRef.getTable().getColumn(colName);
            return new ColumnRef(tableRef, column.getPosition());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.