*/
private abstract class TableFinder
{
- protected abstract Cursor findRow(Integer parentId, String name)
- throws IOException;
-
- protected abstract Cursor findRow(Integer objectId)
- throws IOException;
-
public Integer findObjectId(Integer parentId, String name)
throws IOException
{
return (Integer)cur.getCurrentRowValue(idCol);
}
- public abstract TableInfo lookupTable(String tableName)
- throws IOException;
-
- public abstract void getTableNames(Set<String> tableNames)
- throws IOException;
-
public Map<String,Object> getObjectRow(Integer parentId, String name,
Collection<String> columns)
throws IOException
Cursor cur = findRow(objectId);
return ((cur != null) ? cur.getCurrentRow(columns) : null);
}
+
+ public void getTableNames(Set<String> tableNames) throws IOException {
+
+ for(Map<String,Object> row : getTableNamesCursor().iterable(
+ SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
+
+ String tableName = (String)row.get(CAT_COL_NAME);
+ int flags = (Integer)row.get(CAT_COL_FLAGS);
+ Short type = (Short)row.get(CAT_COL_TYPE);
+ int parentId = (Integer)row.get(CAT_COL_PARENT_ID);
+
+ if((parentId == _tableParentId) && TYPE_TABLE.equals(type) &&
+ !isSystemObject(flags)) {
+ tableNames.add(tableName);
+ }
+ }
+ }
+
+ protected abstract Cursor findRow(Integer parentId, String name)
+ throws IOException;
+
+ protected abstract Cursor findRow(Integer objectId)
+ throws IOException;
+
+ protected abstract Cursor getTableNamesCursor() throws IOException;
+
+ public abstract TableInfo lookupTable(String tableName)
+ throws IOException;
}
/**
}
@Override
- public void getTableNames(Set<String> tableNames) throws IOException {
-
- IndexCursor tNameCursor = new CursorBuilder(_systemCatalog)
+ protected Cursor getTableNamesCursor() throws IOException {
+ return new CursorBuilder(_systemCatalog)
.setIndex(_systemCatalogCursor.getIndex())
.setStartEntry(_tableParentId, IndexData.MIN_VALUE)
.setEndEntry(_tableParentId, IndexData.MAX_VALUE)
.toIndexCursor();
-
- for(Map<String,Object> row : tNameCursor.iterable(
- SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
-
- String tableName = (String)row.get(CAT_COL_NAME);
- int flags = (Integer)row.get(CAT_COL_FLAGS);
- Short type = (Short)row.get(CAT_COL_TYPE);
-
- if(TYPE_TABLE.equals(type) && !isSystemObject(flags)) {
- tableNames.add(tableName);
- }
- }
}
}
}
@Override
- public void getTableNames(Set<String> tableNames) throws IOException {
-
- for(Map<String,Object> row : _systemCatalogCursor.iterable(
- SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
-
- String tableName = (String)row.get(CAT_COL_NAME);
- int flags = (Integer)row.get(CAT_COL_FLAGS);
- Short type = (Short)row.get(CAT_COL_TYPE);
- int parentId = (Integer)row.get(CAT_COL_PARENT_ID);
-
- if((parentId == _tableParentId) && TYPE_TABLE.equals(type) &&
- !isSystemObject(flags)) {
- tableNames.add(tableName);
- }
- }
+ protected Cursor getTableNamesCursor() throws IOException {
+ return _systemCatalogCursor;
}
}