Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Table


        assert (table != null);
        return table.rowDef();
    }

    protected RowDef getIndexStatsEntryRowDef(Session session) {
        Table table = store.getAIS(session).getTable(INDEX_STATISTICS_ENTRY_TABLE_NAME);
        assert (table != null);
        return table.rowDef();
    }
View Full Code Here


    public void getEntities(PrintWriter writer, TableName tableName, Integer depth, String identifiers) {
        int realDepth = (depth != null) ? Math.max(depth, 0) : -1;
        ENTITY_GET.in();
        try (Session session = sessionService.createSession();
             CloseableTransaction txn = transactionService.beginCloseableTransaction(session)) {
            Table table = dxlService.ddlFunctions().getTable(session, tableName);
            Index pkIndex = table.getPrimaryKeyIncludingInternal().getIndex();
            List<List<Object>> pks = PrimaryKeyParser.parsePrimaryKeys(identifiers, pkIndex);
            extDataService.dumpBranchAsJson(session,
                    writer,
                    tableName.getSchemaName(),
                    tableName.getTableName(),
View Full Code Here

        // Initialize the HKey being constructed
        hKeyOut.clear();
        PersistitKeyAppender hKeyAppender = PersistitKeyAppender.create(hKeyOut, rowDef.table().getName());

        // Metadata for the row's table
        Table table = rowDef.table();

        // Only set if parent row is looked up
        int i2hPosition = 0;
        IndexToHKey indexToHKey = null;
        SDType parentStoreData = null;
        IndexRow parentPKIndexRow = null;

        // All columns of all segments of the HKey
        for(HKeySegment hKeySegment : table.hKey().segments()) {
            // Ordinal for this segment
            RowDef segmentRowDef = hKeySegment.table().rowDef();
            hKeyAppender.append(segmentRowDef.table().getOrdinal());
            // Segment's columns
            for(HKeyColumn hKeyColumn : hKeySegment.columns()) {
                Table hKeyColumnTable = hKeyColumn.column().getTable();
                if(hKeyColumnTable != table) {
                    // HKey column from row of parent table
                    if (parentStoreData == null) {
                        // Initialize parent metadata and state
                        RowDef parentRowDef = rowDef.table().getParentTable().rowDef();
View Full Code Here

        sb.append(')');
        return sb.toString();
    }

    private static BitSet hKeyDependentTableOrdinals(RowDef rowDef) {
        Table table = rowDef.table();
        BitSet ordinals = new BitSet();
        for (Table hKeyDependentTable : table.hKeyDependentTables()) {
            int ordinal = hKeyDependentTable.getOrdinal();
            ordinals.set(ordinal, true);
        }
        return ordinals;
    }
View Full Code Here

    }

    /** Delicate: Added to support GroupIndex building which only deals with FlattenedRows containing AbstractRows. */
    protected void lock(Session session, Row row) {
        RowData rowData = ((AbstractRow)row).rowData();
        Table table = row.rowType().table();
        SDType storeData = createStoreData(session, table.getGroup());
        try {
            lock(session, storeData, table.rowDef(), rowData);
        } finally {
            releaseStoreData(session, storeData);
        }
    }
View Full Code Here

    // For use by this class

    private static Table commonAncestor(Table inputTable, Table outputTable)
    {
        int minLevel = min(inputTable.getDepth(), outputTable.getDepth());
        Table inputAncestor = inputTable;
        while (inputAncestor.getDepth() > minLevel) {
            inputAncestor = inputAncestor.getParentTable();
        }
        Table outputAncestor = outputTable;
        while (outputAncestor.getDepth() > minLevel) {
            outputAncestor = outputAncestor.getParentTable();
        }
        while (inputAncestor != outputAncestor) {
            inputAncestor = inputAncestor.getParentTable();
            outputAncestor = outputAncestor.getParentTable();
        }
        return outputAncestor;
    }
View Full Code Here

    @Override
    public void createTable(Session session, Table table)
    {
        TableName tableName = schemaManager().createTableDefinition(session, table);
        Table newTable = getAIS(session).getTable(tableName);
        for(TableListener listener : listenerService.getTableListeners()) {
            listener.onCreate(session, newTable);
        }
    }
View Full Code Here

                txnService.run(session, new Runnable() {
                    @Override
                    public void run() {
                        AkibanInformationSchema onlineAIS = schemaManager().getOnlineAIS(session);
                        final Table onlineTable = onlineAIS.getTable(table.getName());
                        for (TableListener listener : listenerService.getTableListeners()) {
                            listener.onCreate(session, onlineTable);
                        }
                    }
                });
View Full Code Here

    }

    private void dropTableInternal(Session session, TableName tableName) {
        logger.trace("dropping table {}", tableName);

        Table table = getAIS(session).getTable(tableName);
        if(table == null) {
            return;
        }

        // May only drop leaf tables through DDL interface
        if(!table.getChildJoins().isEmpty()) {
            throw new UnsupportedDropException(table.getName());
        }

        DMLFunctions dml = new BasicDMLFunctions(schemaManager(), store(), listenerService);
        if(table.isRoot()) {
            // Root table and no child tables, can delete all associated trees
            store().removeTrees(session, table);
        } else {
            dml.truncateTable(session, table.getTableId(), false);
            store().deleteIndexes(session, table.getIndexesIncludingInternal());
            store().deleteIndexes(session, table.getGroupIndexes());

            if (table.getIdentityColumn() != null) {
                Collection<Sequence> sequences = Collections.singleton(table.getIdentityColumn().getIdentityGenerator());
                store().deleteSequences(session, sequences);
            }
        }
        for(TableListener listener : listenerService.getTableListeners()) {
            listener.onDrop(session, table);
View Full Code Here

        onlineAt(OnlineDDLMonitor.Stage.PRE_METADATA);
        final AISValidatorPair pair = txnService.run(session, new Callable<AISValidatorPair>() {
            @Override
            public AISValidatorPair call() {
                AkibanInformationSchema origAIS = getAIS(session);
                Table origTable = origAIS.getTable(tableName);
                schemaManager().startOnline(session);
                TableChangeValidator validator = alterTableDefinitions(
                    session, origTable, newDefinition, columnChanges, tableIndexChanges
                );
                List<ChangeSet> changeSets = buildChangeSets(
                    origAIS,
                    schemaManager().getOnlineAIS(session),
                    origTable.getTableId(),
                    validator
                );
                for(ChangeSet cs : changeSets) {
                    schemaManager().addOnlineChangeSet(session, cs);
                }
                return new AISValidatorPair(origAIS, validator);
            }
        });
        onlineAt(OnlineDDLMonitor.Stage.POST_METADATA);

        final String errorMsg;
        final boolean[] success = { false };
        try {
            onlineAt(OnlineDDLMonitor.Stage.PRE_TRANSFORM);
            alterTablePerform(session, tableName, pair.validator.getFinalChangeLevel(), context);
            onlineAt(OnlineDDLMonitor.Stage.POST_TRANSFORM);
            success[0] = true;
        } finally {
            onlineAt(OnlineDDLMonitor.Stage.PRE_FINAL);
            errorMsg = txnService.run(session, new Callable<String>() {
                @Override
                public String call() {
                    String error = schemaManager().getOnlineDMLError(session);
                    if(success[0] && (error == null)) {
                        finishOnlineChange(session);
                    } else {
                        discardOnlineChange(session);
                    }
                    return error;
                }
            });
            onlineAt(OnlineDDLMonitor.Stage.POST_FINAL);
        }
        if(errorMsg != null) {
            throw new ConcurrentViolationException(errorMsg);
        }

        // Clear old storage after it is completely unused
        txnService.run(session, new Runnable() {
            @Override
            public void run() {
                Table origTable = pair.ais.getTable(tableName);
                Table newTable = getTable(session, origTable.getTableId());
                alterTableRemoveOldStorage(session, origTable, newTable, pair.validator);
            }
        });

        return pair.validator.getFinalChangeLevel();
View Full Code Here

TOP

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

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.