Search in sources :

Example 6 with OrderedIntHashSet

use of org.hsqldb_voltpatches.lib.OrderedIntHashSet in project voltdb by VoltDB.

the class ParserDDL method readSequenceOptions.

private void readSequenceOptions(NumberSequence sequence, boolean withType, boolean isAlter) {
    OrderedIntHashSet set = new OrderedIntHashSet();
    while (true) {
        boolean end = false;
        if (set.contains(token.tokenType)) {
            throw unexpectedToken();
        }
        switch(token.tokenType) {
            case Tokens.AS:
                {
                    if (withType) {
                        read();
                        Type type = readTypeDefinition(true);
                        sequence.setDefaults(sequence.name, type);
                        break;
                    }
                    throw unexpectedToken();
                }
            case Tokens.START:
                {
                    set.add(token.tokenType);
                    read();
                    readThis(Tokens.WITH);
                    long value = readBigint();
                    sequence.setStartValueNoCheck(value);
                    break;
                }
            case Tokens.RESTART:
                {
                    if (!isAlter) {
                        end = true;
                        break;
                    }
                    set.add(token.tokenType);
                    read();
                    if (readIfThis(Tokens.WITH)) {
                        long value = readBigint();
                        sequence.setCurrentValueNoCheck(value);
                    } else {
                        sequence.setStartValueDefault();
                    }
                    break;
                }
            case Tokens.INCREMENT:
                {
                    set.add(token.tokenType);
                    read();
                    readThis(Tokens.BY);
                    long value = readBigint();
                    sequence.setIncrement(value);
                    break;
                }
            case Tokens.NO:
                read();
                if (token.tokenType == Tokens.MAXVALUE) {
                    sequence.setDefaultMaxValue();
                } else if (token.tokenType == Tokens.MINVALUE) {
                    sequence.setDefaultMinValue();
                } else if (token.tokenType == Tokens.CYCLE) {
                    sequence.setCycle(false);
                } else {
                    throw unexpectedToken();
                }
                set.add(token.tokenType);
                read();
                break;
            case Tokens.MAXVALUE:
                {
                    set.add(token.tokenType);
                    read();
                    long value = readBigint();
                    sequence.setMaxValueNoCheck(value);
                    break;
                }
            case Tokens.MINVALUE:
                {
                    set.add(token.tokenType);
                    read();
                    long value = readBigint();
                    sequence.setMinValueNoCheck(value);
                    break;
                }
            case Tokens.CYCLE:
                set.add(token.tokenType);
                read();
                sequence.setCycle(true);
                break;
            default:
                end = true;
                break;
        }
        if (end) {
            break;
        }
    }
    sequence.checkValues();
}
Also used : Type(org.hsqldb_voltpatches.types.Type) OrderedIntHashSet(org.hsqldb_voltpatches.lib.OrderedIntHashSet)

Example 7 with OrderedIntHashSet

use of org.hsqldb_voltpatches.lib.OrderedIntHashSet in project voltdb by VoltDB.

the class StatementCompound method setHandlers.

private void setHandlers() {
    if (handlers.length == 0) {
        return;
    }
    HashSet statesSet = new HashSet();
    OrderedIntHashSet typesSet = new OrderedIntHashSet();
    for (int i = 0; i < handlers.length; i++) {
        int[] types = handlers[i].getConditionTypes();
        for (int j = 0; j < types.length; j++) {
            if (!typesSet.add(types[j])) {
                throw Error.error(ErrorCode.X_42601);
            }
        }
        String[] states = handlers[i].getConditionStates();
        for (int j = 0; j < states.length; j++) {
            if (!statesSet.add(states[j])) {
                throw Error.error(ErrorCode.X_42601);
            }
        }
    }
}
Also used : OrderedIntHashSet(org.hsqldb_voltpatches.lib.OrderedIntHashSet) OrderedIntHashSet(org.hsqldb_voltpatches.lib.OrderedIntHashSet) HashSet(org.hsqldb_voltpatches.lib.HashSet)

Aggregations

OrderedIntHashSet (org.hsqldb_voltpatches.lib.OrderedIntHashSet)7 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)3 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)2 HashSet (org.hsqldb_voltpatches.lib.HashSet)1 Type (org.hsqldb_voltpatches.types.Type)1