use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaObjectSet method getSQL.
String[] getSQL(OrderedHashSet resolved, OrderedHashSet unresolved) {
HsqlArrayList list = new HsqlArrayList();
if (!(map instanceof HashMappedList)) {
return null;
}
if (map.isEmpty()) {
return ValuePool.emptyStringArray;
}
Iterator it = map.values().iterator();
if (type == SchemaObject.FUNCTION || type == SchemaObject.PROCEDURE) {
OrderedHashSet set = new OrderedHashSet();
while (it.hasNext()) {
RoutineSchema routine = (RoutineSchema) it.next();
for (int i = 0; i < routine.routines.length; i++) {
set.add(routine.routines[i]);
}
}
it = set.iterator();
}
while (it.hasNext()) {
SchemaObject object = (SchemaObject) it.next();
OrderedHashSet references = object.getReferences();
if (references != null) {
boolean isResolved = true;
for (int j = 0; j < references.size(); j++) {
HsqlName name = (HsqlName) references.get(j);
if (SqlInvariants.isSchemaNameSystem(name)) {
continue;
}
if (name.type == SchemaObject.COLUMN) {
name = name.parent;
}
if (name.type == SchemaObject.CHARSET) {
// some built-in character sets have no schema
if (name.schema == null) {
continue;
}
}
if (!resolved.contains(name)) {
isResolved = false;
break;
}
}
if (!isResolved) {
unresolved.add(object);
continue;
}
}
resolved.add(object.getName());
if (object.getType() == SchemaObject.TABLE) {
list.addAll(((Table) object).getSQL(resolved, unresolved));
} else {
list.add(object.getSQL());
}
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SessionContext method push.
public void push() {
if (stack == null) {
stack = new HsqlArrayList(true);
}
stack.add(dynamicArguments);
stack.add(routineArguments);
stack.add(routineVariables);
stack.add(rangeIterators);
stack.add(savepoints);
stack.add(savepointTimestamps);
rangeIterators = new RangeIterator[4];
savepoints = new HashMappedList(4);
savepointTimestamps = new LongDeque();
String name = HsqlNameManager.getAutoSavepointNameString(session.actionTimestamp, depth);
session.savepoint(name);
depth++;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaManager method dropSchemas.
/**
* drop all schemas with the given authorisation
*/
void dropSchemas(Grantee grantee, boolean cascade) {
HsqlArrayList list = getSchemas(grantee);
Iterator it = list.iterator();
while (it.hasNext()) {
Schema schema = (Schema) it.next();
dropSchema(schema.name.name, cascade);
}
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class DataFileDefrag method process.
void process() throws IOException {
boolean complete = false;
Error.printSystemOut("Defrag Transfer begins");
transactionRowLookup = database.txManager.getTransactionIDList();
HsqlArrayList allTables = database.schemaManager.getAllTables();
rootsList = new int[allTables.size()][];
Storage dest = null;
try {
OutputStream fos = database.getFileAccess().openOutputStreamElement(filename + ".new");
fileStreamOut = new BufferedOutputStream(fos, 1 << 12);
for (int i = 0; i < DataFileCache.INITIAL_FREE_POS; i++) {
fileStreamOut.write(0);
}
fileOffset = DataFileCache.INITIAL_FREE_POS;
for (int i = 0, tSize = allTables.size(); i < tSize; i++) {
Table t = (Table) allTables.get(i);
if (t.getTableType() == TableBase.CACHED_TABLE) {
int[] rootsArray = writeTableToDataFile(t);
rootsList[i] = rootsArray;
} else {
rootsList[i] = null;
}
Error.printSystemOut(t.getName().name + " complete");
}
writeTransactionRows();
fileStreamOut.flush();
fileStreamOut.close();
fileStreamOut = null;
// write out the end of file position
dest = ScaledRAFile.newScaledRAFile(database, filename + ".new", false, ScaledRAFile.DATA_FILE_RAF, database.getURLProperties().getProperty("storage_class_name"), database.getURLProperties().getProperty("storage_key"));
dest.seek(DataFileCache.LONG_FREE_POS_POS);
dest.writeLong(fileOffset);
dest.close();
dest = null;
for (int i = 0, size = rootsList.length; i < size; i++) {
int[] roots = rootsList[i];
if (roots != null) {
Error.printSystemOut(org.hsqldb_voltpatches.lib.StringUtil.getList(roots, ",", ""));
}
}
complete = true;
} catch (IOException e) {
throw Error.error(ErrorCode.FILE_IO_ERROR, filename + ".new");
} catch (OutOfMemoryError e) {
throw Error.error(ErrorCode.OUT_OF_MEMORY);
} finally {
if (fileStreamOut != null) {
fileStreamOut.close();
}
if (dest != null) {
dest.close();
}
if (!complete) {
database.getFileAccess().removeElement(filename + ".new");
}
}
//Error.printSystemOut("Transfer complete: ", stopw.elapsedTime());
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaManager method getAllTables.
/**
* Returns an HsqlArrayList containing references to all non-system
* tables and views. This includes all tables and views registered with
* this Database.
*/
public HsqlArrayList getAllTables() {
Iterator schemas = allSchemaNameIterator();
HsqlArrayList alltables = new HsqlArrayList();
while (schemas.hasNext()) {
String name = (String) schemas.next();
HashMappedList current = getTables(name);
alltables.addAll(current.values());
}
return alltables;
}
Aggregations