Search in sources :

Example 61 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class CacheLock method saveProperty.

void saveProperty(TransactionController tc, String key, Serializable value) throws StandardException {
    if (saveServiceProperty(key, value))
        return;
    // Do a scan to see if the property already exists in the Conglomerate.
    ScanController scan = this.openScan(tc, key, TransactionController.OPENMODE_FORUPDATE);
    DataValueDescriptor[] row = makeNewTemplate();
    if (scan.fetchNext(row)) {
        if (value == null) {
            // A null input value means that we should delete the row
            scan.delete();
        } else {
            // a value already exists, just replace the second columm
            row[1] = new UserType(value);
            scan.replace(row, (FormatableBitSet) null);
        }
        scan.close();
    } else {
        // The value does not exist in the Conglomerate.
        scan.close();
        scan = null;
        if (value != null) {
            // not a delete request, so insert the new property.
            row = makeNewTemplate(key, value);
            ConglomerateController cc = tc.openConglomerate(propertiesConglomId, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
            cc.insert(row);
            cc.close();
        }
    }
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Aggregations

ScanController (org.apache.derby.iapi.store.access.ScanController)61 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 RowLocation (org.apache.derby.iapi.types.RowLocation)29 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)22 SQLLongint (org.apache.derby.iapi.types.SQLLongint)20 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)9 StandardException (org.apache.derby.shared.common.error.StandardException)9 TransactionController (org.apache.derby.iapi.store.access.TransactionController)8 Properties (java.util.Properties)7 GroupFetchScanController (org.apache.derby.iapi.store.access.GroupFetchScanController)7 SQLChar (org.apache.derby.iapi.types.SQLChar)6 UUID (org.apache.derby.catalog.UUID)5 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)5 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)5 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)4 HashSet (java.util.HashSet)3 Hashtable (java.util.Hashtable)3 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)3