Package at.jku.sii.sqlitereader.btree

Source Code of at.jku.sii.sqlitereader.btree.TableLeafBTreePage

package at.jku.sii.sqlitereader.btree;

import java.util.List;

import at.jku.sii.sqlitereader.SqliteDataBase;
import at.jku.sii.sqlitereader.btree.TableLeafBTreePage.TableLeafCell;
import at.jku.sii.sqlitereader.io.AdvancedDataInput.Varint;
import at.jku.sii.sqlitereader.io.ArrayDataInput;
import at.jku.sii.sqlitereader.record.Record;

public final class TableLeafBTreePage extends PayloadBTreePage<TableLeafCell> {
  public static final class TableLeafCell extends PayloadCell implements TableCell {
    private final long rowid;

    public TableLeafCell(ArrayDataInput in, SqliteDataBase db) {
      this(in.readVarint("numPayloadBytes"), in.readVarint("rowid"), in, db);
    }

    private TableLeafCell(Varint numPayloadBytes, Varint rowid, ArrayDataInput in, SqliteDataBase db) {
      super(numPayloadBytes, Type.TABLE_LEAF, in, db);
      this.rowid = rowid.value;
    }

    public long getRowid() {
      return this.rowid;
    }

    @Override
    public String toString() {
      return String.format("TableLeafCell [rowid=%s, %s]", this.rowid, this.toStringAttr());
    }
  }

  TableLeafBTreePage(int number, SqliteDataBase db, ArrayDataInput block) {
    super(number, Type.TABLE_LEAF, db, block);
  }

  @Override
  protected TableLeafCell readCell(ArrayDataInput in, SqliteDataBase db) {
    return new TableLeafCell(in, db);
  }

  @Override
  public void collectRecords(List<Record> records) {
    for (TableLeafCell cell : this)
      records.add(cell.getRecord());
  }
}
TOP

Related Classes of at.jku.sii.sqlitereader.btree.TableLeafBTreePage

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.