Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Sequence


            }

            @Override
            public Row next() {
                while(it.hasNext()) {
                    Sequence sequence = it.next();
                    if(isAccessible(session, sequence.getSequenceName()) &&
                            !sequence.isInternalSequence()) {
                        return new ValuesRow(rowType,
                                             null,      //sequence catalog
                                             sequence.getSequenceName().getSchemaName(),
                                             sequence.getSequenceName().getTableName(),
                                             datatype,
                                             sequence.getStartsWith(),
                                             sequence.getMinValue(),
                                             sequence.getMaxValue(),
                                             sequence.getIncrement(),
                                             boolResult(sequence.isCycle()),
                                             sequence.getStorageNameString(),
                                             ++rowCounter);
                    }
                }
                return null;
            }
View Full Code Here


            TInstance columnType = column.getType();
            String functionName;
            List<TPreptimeValue> input;
            List<TPreparedExpression> arguments;
            if (column.getIdentityGenerator() != null) {
                Sequence sequence = column.getIdentityGenerator();
                TableName sequenceName = sequence.getSequenceName();
                functionName = "NEXTVAL";
                input = new ArrayList<>(2);
                input.add(ValueSources.fromObject(sequenceName.getSchemaName(), typesTranslator.typeForString(sequenceName.getSchemaName())));
                input.add(ValueSources.fromObject(sequenceName.getTableName(), typesTranslator.typeForString(sequenceName.getTableName())));
                arguments = new ArrayList<>(input.size());
View Full Code Here

        if (idColumn != null) {
            FieldDef fieldDef = idColumn.getFieldDef();
            Boolean defaultIdentity = idColumn.getDefaultIdentity();
            if (defaultIdentity == false ||
                    (defaultIdentity == true && row.isColumnNull(fieldDef.getFieldIndex()))) {
                Sequence sequence = idColumn.getIdentityGenerator();
                Long value = this.nextSequenceValue(session, sequence);
                row.put(fieldDef.getFieldIndex(), value);
            }
        }
    }
View Full Code Here

    @Override
    public void alterSequence(Session session, TableName sequenceName, Sequence newDefinition)
    {
        logger.trace("altering sequence {}", sequenceName);
        AkibanInformationSchema ais = getAIS(session);
        Sequence oldSeq = ais.getSequence(sequenceName);
        if(oldSeq == null) {
            throw new NoSuchSequenceException(sequenceName);
        }
        schemaManager().alterSequence(session, sequenceName, newDefinition);
        // Remove old storage
View Full Code Here

    public void createSequence(Session session, Sequence sequence) {
        schemaManager().createSequence(session, sequence);
    }
  
    public void dropSequence(Session session, TableName sequenceName) {
        final Sequence sequence = getAIS(session).getSequence(sequenceName);
       
        if (sequence == null) {
            throw new NoSuchSequenceException (sequenceName);
        }

        for (Table table : getAIS(session).getTables().values()) {
            if (table.getIdentityColumn() != null && table.getIdentityColumn().getIdentityGenerator().equals(sequence)) {
                throw new DropSequenceNotAllowedException(sequence.getSequenceName().getTableName(), table.getName());
            }
        }
        store().deleteSequences(session, Collections.singleton(sequence));
        schemaManager().dropSequence(session, sequence);
    }
View Full Code Here

    }

    @Override
    public void alterSequence(Session session, TableName sequenceName, Sequence newDefinition) {
        AkibanInformationSchema oldAIS = getAISForChange(session);
        Sequence oldSequence = oldAIS.getSequence(sequenceName);
        if(oldSequence == null) {
            throw new NoSuchSequenceException(sequenceName);
        }

        if(!sequenceName.equals(newDefinition.getSequenceName())) {
            throw new UnsupportedOperationException("Renaming Sequence");
        }

        AkibanInformationSchema newAIS = aisCloner.clone(oldAIS);
        newAIS.removeSequence(sequenceName);
        Sequence newSequence = Sequence.create(newAIS, newDefinition);
        storageFormatRegistry.finishStorageDescription(newSequence, getNameGenerator(session));

        // newAIS may have mixed references to sequenceName. Re-clone to resolve.
        newAIS = aisCloner.clone(newAIS);
View Full Code Here

        assert tableType.hasTable() : tableType;
        return tableType.table().rowDef().getTableStatus().getRowCount(session);
    }

    public Sequence getSequence(TableName sequenceName) {
        Sequence sequence = schema().ais().getSequence(sequenceName);
        if(sequence == null) {
            throw new NoSuchSequenceException(sequenceName);
        }
        return sequence;
    }
View Full Code Here

                    } else {
                        // Special case: The only requested change is RESTART WITH.
                        // Cannot go through the current ALTER flow as the new value may appear to be the same,
                        // triggering NONE change, but should still take affect as values may have been allocated.
                        if((elements.size() == 1) && isRestartWithNode(modNode)) {
                            Sequence curSeq = column.getIdentityGenerator();
                            if(curSeq == null) {
                                throw new ColumnNotGeneratedException(column);
                            }
                            AkibanInformationSchema aisCopy = new AkibanInformationSchema();
                            Sequence newSeq = Sequence.create(aisCopy,
                                                              curSeq.getSchemaName(),
                                                              curSeq.getSequenceName().getTableName(),
                                                              modNode.getAutoincrementStart(),
                                                              curSeq.getIncrement(),
                                                              curSeq.getMinValue(),
View Full Code Here

                        default:
                            throw new IllegalStateException("Unknown autoIncType: " + autoIncType);
                    }
                } else {
                    // DROP DEFAULT will come though as a NULL default, clears both GENERATED and DEFAULT
                    Sequence seq = column.getIdentityGenerator();
                    if(seq != null) {
                        column.setDefaultIdentity(null);
                        column.setIdentityGenerator(null);
                        aisCopy.removeSequence(seq.getSequenceName());
                    }
                    String[] defaultValueFunction = TableDDL.getColumnDefault(modNode, tableCopy.getName().getSchemaName(), tableCopy.getName().getTableName());
                    column.setDefaultValue(defaultValueFunction[0]);
                    column.setDefaultFunction(defaultValueFunction[1]);
                }
View Full Code Here

            }
            // else keep long max
        }
        AISBuilder builder = new AISBuilder();
        builder.sequence(seqName.getSchemaName(), seqName.getTableName(), startWith, incBy, minValue, maxValue, isCycle);
        Sequence sequence = builder.akibanInformationSchema().getSequence(seqName);
        if (node.getStorageFormat() != null) {
            TableDDL.setStorage(ddlFunctions, sequence, node.getStorageFormat());
        }
        ddlFunctions.createSequence(session, sequence);
    }
View Full Code Here

TOP

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

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.