Package at.jku.sii.sqlitereader.io

Examples of at.jku.sii.sqlitereader.io.FileDataInput


  private final SqliteMasterTable sql_master_table;

  private final SimpleAnnotator annotator;

  public SqliteDataBase(File dbFile) {
    FileDataInput file = null;
    this.annotator = new SimpleAnnotator();

    try {
      file = new FileDataInput(dbFile, this.annotator);

      this.fileName = dbFile.getAbsolutePath();

      file.annotate(0, (int) HEADER_SIZE, "Header");
      // start of header
      readMagicHeader(file);
      this.pageSize = readPageSize(file);
      this.fileFormatWrite = file.readByte() == 1 ? FileFormat.LEGACY : FileFormat.WAL;
      file.annotateLastByte("writeFileFormat", this.fileFormatWrite);
      this.fileFormatRead = file.readByte() == 1 ? FileFormat.LEGACY : FileFormat.WAL;
      file.annotateLastByte("readFileFormat", this.fileFormatRead);

      this.reservedPageSpace = file.readByte("reservedPageSpace");

      byte maxEmbedded = file.readByte("maxEmbedded");
      assert (maxEmbedded == 64);
      byte minEmbedded = file.readByte("minEmbedded");
      assert (minEmbedded == 32);
      byte leafPayload = file.readByte("leafPayload");
      assert (leafPayload == 32);
      this.fileChangeCounter = file.readInt("fileChangeCounter");
      int storedNumPages = file.readInt("storedNumPages");

      this.firstFreeListPage = file.readInt("firstFreeListPage");
      this.numFreeListPages = file.readInt("numFreeListPages");

      this.schemaCookie = file.readInt("schemaCookie");
      this.schemaFormat = file.readInt("schemaForamt"); // one of 1..4
      this.defaultPageCacheSize = file.readInt("defaultPageCacheSize");

      this.largestBTreePage = file.readInt("largestBTreePage");

      this.encoding = readEncoding(file);
      file.annotateLastInt("Encoding", this.encoding);

      this.userVersion = file.readInt("userVersion");
      this.incrementalVacuumMode = file.readInt() > 0;
      file.annotateLastInt("incrementalVacuumMode", this.incrementalVacuumMode);
      // reserved
      byte[] reserved = new byte[24];
      file.readFully(reserved);
      file.annotateLast(reserved.length, "reserved");

      this.versionValid4Number = file.readInt("versionValid4Number");
      this.versionSqlite = file.readInt("versionSqlite");
      // end of header

      // compute the num of Pages
      if (isValidNumPages(storedNumPages, this.fileChangeCounter, this.versionValid4Number)) {
        this.numPages = storedNumPages;
      } else {
        this.numPages = file.size() / this.pageSize;
      }

      // read all pages
      this.pages = readPages(file, this.numPages, this.pageSize);
    } finally {
      if (file != null)
        file.close();
      file = null;
    }

    // read root btree page
    BTreePage<TableCell> sql_master_btree = BTreePages.readMaster(this);
View Full Code Here

TOP

Related Classes of at.jku.sii.sqlitereader.io.FileDataInput

Copyright © 2018 www.massapicom. 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.