Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Join


        List<Table> implicitlyDroppedTables = new ArrayList<>();

        for(Table table : schema.getTables().values()) {
            groupsToDrop.add(table.getGroup());
            // Cannot drop entire group if parent is not in the same schema
            final Join parentJoin = table.getParentJoin();
            if(parentJoin != null) {
                final Table parentTable = parentJoin.getParent();
                if(!parentTable.getName().getSchemaName().equals(schemaName)) {
                    explicitlyDroppedTables.add(table);
                } else {
                    implicitlyDroppedTables.add(table);
                }
View Full Code Here


        }
       
        for(FKConstraintDefinitionNode fk : fkDefNodes) {
            if(fk.isGrouping()) {
                if(fk.getConstraintType() == ConstraintType.DROP) {
                    Join parentJoin = tableCopy.getParentJoin();
                    tableCopy.setGroup(null);
                    tableCopy.removeCandidateParentJoin(parentJoin);
                    parentJoin.getParent().removeCandidateChildJoin(parentJoin);
                } else {
                    if(origTable.getParentJoin() != null) {
                        throw new JoinToMultipleParentsException(origTable.getName());
                    }
                    tableCopy.setGroup(null);
View Full Code Here

     private void runInsert(ProcessContext context, AkibanAppender appender) {
        assert context != null : "Bad Json format";
        LOG.trace("Insert row into: {}, values {}", context.tableName, context.queryContext);
        // Fill in parent columns if this is a child table
        if(context.pkValues != null && context.table.getParentJoin() != null) {
            Join join = context.table.getParentJoin();
            for (Entry<Column, ValueSource> entry : context.pkValues.entrySet()) {
                Column parentCol = entry.getKey();
                Column childCol = join.getMatchingChild(parentCol);
                String fkValue = valueToString(entry.getValue());
                String curValue = context.allValues.get(childCol);
                if(curValue == null) {
                    context.allValues.put(childCol, fkValue);
                } else if(!fkValue.equals(curValue)) {
                    throw new FKValueMismatchException(join.getMatchingChild(entry.getKey()).getName());
                }
            }
        }
        Operator insert = insertGenerator.create(context.allValues, context.table.getName());
        Cursor cursor = API.cursor(insert, context.queryContext, context.queryBindings);
View Full Code Here

    protected TableGroupJoin findParentJoin(TableSource childTable,
                                            ConditionList conditions,
                                            EquivalenceFinder<ColumnExpression> columnEquivs) {
        if ((conditions == null) || conditions.isEmpty()) return null;
        TableNode childNode = childTable.getTable();
        Join groupJoin = childNode.getTable().getParentJoin();
        if (groupJoin == null) return null;
        TableNode parentNode = childNode.getTree().getNode(groupJoin.getParent());
        if (parentNode == null) return null;
        List<JoinColumn> joinColumns = groupJoin.getJoinColumns();
        int ncols = joinColumns.size();
        Map<TableSource,GroupJoinConditions> parentTables = new HashMap<>();

        for (int i = 0; i < ncols; ++i) {
            if (!findGroupCondition(joinColumns, i, childTable, conditions, true, parentTables, columnEquivs)) {
                if (!findGroupCondition(joinColumns, i, childTable, conditions, false, parentTables, columnEquivs)) {
                    return null; // join column had no direct or equivalent group joins, so we know the answer
                }
            }
        }
       
        TableSource parentTable = null;
        GroupJoinConditions groupJoinConditions = null;
        for (Map.Entry<TableSource,GroupJoinConditions> entry : parentTables.entrySet()) {
            boolean found = true;
            for (ComparisonCondition elem : entry.getValue().getConditions()) {
                if (elem == null) {
                    found = false;
                    break;
                }
            }
            if (found) {
                if (parentTable == null) {
                    parentTable = entry.getKey();
                    groupJoinConditions = entry.getValue();
                }
                else {
                    // TODO: What we need is something
                    // earlier to decide that the primary
                    // keys are equated and so share the
                    // references somehow.
                    ConditionExpression c1 = groupJoinConditions.getConditions().get(0);
                    ConditionExpression c2 = entry.getValue().getConditions().get(0);
                    if (conditions.indexOf(c1) > conditions.indexOf(c2)) {
                        // Make the order predictable for tests.
                        ConditionExpression temp = c1;
                        c1 = c2;
                        c2 = temp;
                    }
                    throw new UnsupportedSQLException("Found two possible parent joins",
                                                      c2.getSQLsource());
                }
            }
        }
        if (parentTable == null) return null;
        TableGroup group = parentTable.getGroup();
        if (group == null) {
            group = childTable.getGroup();
            if (group == null)
                group = new TableGroup(groupJoin.getGroup());
        }
        else if (childTable.getGroup() != null) {
            group.merge(childTable.getGroup());
        }
        if (!tableAllowedInGroup(group, childTable))
View Full Code Here

                        updateColumns.add(updateColumn.getColumn());
                    }
                    for (Column pkColumn : targetTable.getTable().getPrimaryKeyIncludingInternal().getColumns()) {
                        vulnerableColumns.add(pkColumn);
                    }
                    Join parentJoin = targetTable.getTable().getParentJoin();
                    if (parentJoin != null) {
                        for (JoinColumn joinColumn : parentJoin.getJoinColumns()) {
                            vulnerableColumns.add(joinColumn.getChild());
                        }
                    }
                    for (Column column : vulnerableColumns) {
                        if (updateColumns.contains(column)) {
View Full Code Here

                sb.append(first ? "" : ',').append(indexColumn.getColumn().getName());
                first = false;
            }
            sb.append(')');
        }
        Join join = table.getParentJoin();
        if(join != null) {
            sb.append(", join(");
            first = true;
            for(JoinColumn joinColumn : join.getJoinColumns()) {
                sb.append(first ? "" : ", ").append(joinColumn.getChild().getName()).append("->").append(joinColumn.getParent().getName());
                first = false;
            }
            sb.append(")");
        }
View Full Code Here

    private RowDef createTableRowDef(Table table) {
        RowDef rowDef = createRowDefCommon(table, table.hasMemoryTableFactory() ? MemoryAdapter.getMemoryTableFactory(table) : null);
        // parentRowDef
        int[] parentJoinFields;
        if (table.getParentJoin() != null) {
            final Join join = table.getParentJoin();
            parentJoinFields = new int[join.getJoinColumns().size()];
            for (int index = 0; index < join.getJoinColumns().size(); index++) {
                final JoinColumn joinColumn = join.getJoinColumns().get(index);
                parentJoinFields[index] = joinColumn.getChild().getPosition();
            }
        } else {
            parentJoinFields = new int[0];
        }
View Full Code Here

        Column.create(realOrder, "odate", 2, date);
        Index orderPK = TableIndex.create(inAIS, realOrder, Index.PRIMARY, 0, true, true, new TableName(SCHEMA, "pkey"));
        IndexColumn.create(orderPK, oId, 0, true, null);
        Index akFk = TableIndex.create(inAIS, realOrder, "_fk1", 1, false, false);
        IndexColumn.create(akFk, oCid, 0, true, null);
        Join coJoin = Join.create(inAIS, "co", stubCustomer, realOrder);
        JoinColumn.create(coJoin, cId, oCid);

        final AkibanInformationSchema outAIS = writeAndRead(inAIS);
        compareAndAssert(inAIS, outAIS, false);
    }
View Full Code Here

                Table table = rpt.table;
                String constraintName = null;
                String uniqueSchema = null;
                String uniqueConstraint = null;

                Join join = table.getParentJoin();
                if (table.getParentJoin() != null) {
                    constraintName = join.getConstraintName().getTableName();
                    uniqueSchema = join.getParent().getName().getSchemaName();
                    uniqueConstraint = join.getParent().getPrimaryKey().getIndex().getConstraintName().getTableName();
                }
               
                return new ValuesRow(rowType,
                                    null,                               //root table catalog
                                     rpt.root.getName().getSchemaName(),// root_table_schema
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Join

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.