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;
}
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);
}
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);
}
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());
}
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());
}
Aggregations