Package com.foundationdb.qp.rowtype

Examples of com.foundationdb.qp.rowtype.IndexRowType


        return new OperatorCreator() {
            @Override
            public Operator create(Schema schema) {
                TableRowType tableType = schema.tableRowType(tID);
                Index index = schema.tableRowType(tID).table().getGroup().getIndex(indexName);
                IndexRowType indexType = schema.indexRowType(index);
                return API.indexScan_Default(indexType, false, IndexKeyRange.unbounded(indexType), tableType);
            }
        };
    }
View Full Code Here


            row(mid, 41, 4, "y", "two")
        );

        AkibanInformationSchema ais = ais();
        Schema schema = SchemaCache.globalSchema(ais);
        IndexRowType rIndex = schema.indexRowType(ais.getTable(rid).getIndex("name"));
        IndexRowType mdIndex = schema.indexRowType(ais.getTable(mid).getIndex("name_value"));

        /*
        Build something like:
          Intersect_Ordered(skip 2 left, skip 2 right, compare 1)
            Intersect_Ordered(skip 2 left, skip 1 right, compare 1)
              IndexScan_Default(Index(metadata.name_value), name = 'x', value = 'one')
              IndexScan_Default(Index(reports.name), name = 'foo')
            IndexScan_Default(Index(metadata.name_value), name = 'y', value = 'two')
         */

        IndexBound fooBound = new IndexBound(testRow(rIndex, "foo", null), new SetColumnSelector(0));
        Operator fooScan = API.indexScan_Default(rIndex,
                                                 false,
                                                 IndexKeyRange.bounded(rIndex, fooBound, true, fooBound, true));

        IndexBound xOneBound = new IndexBound(testRow(mdIndex, "x", "one", null, null), new SetColumnSelector(0, 1));
        Operator xOneScan = API.indexScan_Default(mdIndex,
                                                   false,
                                                   IndexKeyRange.bounded(mdIndex, xOneBound, true, xOneBound, true));

        IndexBound yTwoBound = new IndexBound(testRow(mdIndex, "y", "two", null, null), new SetColumnSelector(0, 1));
        Operator yTwoScan = API.indexScan_Default(mdIndex,
                                                  false,
                                                  IndexKeyRange.bounded(mdIndex, yTwoBound, true, yTwoBound, true));

        TKeyComparable comparableIntBigint = typesRegistryService().getKeyComparable(
            ais.getTable(mid).getColumn("report_id").getType().typeClass(),
            ais.getTable(rid).getColumn("id").getType().typeClass()
        );

        Operator innerIntersect = API.intersect_Ordered(
                xOneScan,
                fooScan,
                mdIndex,
                rIndex,
                mdIndex.index().getAllColumns().size() - 2,
                rIndex.index().getAllColumns().size() - 1,
                new boolean[]{true},
                JoinType.INNER_JOIN,
                EnumSet.of(IntersectOption.OUTPUT_LEFT, IntersectOption.SKIP_SCAN),
                Arrays.asList(comparableIntBigint.getComparison()),
                true
        );

        Operator outerIntersect = API.intersect_Ordered(
                innerIntersect,
                yTwoScan,
                mdIndex,
                mdIndex,
                mdIndex.index().getAllColumns().size() - 2,
                mdIndex.index().getAllColumns().size() - 2,
                new boolean[]{true},
                JoinType.INNER_JOIN,
                EnumSet.of(IntersectOption.OUTPUT_LEFT, IntersectOption.SKIP_SCAN),
                null,
                true
View Full Code Here

     */
    public static Operator generateBranchPlan (AkibanInformationSchema ais, Table table) {
        final Operator indexScan = generateIndexScan(ais, table);
        final Schema schema = SchemaCache.globalSchema(ais);
        PrimaryKey pkey = table.getPrimaryKeyIncludingInternal();
        IndexRowType indexType = schema.indexRowType(pkey.getIndex());
        return generateBranchPlan(table, indexScan, indexType);
    }
View Full Code Here

        TableRowType tableType = schema.tableRowType(table);

        List<TableRowType> ancestorType = new ArrayList<>(1);
        ancestorType.add (tableType);

        IndexRowType indexType = schema.indexRowType(table.getPrimaryKeyIncludingInternal().getIndex());
       
        Operator indexScan = generateIndexScan (ais, table);
        Operator lookup = API.groupLookup_Default(indexScan,
                table.getGroup(),
                indexType,
View Full Code Here

     */
    private static Operator generateIndexScan (AkibanInformationSchema ais, Table table) {
        final Schema schema = SchemaCache.globalSchema(ais);
        PrimaryKey pkey = table.getPrimaryKeyIncludingInternal();
        final int nkeys = pkey.getColumns().size();
        IndexRowType indexType = schema.indexRowType(pkey.getIndex());

        List<TPreparedExpression> pexprs = new ArrayList<>(nkeys);
        for (int i = 0; i < nkeys; i++) {
            pexprs.add(new TPreparedParameter(i, indexType.typeAt(i)));
        }
        IndexBound bound =
            new IndexBound(new RowBasedUnboundExpressions(indexType, pexprs),
                           new ColumnSelector() {
                               @Override
                               public boolean includesColumn(int columnPosition) {
                                   return columnPosition < nkeys;
                               }
                           });
        IndexKeyRange indexRange = IndexKeyRange.bounded(indexType,
                                                         bound, true,
                                                         bound, true);

        Ordering ordering = API.ordering();
        for (int i = 0; i < nkeys; i++) {
            ordering.append(new TPreparedField(indexType.typeAt(i), i),
                            false);
        }

        return API.indexScan_Default(indexType, indexRange, ordering);
    }
View Full Code Here

    private IndexCursorSpatial_NearPoint(QueryContext context, IterationHelper iterationHelper, IndexKeyRange keyRange)
    {
        super(context, iterationHelper);
        assert keyRange.spatial();
        this.iterationHelper = iterationHelper;
        IndexRowType physicalIndexRowType = keyRange.indexRowType().physicalRowType();
        Index index = keyRange.indexRowType().index();
        Space space = index.space();
        int latColumn = index.firstSpatialArgument();
        int lonColumn = latColumn + 1;
        // The index column selector needs to select all the columns before the z column, and the z column itself.
        IndexRowPrefixSelector indexColumnSelector = new IndexRowPrefixSelector(latColumn + 1);
        IndexBound loBound = keyRange.lo();
        ValueRecord loExpressions = loBound.boundExpressions(context, bindings);
        // Compute z-value at beginning of forward and backward scans
        TInstance latInstance = index.getAllColumns().get(latColumn).getColumn().getType();
        TInstance lonInstance = index.getAllColumns().get(lonColumn).getColumn().getType();
        BigDecimal lat = TBigDecimal.getWrapper(loExpressions.value(latColumn), latInstance).asBigDecimal();
        BigDecimal lon = TBigDecimal.getWrapper(loExpressions.value(lonColumn), lonInstance).asBigDecimal();
        zStart = Spatial.shuffle(space, lat.doubleValue(), lon.doubleValue());
        // Cursors going forward from starting z value (inclusive), and backward from the same z value (exclusive)
        int indexRowFields = physicalIndexRowType.nFields();
        SpatialIndexValueRecord zForwardRow = new SpatialIndexValueRecord(indexRowFields);
        SpatialIndexValueRecord zBackwardRow = new SpatialIndexValueRecord(indexRowFields);
        SpatialIndexValueRecord zMaxRow = new SpatialIndexValueRecord(indexRowFields);
        SpatialIndexValueRecord zMinRow = new SpatialIndexValueRecord(indexRowFields);
        IndexBound zForward = new IndexBound(zForwardRow, indexColumnSelector);
        IndexBound zBackward = new IndexBound(zBackwardRow, indexColumnSelector);
        IndexBound zMax = new IndexBound(zMaxRow, indexColumnSelector);
        IndexBound zMin = new IndexBound(zMinRow, indexColumnSelector);
        // Take care of any equality restrictions before the spatial fields
        zPosition = latColumn;
        for (int f = 0; f < zPosition; f++) {
            ValueSource eqValueSource = loExpressions.value(f);
            zForwardRow.value(f, eqValueSource);
            zBackwardRow.value(f, eqValueSource);
            zMaxRow.value(f, eqValueSource);
            zMinRow.value(f, eqValueSource);
        }
        // Z-value part of bounds
        Value startValue = new Value(InternalIndexTypes.LONG.instance(false));
        Value maxValue = new Value(InternalIndexTypes.LONG.instance(false));
        Value minValue = new Value(InternalIndexTypes.LONG.instance(false));
        startValue.putInt64(zStart);
        maxValue.putInt64(Long.MAX_VALUE);
        minValue.putInt64(Long.MIN_VALUE);
        zForwardRow.value(zPosition, startValue);
        zBackwardRow.value(zPosition, startValue);
        zMaxRow.value(zPosition, maxValue);
        zMinRow.value(zPosition, minValue);
        IndexKeyRange geKeyRange = IndexKeyRange.bounded(physicalIndexRowType, zForward, true, zMax, false);
        IndexKeyRange ltKeyRange = IndexKeyRange.bounded(physicalIndexRowType, zMin, false, zBackward, false);
        IterationHelper geRowState = adapter.createIterationHelper(keyRange.indexRowType());
        IterationHelper ltRowState = adapter.createIterationHelper(keyRange.indexRowType());
        API.Ordering upOrdering = new API.Ordering();
        API.Ordering downOrdering = new API.Ordering();
        for (int f = 0; f < physicalIndexRowType.nFields(); f++) {
            // TODO: This seems like an API hack
            upOrdering.append((TPreparedExpression)null, true);
            downOrdering.append((TPreparedExpression)null, false);
        }
        geCursor = new IndexCursorUnidirectional<>(context,
View Full Code Here

        assert spatialIndex.isSpatial() : spatialIndex;
        this.space = spatialIndex.space();
        this.latColumn = spatialIndex.firstSpatialArgument();
        this.lonColumn = latColumn + 1;
        API.Ordering zOrdering = new API.Ordering();
        IndexRowType rowType = keyRange.indexRowType().physicalRowType();
        for (int f = 0; f < rowType.nFields(); f++) {
            zOrdering.append(new TPreparedField(rowType.typeAt(f), f), true);
        }
        // The index column selector needs to select all the columns before the z column, and the z column itself.
        this.indexColumnSelector = new IndexRowPrefixSelector(this.latColumn + 1);
        for (IndexKeyRange zKeyRange : zKeyRanges(context, keyRange)) {
            IterationHelper rowState = adapter.createIterationHelper(keyRange.indexRowType());
View Full Code Here

        long[] zValues = new long[box.maxZ()];
        space.decompose(box, zValues);
        for (int i = 0; i < zValues.length; i++) {
            long z = zValues[i];
            if (z != -1L) {
                IndexRowType physicalRowType = keyRange.indexRowType().physicalRowType();
                int indexRowFields = physicalRowType.nFields();
                SpatialIndexValueRecord zLoRow = new SpatialIndexValueRecord(indexRowFields);
                SpatialIndexValueRecord zHiRow = new SpatialIndexValueRecord(indexRowFields);
                IndexBound zLo = new IndexBound(zLoRow, indexColumnSelector);
                IndexBound zHi = new IndexBound(zHiRow, indexColumnSelector);
                // Take care of any equality restrictions before the spatial fields
View Full Code Here

        return IndexKeyRange.bounded(orderSalesmanIndexRowType, bound, true, bound, true);
    }

    private IndexKeyRange orderIdEQ(long oid)
    {
        IndexRowType indexRowType = indexType(order, "oid");
        IndexBound bound = new IndexBound(row(indexRowType, oid), new SetColumnSelector(0));
        return IndexKeyRange.bounded(indexRowType, bound, true, bound, true);
       
    }
View Full Code Here

        Index index = ais.getGroup(C_NAME).getIndex("c1_o1_o2");
        assertNotNull("Index still exists", index);
        assertEquals("Index column count", 2, index.getKeyColumns().size());

        Schema schema = SchemaCache.globalSchema(ddl().getAIS(session()));
        IndexRowType indexRowType = schema.indexRowType(index);

        StoreAdapter adapter = newStoreAdapter(schema);
        QueryContext queryContext = new SimpleQueryContext(adapter);
        QueryBindings queryBindings = queryContext.createBindings();
        compareRows(
View Full Code Here

TOP

Related Classes of com.foundationdb.qp.rowtype.IndexRowType

Copyright © 2018 www.massapicom. 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.