use of org.apache.derby.iapi.types.UserType in project derby by apache.
the class CacheLock method readProperty.
private Serializable readProperty(TransactionController tc, String key) throws StandardException {
// scan the table for a row with matching "key"
ScanController scan = openScan(tc, key, 0);
DataValueDescriptor[] row = makeNewTemplate();
// did we find at least one row?
boolean isThere = scan.fetchNext(row);
scan.close();
if (!isThere)
return null;
return (Serializable) (((UserType) row[1]).getObject());
}
use of org.apache.derby.iapi.types.UserType in project derby by apache.
the class CacheLock method makeNewTemplate.
/**
* Create a new empty PropertyConglomerate row, to fetch values into.
*/
private DataValueDescriptor[] makeNewTemplate() {
DataValueDescriptor[] template = new DataValueDescriptor[2];
template[0] = new UTF();
template[1] = new UserType();
return (template);
}
use of org.apache.derby.iapi.types.UserType in project derby by apache.
the class CacheLock method readDbProperties.
/**
* Read the database properties and add in the service set.
*/
private Dictionary<String, Object> readDbProperties(TransactionController tc) throws StandardException {
Dictionary<String, Object> set = new Hashtable<String, Object>();
// scan the table for a row with no matching "key"
ScanController scan = openScan(tc, (String) null, 0);
DataValueDescriptor[] row = makeNewTemplate();
while (scan.fetchNext(row)) {
Object key = ((UserType) row[0]).getObject();
Object value = ((UserType) row[1]).getObject();
if (SanityManager.DEBUG) {
if (!(key instanceof String))
SanityManager.THROWASSERT("Key is not a string " + key.getClass().getName());
}
set.put((String) key, value);
}
scan.close();
// add the known properties from the service properties set
String[] servicePropertyList = PropertyUtil.getServicePropertyList();
for (int i = 0; i < servicePropertyList.length; i++) {
String value = serviceProperties.getProperty(servicePropertyList[i]);
if (value != null)
set.put(servicePropertyList[i], value);
}
return set;
}
use of org.apache.derby.iapi.types.UserType in project derby by apache.
the class SYSDEPENDSRowFactory method makeRow.
// ///////////////////////////////////////////////////////////////////////////
//
// METHODS
//
// ///////////////////////////////////////////////////////////////////////////
/**
* Make a SYSDEPENDS row
*
* @param td DependencyDescriptor. If its null then we want to make an empty
* row.
*
* @return Row suitable for inserting into SYSDEPENDS.
*
* @exception StandardException thrown on failure
*/
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
DataValueDescriptor col;
ExecRow row;
String dependentID = null;
DependableFinder dependentBloodhound = null;
String providerID = null;
DependableFinder providerBloodhound = null;
if (td != null) {
DependencyDescriptor dd = (DependencyDescriptor) td;
dependentID = dd.getUUID().toString();
dependentBloodhound = dd.getDependentFinder();
if (dependentBloodhound == null) {
throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE);
}
providerID = dd.getProviderID().toString();
providerBloodhound = dd.getProviderFinder();
if (providerBloodhound == null) {
throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE);
}
}
/* Insert info into sysdepends */
/* RESOLVE - It would be nice to require less knowledge about sysdepends
* and have this be more table driven.
*/
/* Build the row to insert */
row = getExecutionFactory().getValueRow(SYSDEPENDS_COLUMN_COUNT);
/* 1st column is DEPENDENTID (UUID - char(36)) */
row.setColumn(SYSDEPENDS_DEPENDENTID, new SQLChar(dependentID));
/* 2nd column is DEPENDENTFINDER */
row.setColumn(SYSDEPENDS_DEPENDENTTYPE, new UserType(dependentBloodhound));
/* 3rd column is PROVIDERID (UUID - char(36)) */
row.setColumn(SYSDEPENDS_PROVIDERID, new SQLChar(providerID));
/* 4th column is PROVIDERFINDER */
row.setColumn(SYSDEPENDS_PROVIDERTYPE, new UserType(providerBloodhound));
return row;
}
use of org.apache.derby.iapi.types.UserType in project derby by apache.
the class SYSSTATEMENTSRowFactory method makeSYSSTATEMENTSrow.
// ///////////////////////////////////////////////////////////////////////////
//
// METHODS
//
// ///////////////////////////////////////////////////////////////////////////
/**
* Make a SYSSTATEMENTS row.
* <p>
* <B>WARNING</B>: When empty row is true, this method takes
* a snapshot of the SPSD and creates a row. It is imperative
* that that row remain consistent with the descriptor (the
* valid and StorablePreparedStatement fields must be in sync).
* If this row is to be written out and valid is true, then
* this call and the insert should be synchronized on the
* SPSD. This method has <B>NO</B> synchronization.
*
* @param compileMe passed into SPSDescriptorImpl.getPreparedStatement().
* if true, we (re)compile the stmt
* @param spsDescriptor In-memory tuple to be converted to a disk row.
*
* @return Row suitable for inserting into SYSSTATEMENTS.
*
* @exception StandardException thrown on failure
*/
public ExecRow makeSYSSTATEMENTSrow(boolean compileMe, SPSDescriptor spsDescriptor) throws StandardException {
DataTypeDescriptor dtd;
ExecRow row;
DataValueDescriptor col;
String name = null;
UUID uuid = null;
String uuidStr = null;
// schema
String suuidStr = null;
// compilation schema
String compUuidStr = null;
String text = null;
String usingText = null;
ExecPreparedStatement preparedStatement = null;
String typeStr = null;
boolean valid = true;
Timestamp time = null;
boolean initiallyCompilable = true;
if (spsDescriptor != null) {
name = spsDescriptor.getName();
uuid = spsDescriptor.getUUID();
suuidStr = spsDescriptor.getSchemaDescriptor().getUUID().toString();
uuidStr = uuid.toString();
text = spsDescriptor.getText();
valid = spsDescriptor.isValid();
time = spsDescriptor.getCompileTime();
typeStr = spsDescriptor.getTypeAsString();
initiallyCompilable = spsDescriptor.initiallyCompilable();
preparedStatement = spsDescriptor.getPreparedStatement(compileMe);
compUuidStr = (spsDescriptor.getCompSchemaId() != null) ? spsDescriptor.getCompSchemaId().toString() : null;
usingText = spsDescriptor.getUsingText();
}
/* Build the row to insert */
row = getExecutionFactory().getValueRow(SYSSTATEMENTS_COLUMN_COUNT);
/* 1st column is STMTID */
row.setColumn(1, new SQLChar(uuidStr));
/* 2nd column is STMTNAME */
row.setColumn(2, new SQLVarchar(name));
/* 3rd column is SCHEMAID */
row.setColumn(3, new SQLChar(suuidStr));
/* 4th column is TYPE */
row.setColumn(4, new SQLChar(typeStr));
/* 5th column is VALID */
row.setColumn(5, new SQLBoolean(valid));
/* 6th column is TEXT */
row.setColumn(6, dvf.getLongvarcharDataValue(text));
/* 7th column is LASTCOMPILED */
row.setColumn(7, new SQLTimestamp(time));
/* 8th column is COMPILATIONSCHEMAID */
row.setColumn(8, new SQLChar(compUuidStr));
/* 9th column is USINGTEXT */
row.setColumn(9, dvf.getLongvarcharDataValue(usingText));
/*
** 10th column is CONSTANTSTATE
**
** CONSTANTSTATE is really a formatable StorablePreparedStatement.
*/
row.setColumn(10, new UserType(preparedStatement));
/* 11th column is INITIALLY_COMPILABLE */
row.setColumn(11, new SQLBoolean(initiallyCompilable));
return row;
}
Aggregations