Search in sources :

Example 76 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class ValueHashMap method remove.

/**
 * Remove a key value pair.
 *
 * @param key the key
 */
public void remove(Value key) {
    checkSizeRemove();
    int index = getIndex(key);
    int plus = 1;
    do {
        Value k = keys[index];
        if (k == null) {
            // found an empty record
            return;
        } else if (k == ValueNull.DELETED) {
        // found a deleted record
        } else if (k.equals(key)) {
            // found the record
            keys[index] = ValueNull.DELETED;
            values[index] = null;
            deletedCount++;
            size--;
            return;
        }
        index = (index + plus++) & mask;
    } while (plus <= len);
// not found
}
Also used : Value(com.wplatform.ddal.value.Value)

Example 77 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class ValueHashMap method get.

/**
 * Get the value for this key. This method returns null if the key was not
 * found.
 *
 * @param key the key
 * @return the value for the given key
 */
public V get(Value key) {
    int index = getIndex(key);
    int plus = 1;
    do {
        Value k = keys[index];
        if (k == null) {
            // found an empty record
            return null;
        } else if (k == ValueNull.DELETED) {
        // found a deleted record
        } else if (k.equals(key)) {
            // found it
            return values[index];
        }
        index = (index + plus++) & mask;
    } while (plus <= len);
    return null;
}
Also used : Value(com.wplatform.ddal.value.Value)

Example 78 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class ValueHashMap method values.

/**
 * Get the list of values.
 *
 * @return all values
 */
public ArrayList<V> values() {
    ArrayList<V> list = New.arrayList(size);
    int len = keys.length;
    for (int i = 0; i < len; i++) {
        Value k = keys[i];
        if (k != null && k != ValueNull.DELETED) {
            list.add(values[i]);
        }
    }
    return list;
}
Also used : Value(com.wplatform.ddal.value.Value)

Example 79 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class JdbcConnection method createBlob.

/**
 * Create a new empty Blob object.
 *
 * @return the object
 */
@Override
public Blob createBlob() throws SQLException {
    try {
        int id = getNextId(TraceObject.BLOB);
        debugCodeAssign("Blob", TraceObject.BLOB, id, "createClob()");
        checkClosedForWrite();
        try {
            Value v = ValueLobDb.createTempBlob(new ByteArrayInputStream(Utils.EMPTY_BYTES), 0);
            session.addTemporaryLob(v);
            return new JdbcBlob(this, v, id);
        } finally {
            afterWriting();
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Value(com.wplatform.ddal.value.Value) Savepoint(java.sql.Savepoint) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) DbException(com.wplatform.ddal.message.DbException)

Example 80 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class Trace method formatParams.

/**
 * Format the parameter list.
 *
 * @param parameters the parameter list
 * @return the formatted text
 */
public static String formatParams(ArrayList<? extends ParameterInterface> parameters) {
    if (parameters.size() == 0) {
        return "";
    }
    StatementBuilder buff = new StatementBuilder();
    int i = 0;
    boolean params = false;
    for (ParameterInterface p : parameters) {
        if (p.isValueSet()) {
            if (!params) {
                buff.append(" {");
                params = true;
            }
            buff.appendExceptFirst(", ");
            Value v = p.getParamValue();
            buff.append(++i).append(": ").append(v.getTraceSQL());
        }
    }
    if (params) {
        buff.append('}');
    }
    return buff.toString();
}
Also used : ParameterInterface(com.wplatform.ddal.command.expression.ParameterInterface) StatementBuilder(com.wplatform.ddal.util.StatementBuilder) Value(com.wplatform.ddal.value.Value)

Aggregations

Value (com.wplatform.ddal.value.Value)84 Expression (com.wplatform.ddal.command.expression.Expression)14 Column (com.wplatform.ddal.dbobject.table.Column)14 StatementBuilder (com.wplatform.ddal.util.StatementBuilder)13 DbException (com.wplatform.ddal.message.DbException)9 SQLException (java.sql.SQLException)8 Row (com.wplatform.ddal.result.Row)7 SearchRow (com.wplatform.ddal.result.SearchRow)7 PreparedStatement (java.sql.PreparedStatement)7 TableMate (com.wplatform.ddal.dbobject.table.TableMate)6 LocalResult (com.wplatform.ddal.result.LocalResult)6 ResultInterface (com.wplatform.ddal.result.ResultInterface)5 Connection (java.sql.Connection)5 Parameter (com.wplatform.ddal.command.expression.Parameter)4 List (java.util.List)4 DataSource (javax.sql.DataSource)4 Query (com.wplatform.ddal.command.dml.Query)3 TableFilter (com.wplatform.ddal.dbobject.table.TableFilter)3 TableNode (com.wplatform.ddal.dispatch.rule.TableNode)3 JdbcWorker (com.wplatform.ddal.excutor.JdbcWorker)3