Search in sources :

Example 1 with BitMap

use of org.hsqldb_voltpatches.store.BitMap in project voltdb by VoltDB.

the class Scanner method convertToBit.

public synchronized BinaryData convertToBit(String s) {
    BitMap map = new BitMap(32);
    int bitIndex = map.size();
    reset(s);
    resetState();
    byteOutputStream.reset(byteBuffer);
    for (; currentPosition < limit; currentPosition++) {
        int c = sqlString.charAt(currentPosition);
        if (c == '0') {
            bitIndex++;
        } else if (c == '1') {
            map.set(bitIndex);
            bitIndex++;
        } else {
            token.tokenType = Tokens.X_MALFORMED_BIT_STRING;
            token.isMalformed = true;
            throw Error.error(ErrorCode.X_22018);
        }
    }
    map.setSize(bitIndex);
    return new BinaryData(map.getBytes(), map.size());
}
Also used : BitMap(org.hsqldb_voltpatches.store.BitMap) BinaryData(org.hsqldb_voltpatches.types.BinaryData)

Example 2 with BitMap

use of org.hsqldb_voltpatches.store.BitMap in project voltdb by VoltDB.

the class StringConverter method sqlBitStringToBitMap.

/**
     * Compacts a bit string into a BitMap
     *
     *
     * @param s bit string
     *
     * @return byte array for the hex string
     * @throws IOException
     */
public static BitMap sqlBitStringToBitMap(String s) throws IOException {
    int l = s.length();
    int n;
    int bitIndex = 0;
    BitMap map = new BitMap(l);
    for (int j = 0; j < l; j++) {
        char c = s.charAt(j);
        if (c == ' ') {
            continue;
        }
        n = getNibble(c);
        if (n != 0 && n != 1) {
            throw new IOException(//NOI18N
            "hexadecimal string contains non hex character");
        }
        if (n == 1) {
            map.set(bitIndex);
        }
        bitIndex++;
    }
    map.setSize(bitIndex);
    return map;
}
Also used : BitMap(org.hsqldb_voltpatches.store.BitMap) IOException(java.io.IOException)

Example 3 with BitMap

use of org.hsqldb_voltpatches.store.BitMap in project voltdb by VoltDB.

the class ParserDQL method readColumnNames.

HsqlName[] readColumnNames(HsqlName tableName) {
    BitMap quotedFlags = new BitMap(32);
    OrderedHashSet set = readColumnNames(quotedFlags, false);
    HsqlName[] colList = new HsqlName[set.size()];
    for (int i = 0; i < colList.length; i++) {
        String name = (String) set.get(i);
        boolean quoted = quotedFlags.isSet(i);
        colList[i] = database.nameManager.newHsqlName(tableName.schema, name, quoted, SchemaObject.COLUMN, tableName);
    }
    return colList;
}
Also used : BitMap(org.hsqldb_voltpatches.store.BitMap) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 4 with BitMap

use of org.hsqldb_voltpatches.store.BitMap in project voltdb by VoltDB.

the class ParserDQL method readTableOrSubquery.

/**
     * Creates a RangeVariable from the parse context. <p>
     */
protected RangeVariable readTableOrSubquery() {
    Table table = null;
    SimpleName alias = null;
    OrderedHashSet columnList = null;
    BitMap columnNameQuoted = null;
    SimpleName[] columnNameList = null;
    if (token.tokenType == Tokens.OPENBRACKET) {
        Expression e = XreadTableSubqueryOrJoinedTable();
        table = e.subQuery.getTable();
        if (table instanceof TableDerived) {
            ((TableDerived) table).dataExpression = e;
        }
    } else {
        table = readTableName();
        if (table.isView()) {
            SubQuery sq = getViewSubquery((View) table);
            //                sq.queryExpression = ((View) table).queryExpression;
            table = sq.getTable();
        }
    }
    boolean hasAs = false;
    if (token.tokenType == Tokens.AS) {
        read();
        checkIsNonCoreReservedIdentifier();
        hasAs = true;
    }
    if (isNonCoreReservedIdentifier()) {
        boolean limit = token.tokenType == Tokens.LIMIT || token.tokenType == Tokens.OFFSET;
        int position = getPosition();
        alias = HsqlNameManager.getSimpleName(token.tokenString, isDelimitedIdentifier());
        read();
        if (token.tokenType == Tokens.OPENBRACKET) {
            columnNameQuoted = new BitMap(32);
            columnList = readColumnNames(columnNameQuoted, false);
        } else if (!hasAs && limit) {
            if (token.tokenType == Tokens.QUESTION || token.tokenType == Tokens.X_VALUE) {
                alias = null;
                rewind(position);
            }
        }
    }
    if (columnList != null) {
        if (table.getColumnCount() != columnList.size()) {
            throw Error.error(ErrorCode.X_42593);
        }
        columnNameList = new SimpleName[columnList.size()];
        for (int i = 0; i < columnList.size(); i++) {
            SimpleName name = HsqlNameManager.getSimpleName((String) columnList.get(i), columnNameQuoted.isSet(i));
            columnNameList[i] = name;
        }
    }
    RangeVariable range = new RangeVariable(table, alias, columnList, columnNameList, compileContext);
    return range;
}
Also used : BitMap(org.hsqldb_voltpatches.store.BitMap) SimpleName(org.hsqldb_voltpatches.HsqlNameManager.SimpleName) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet)

Example 5 with BitMap

use of org.hsqldb_voltpatches.store.BitMap in project voltdb by VoltDB.

the class Scanner method scanBitString.

void scanBitString() {
    BitMap map = new BitMap(32);
    while (true) {
        scanBitStringPart(map);
        if (token.isMalformed) {
            return;
        }
        if (scanSeparator() && charAt(currentPosition) == '\'') {
            continue;
        }
        break;
    }
    token.tokenValue = new BinaryData(map.getBytes(), map.size());
}
Also used : BitMap(org.hsqldb_voltpatches.store.BitMap) BinaryData(org.hsqldb_voltpatches.types.BinaryData)

Aggregations

BitMap (org.hsqldb_voltpatches.store.BitMap)5 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)2 BinaryData (org.hsqldb_voltpatches.types.BinaryData)2 IOException (java.io.IOException)1 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)1 SimpleName (org.hsqldb_voltpatches.HsqlNameManager.SimpleName)1