Search in sources :

Example 1 with SQLLongint

use of org.apache.derby.iapi.types.SQLLongint in project derby by apache.

the class SYSSEQUENCESRowFactory method makeRow.

/**
 * Make a SYSSEQUENCES row
 *
 * @param td     a sequence descriptor
 * @param parent unused
 * @return Row suitable for inserting into SYSSEQUENCES.
 * @throws org.apache.derby.shared.common.error.StandardException
 *          thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    ExecRow row;
    String oidString = null;
    String sequenceName = null;
    String schemaIdString = null;
    TypeDescriptor typeDesc = null;
    Long currentValue = null;
    long startValue = 0;
    long minimumValue = 0;
    long maximumValue = 0;
    long increment = 0;
    boolean canCycle = false;
    if (td != null) {
        SequenceDescriptor sd = (SequenceDescriptor) td;
        UUID oid = sd.getUUID();
        oidString = oid.toString();
        sequenceName = sd.getSequenceName();
        UUID schemaId = sd.getSchemaId();
        schemaIdString = schemaId.toString();
        typeDesc = sd.getDataType().getCatalogType();
        currentValue = sd.getCurrentValue();
        startValue = sd.getStartValue();
        minimumValue = sd.getMinimumValue();
        maximumValue = sd.getMaximumValue();
        increment = sd.getIncrement();
        canCycle = sd.canCycle();
    }
    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSSEQUENCES_COLUMN_COUNT);
    /* 1st column is UUID */
    row.setColumn(SYSSEQUENCES_SEQUENCEID, new SQLChar(oidString));
    /* 2nd column is SEQUENCENAME */
    row.setColumn(SYSSEQUENCES_SEQUENCENAME, new SQLVarchar(sequenceName));
    /* 3nd column is SCHEMAID */
    row.setColumn(SYSSEQUENCES_SCHEMAID, new SQLChar(schemaIdString));
    /* 4th column is SEQUENCEDATATYPE */
    row.setColumn(SYSSEQUENCES_SEQUENCEDATATYPE, new UserType(typeDesc));
    /* 5th column is CURRENTVALUE */
    SQLLongint curVal;
    if (currentValue == null) {
        curVal = new SQLLongint();
    } else {
        curVal = new SQLLongint(currentValue.longValue());
    }
    row.setColumn(SYSSEQUENCES_CURRENT_VALUE, curVal);
    /* 6th column is STARTVALUE */
    row.setColumn(SYSSEQUENCES_START_VALUE, new SQLLongint(startValue));
    /* 7th column is MINIMUMVALUE */
    row.setColumn(SYSSEQUENCES_MINIMUM_VALUE, new SQLLongint(minimumValue));
    /* 8th column is MAXIMUMVALUE */
    row.setColumn(SYSSEQUENCES_MAXIMUM_VALUE, new SQLLongint(maximumValue));
    /* 9th column is INCREMENT */
    row.setColumn(SYSSEQUENCES_INCREMENT, new SQLLongint(increment));
    /* 10th column is CYCLEOPTION */
    row.setColumn(SYSSEQUENCES_CYCLE_OPTION, new SQLChar(canCycle ? "Y" : "N"));
    return row;
}
Also used : TypeDescriptor(org.apache.derby.catalog.TypeDescriptor) DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) SQLLongint(org.apache.derby.iapi.types.SQLLongint) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) SequenceDescriptor(org.apache.derby.iapi.sql.dictionary.SequenceDescriptor) UUID(org.apache.derby.catalog.UUID) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) UserType(org.apache.derby.iapi.types.UserType)

Example 2 with SQLLongint

use of org.apache.derby.iapi.types.SQLLongint in project derby by apache.

the class ReferencedKeyRIChecker method rememberKey.

/**
 * Remember the deletion of this key, it may cause a RESTRICT
 * foreign key violation, cf. logic in @{link #postCheck}.
 * @param rememberRow
 * @throws StandardException
 */
private void rememberKey(ExecRow rememberRow) throws StandardException {
    if (deletedKeys == null) {
        // key: all columns (these are index rows, or a row containing a
        // row location)
        identityMap = new int[numColumns];
        for (int i = 0; i < numColumns; i++) {
            identityMap[i] = i;
        }
        deletedKeys = new BackingStoreHashtable(tc, null, identityMap, // remove duplicates: no need for more copies:
        true, // one is enough to know what to look for on commit
        -1, HashScanResultSet.DEFAULT_MAX_CAPACITY, HashScanResultSet.DEFAULT_INITIAL_CAPACITY, HashScanResultSet.DEFAULT_MAX_CAPACITY, false, false);
    }
    DataValueDescriptor[] row = rememberRow.getRowArray();
    for (int i = 0; i < numColumns; i++) {
        refKey[i] = row[fkInfo.colArray[i] - 1];
    }
    Object hashKey = KeyHasher.buildHashKey(refKey, identityMap);
    DataValueDescriptor[] savedRow = (DataValueDescriptor[]) deletedKeys.remove(hashKey);
    if (savedRow == null) {
        savedRow = new DataValueDescriptor[numColumns + 1];
        System.arraycopy(refKey, 0, savedRow, 0, numColumns);
        savedRow[numColumns] = new SQLLongint(1);
    } else {
        savedRow[numColumns] = new SQLLongint(((SQLLongint) savedRow[numColumns]).getLong() + 1);
    }
    deletedKeys.putRow(false, savedRow, null);
}
Also used : SQLLongint(org.apache.derby.iapi.types.SQLLongint) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLLongint(org.apache.derby.iapi.types.SQLLongint) BackingStoreHashtable(org.apache.derby.iapi.store.access.BackingStoreHashtable)

Example 3 with SQLLongint

use of org.apache.derby.iapi.types.SQLLongint in project derby by apache.

the class BranchRow method createBranchRowFromOldBranchRow.

/**
 * Create a new branch row, given a old branch row and a new child page.
 * Used by BranchControlRow to manufacture new branch rows when splitting
 * or growing the tree.
 *
 * There is no way to "copy" values of a template row, so this class just
 * stores a reference to each of the columns of the Indexable row passed
 * in.  This is ok as all
 * usages of this class when instantiated this way, have an old branch row
 * from which they are creating a new branch row with the same key values,
 * and a different child page number.
 *
 * WARNING - this branch row is only valid while the old branch row is
 * valid, as it contains references to the columns of the old branch row.
 * So use of the row should only provide read-only access to the objects
 * of the old branch row which are referenced.
 */
public BranchRow createBranchRowFromOldBranchRow(long childpageno) {
    BranchRow newbranch = new BranchRow();
    /* create new object array, and shallow copy all object references 
         * from old branch row to new branch row.
         */
    newbranch.branchrow = new DataValueDescriptor[this.branchrow.length];
    System.arraycopy(this.branchrow, 0, newbranch.branchrow, 0, newbranch.branchrow.length - 1);
    /* now create a different child page pointer object and place it as
         * last column in the new branch row.
         */
    newbranch.branchrow[newbranch.branchrow.length - 1] = new SQLLongint(childpageno);
    return (newbranch);
}
Also used : SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 4 with SQLLongint

use of org.apache.derby.iapi.types.SQLLongint in project derby by apache.

the class ControlRow method getLevel.

protected int getLevel() throws StandardException {
    if (this.level == null) {
        // Fault in the level
        this.level = new SQLLongint();
        scratch_row[CR_LEVEL_COLID] = this.level;
        fetchDesc.setValidColumns(CR_LEVEL_BITSET);
        this.page.fetchFromSlot((RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false);
    }
    return ((int) this.level.getLong());
}
Also used : SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 5 with SQLLongint

use of org.apache.derby.iapi.types.SQLLongint in project derby by apache.

the class ControlRow method getleftSiblingPageNumber.

/**
 *	Get the page number of the left sibling. Fault it's value in if it
 *    hasn't been yet.
 *
 *    @exception StandardException Standard exception policy.
 */
public long getleftSiblingPageNumber() throws StandardException {
    if (this.leftSiblingPageNumber == null) {
        // Fault in the page number.
        this.leftSiblingPageNumber = new SQLLongint();
        if (SanityManager.DEBUG)
            SanityManager.ASSERT(scratch_row != null);
        scratch_row[CR_LEFTSIB_COLID] = this.leftSiblingPageNumber;
        fetchDesc.setValidColumns(CR_LEFTSIB_BITSET);
        this.page.fetchFromSlot((RecordHandle) null, CR_SLOT, scratch_row, fetchDesc, false);
    }
    return (leftSiblingPageNumber.getLong());
}
Also used : SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

SQLLongint (org.apache.derby.iapi.types.SQLLongint)50 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)28 RowLocation (org.apache.derby.iapi.types.RowLocation)24 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)21 ScanController (org.apache.derby.iapi.store.access.ScanController)19 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)13 SQLChar (org.apache.derby.iapi.types.SQLChar)10 Properties (java.util.Properties)7 HashSet (java.util.HashSet)5 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)5 GroupFetchScanController (org.apache.derby.iapi.store.access.GroupFetchScanController)4 StandardException (org.apache.derby.shared.common.error.StandardException)4 ColumnOrdering (org.apache.derby.iapi.store.access.ColumnOrdering)3 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)3 ContextManager (org.apache.derby.iapi.services.context.ContextManager)2 ContextService (org.apache.derby.iapi.services.context.ContextService)2 BackingStoreHashtable (org.apache.derby.iapi.store.access.BackingStoreHashtable)2 NumberDataValue (org.apache.derby.iapi.types.NumberDataValue)2 UserType (org.apache.derby.iapi.types.UserType)2 Enumeration (java.util.Enumeration)1