Examples of SQLiteStatement


Examples of com.almworks.sqlite4java.SQLiteStatement

            for (int i = 0; i < typeGuesses.size(); i+=3) {
              long typeId = typeGuesses.get(i);
              long fileId = typeGuesses.get(i+1);             
              long schemaId = typeGuesses.get(i+2);           

              SQLiteStatement stmt = db.prepare("INSERT into TypeGuesses VALUES(?, ?)");
              try {
                stmt.bind(1, fileId).bind(2, typeId);
                stmt.step();
              } finally {
                stmt.dispose();
              }
            }
            return null;
          }
        }).complete();

      dbQueue.execute(new SQLiteJob<Object>() {
          protected Long job(SQLiteConnection db) throws SQLiteException {
            for (int i = 0; i < typeGuesses.size(); i+=3) {
              long typeId = typeGuesses.get(i);
              long fileId = typeGuesses.get(i+1);             
              long schemaId = typeGuesses.get(i+2);           

              SQLiteStatement stmt = db.prepare("INSERT into SchemaGuesses VALUES(?, ?)");
              try {
                stmt.bind(1, fileId).bind(2, schemaId);
                stmt.step();
              } finally {
                stmt.dispose();
              }
            }
            return null;
          }
        }).complete();
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

    }
    final String parentPath = parentPathString;
    final String fName = fnameString;
    final long fileId = dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("INSERT into Files VALUES(null, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
          try {
            stmt.bind(1, isDir ? "True" : "False").bind(2, crawlId).bind(3, fName).bind(4, fstatus.getOwner()).bind(5, fstatus.getGroup()).bind(6, permissions).bind(7, fstatus.getLen()).bind(8, fileDateFormat.format(new Date(fstatus.getModificationTime()))).bind(9, parentPath);
            stmt.step();
            return db.getLastInsertId();
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String schemaInfoQuery = "SELECT schemaid FROM Schemas";   
  public List<SchemaSummary> getSchemaSummaries() {
    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(schemaInfoQuery);
         
          try {
            while (stmt.step()) {
              long schemaId = stmt.columnLong(0);
              output.add(new SchemaSummary(FSAnalyzer.this, schemaId));
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * Grab details on a schema.
   */
  public SchemaSummaryData getSchemaSummaryData(final long schemaid) {
    return dbQueue.execute(new SQLiteJob<SchemaSummaryData>() {
        protected SchemaSummaryData job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT schemarepr, schemasrcdescription FROM Schemas WHERE schemaid = ?");
          try {
            stmt.bind(1, schemaid);
            if (stmt.step()) {
              return new SchemaSummaryData(schemaid, stmt.columnString(0), stmt.columnString(1));
            } else {
              return null;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  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();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String subpathFilesQuery = "SELECT fid from Files WHERE path LIKE ?";
  public List<Long> getFidUnderPath(final String pathPrefix) throws SQLiteException {
    List<Long> finalResults = dbQueue.execute(new SQLiteJob<List<Long>>() {
        protected List<Long> job(SQLiteConnection db) throws SQLiteException {
          List<Long> results = new ArrayList<Long>();         
          SQLiteStatement stmt = db.prepare(subpathFilesQuery);
          try {
            stmt.bind(1, pathPrefix + "%");
            while (stmt.step()) {
              long resultId = stmt.columnLong(0);
              results.add(resultId);
            }
            return results;
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
    return finalResults;
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String fileInfoQueryWithPrefix = "SELECT fid FROM Files WHERE isDir = ? AND path = ?";
  public List<FileSummary> getFileSummariesInDir(final boolean isDir, final String prefix) {
    return dbQueue.execute(new SQLiteJob<List<FileSummary>>() {
        protected List<FileSummary> job(SQLiteConnection db) throws SQLiteException {
          List<FileSummary> output = new ArrayList<FileSummary>();
          SQLiteStatement stmt;
          if (prefix == null) {
            stmt = db.prepare(fileInfoQueryWithoutPrefix);
            stmt.bind(1, isDir ? "True" : "False");           
          } else {
            stmt = db.prepare(fileInfoQueryWithPrefix);
            String prefixStr = prefix;
            if (! prefixStr.endsWith("/")) {
              prefixStr += "/";
            }
            stmt.bind(1, isDir ? "True" : "False").bind(2, prefixStr);           
          }
          try {
            while (stmt.step()) {
              long fid = stmt.columnLong(0);
              output.add(new FileSummary(FSAnalyzer.this, fid));
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String precachedFileInfoQueryWithPrefix = precachedFileInfoQueryWithoutPrefix + " AND Files.path = ?";
  public List<FileSummary> getPrecachedFileSummariesInDir(final boolean isDir, final String prefix) {
    return dbQueue.execute(new SQLiteJob<List<FileSummary>>() {
        protected List<FileSummary> job(SQLiteConnection db) throws SQLiteException {
          List<FileSummary> output = new ArrayList<FileSummary>();
          SQLiteStatement stmt;
          if (prefix == null) {
            stmt = db.prepare(precachedFileInfoQueryWithoutPrefix);
            stmt.bind(1, isDir ? "True" : "False");           
          } else {
            stmt = db.prepare(precachedFileInfoQueryWithPrefix);
            String prefixStr = prefix;
            if (! prefixStr.endsWith("/")) {
              prefixStr += "/";
            }
            stmt.bind(1, isDir ? "True" : "False").bind(2, prefixStr);           
          }
          try {
            FileSummary fs = null;
            FileSummaryData fsd = null;
            long lastFid = -1L;
            List<TypeGuessSummary> tgslist = null;
            while (stmt.step()) {
              long fid = stmt.columnLong(0);
              long crawlid = stmt.columnLong(1);
              String fname = stmt.columnString(2);
              String owner = stmt.columnString(3);
              String groupowner = stmt.columnString(4);
              String permissions = stmt.columnString(5);
              long size = stmt.columnLong(6);
              String modified = stmt.columnString(7);
              String path = stmt.columnString(8);
              long schemaid = stmt.columnLong(9);
              long typeid = stmt.columnLong(10);

              // We get a tuple for every typeguess.
              // There could be more than one typeguess for each unique file
              TypeGuessSummary tgs = new TypeGuessSummary(FSAnalyzer.this, fid, typeid, schemaid);
              tgs.addCachedData(fs);
               
              if (fid != lastFid) {
                if (fs != null) {
                  fs.addCachedData(tgslist);
                  output.add(fs);
                }
                fs = new FileSummary(FSAnalyzer.this, fid);             
                fsd = new FileSummaryData(FSAnalyzer.this, isDir, fid, crawlid, fname, owner, groupowner, permissions, size, modified, path);
                fs.addCachedData(fsd);
                tgslist = new ArrayList<TypeGuessSummary>();
              }
              tgslist.add(tgs);
              lastFid = fid;
            }
            if (fs != null) {
              fs.addCachedData(tgslist);
              output.add(fs);
            }
          } catch (SQLiteException sqe) {
            sqe.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String singletonFileInfoQuery = "SELECT fid FROM Files WHERE path||fname = ?"
  public FileSummary getSingleFileSummary(final String fullName) {
    return dbQueue.execute(new SQLiteJob<FileSummary>() {
        protected FileSummary job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare(singletonFileInfoQuery);
          stmt.bind(1, fullName);           
          try {
            if (stmt.step()) {
              long fid = stmt.columnLong(0);
              return new FileSummary(FSAnalyzer.this, fid);
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return null;
        }}).complete();
  }   
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  static String filenameForCrawlQuery = "SELECT path, fname FROM Files WHERE crawlid=? AND isDir = ?";       
  private List<Path> getFileEntriesForCrawl(final long crawlid, final String isDir) {
    return dbQueue.execute(new SQLiteJob<List<Path>>() {
        protected List<Path> job(SQLiteConnection db) throws SQLiteException {
          List<Path> output = new ArrayList<Path>();         
          SQLiteStatement stmt = db.prepare(filenameForCrawlQuery);
          try {
            stmt.bind(1, crawlid).bind(2, isDir);
            while (stmt.step()) {
              output.add(new Path(stmt.columnString(0), stmt.columnString(1)));
            }
          } catch (SQLiteException se) {
            se.printStackTrace();
          } finally {
            stmt.dispose();
          }
          return output;
        }}).complete();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.