use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaManager method getSQLArray.
public String[] getSQLArray() {
OrderedHashSet resolved = new OrderedHashSet();
OrderedHashSet unresolved = new OrderedHashSet();
HsqlArrayList list = new HsqlArrayList();
Iterator schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (isSystemSchema(schema.name.name)) {
continue;
}
if (isLobsSchema(schema.name.name)) {
continue;
}
list.addAll(schema.getSQLArray(resolved, unresolved));
}
while (true) {
Iterator it = unresolved.iterator();
if (!it.hasNext()) {
break;
}
while (it.hasNext()) {
SchemaObject object = (SchemaObject) it.next();
OrderedHashSet references = object.getReferences();
boolean isResolved = true;
for (int j = 0; j < references.size(); j++) {
HsqlName name = (HsqlName) references.get(j);
if (name.type == SchemaObject.COLUMN || name.type == SchemaObject.CONSTRAINT) {
name = name.parent;
}
if (!resolved.contains(name)) {
isResolved = false;
break;
}
}
if (isResolved) {
if (object.getType() == SchemaObject.TABLE) {
list.addAll(((Table) object).getSQL(resolved, unresolved));
} else {
list.add(object.getSQL());
resolved.add(object.getName());
}
it.remove();
}
}
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (database.schemaManager.isSystemSchema(schema.name.name)) {
continue;
}
if (database.schemaManager.isLobsSchema(schema.name.name)) {
// continue;
}
list.addAll(schema.getTriggerSQL());
list.addAll(schema.getSequenceRestartSQL());
}
if (defaultSchemaHsqlName != null) {
StringBuffer sb = new StringBuffer();
sb.append(Tokens.T_SET).append(' ').append(Tokens.T_DATABASE);
sb.append(' ').append(Tokens.T_DEFAULT).append(' ');
sb.append(Tokens.T_INITIAL).append(' ').append(Tokens.T_SCHEMA);
sb.append(' ').append(defaultSchemaHsqlName.statementName);
list.add(sb.toString());
}
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 RoutineSchema method getSQLArray.
public String[] getSQLArray() {
HsqlArrayList list = new HsqlArrayList();
for (int i = 0; i < routines.length; i++) {
list.add(routines[i].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 SchemaManager method getIndexRootsSQL.
public String[] getIndexRootsSQL() {
Session sysSession = database.sessionManager.getSysSession();
HsqlArrayList tableList = getAllTables();
HsqlArrayList list = new HsqlArrayList();
for (int i = 0, tSize = tableList.size(); i < tSize; i++) {
Table t = (Table) tableList.get(i);
if (t.isIndexCached() && !t.isEmpty(sysSession)) {
String ddl = ((Table) tableList.get(i)).getIndexRootsSQL();
if (ddl != null) {
list.add(ddl);
}
}
}
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 DataFileDefrag method updateTableIndexRoots.
/**
* called from outside after the complete end of defrag
*/
void updateTableIndexRoots() {
HsqlArrayList allTables = database.schemaManager.getAllTables();
for (int i = 0, size = allTables.size(); i < size; i++) {
Table t = (Table) allTables.get(i);
if (t.getTableType() == TableBase.CACHED_TABLE) {
int[] rootsArray = rootsList[i];
t.setIndexRoots(rootsArray);
}
}
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Database method getPropertiesSQL.
public String[] getPropertiesSQL() {
HsqlArrayList list = new HsqlArrayList();
if (schemaManager.getDefaultTableType() == TableBase.CACHED_TABLE) {
list.add("SET DATABASE DEFAULT TABLE TYPE CACHED");
}
if (logger.hasLog()) {
int delay = logger.getWriteDelay();
boolean millis = delay < 1000;
if (millis) {
if (delay != 0 && delay < 20) {
delay = 20;
}
} else {
delay /= 1000;
}
list.add("SET WRITE_DELAY " + delay + (millis ? " MILLIS" : ""));
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
Aggregations