static String precachedSchemaQuery = "SELECT Schemas.schemaid, Schemas.schemarepr, Schemas.schemasrcdescription, SchemaGuesses.fid, TypeGuesses.typeid, Files.crawlid, Files.fname, Files.owner, Files.groupowner, Files.permissions, Files.size, Files.modified, Files.path FROM Schemas, SchemaGuesses, TypeGuesses, Files WHERE SchemaGuesses.schemaid = Schemas.schemaid AND TypeGuesses.fid = SchemaGuesses.fid AND Files.fid = SchemaGuesses.fid ORDER BY Schemas.schemaid";
public List<SchemaSummary> getPrecachedSchemaSummaries() {
return dbQueue.execute(new SQLiteJob<List<SchemaSummary>>() {
protected List<SchemaSummary> job(SQLiteConnection db) throws SQLiteException {
List<SchemaSummary> output = new ArrayList<SchemaSummary>();
SQLiteStatement stmt = db.prepare(precachedSchemaQuery);
try {
SchemaSummaryData ssd = null;
SchemaSummary ss = null;
long lastSchemaId = -1L;
List<TypeGuessSummary> tgslist = null;
while (stmt.step()) {
long schemaid = stmt.columnLong(0);
String schemarepr = stmt.columnString(1);
String schemasrcdescription = stmt.columnString(2);
long fid = stmt.columnLong(3);
long typeid = stmt.columnLong(4);
long crawlid = stmt.columnLong(5);
String fname = stmt.columnString(6);
String owner = stmt.columnString(7);
String groupowner = stmt.columnString(8);
String permissions = stmt.columnString(9);
long size = stmt.columnLong(10);
String modified = stmt.columnString(11);
String path = stmt.columnString(12);
TypeGuessSummary tgs = new TypeGuessSummary(FSAnalyzer.this, fid, typeid, schemaid);
FileSummary fs = new FileSummary(FSAnalyzer.this, fid);
FileSummaryData fsd = new FileSummaryData(FSAnalyzer.this, true, fid, crawlid, fname, owner, groupowner, permissions, size, modified, path);
fs.addCachedData(fsd);
tgs.addCachedData(fs);
if (schemaid != lastSchemaId) {
if (ss != null) {
ss.addCachedData(tgslist);
output.add(ss);
}
ssd = new SchemaSummaryData(schemaid, schemarepr, schemasrcdescription);
ss = new SchemaSummary(FSAnalyzer.this, schemaid);
ss.addCachedData(ssd);
tgslist = new ArrayList<TypeGuessSummary>();
}
tgslist.add(tgs);
lastSchemaId = schemaid;
}
if (ss != null) {
ss.addCachedData(tgslist);
output.add(ss);
}
} catch (SQLiteException se) {
se.printStackTrace();
} finally {
stmt.dispose();
}
return output;
}}).complete();
}