java.lang.Object
com.semedy.reasoner.edb.persistentstore.bplustree.BplusDataFile
All Implemented Interfaces:
Closeable, AutoCloseable

public class BplusDataFile extends Object implements Closeable
Manages file space for data like bplus nodes, indice values, symbols etc.
File space is managed with variable piece sizes.
A free space list is managed. Data are compressed with lz4
Author:
angele
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    static boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BplusDataFile(String filePath, int additionalHeadSpace, int nodeSize, boolean compress)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    alloc(int oldindex, byte[] data)
    Searches for free space in file and writes
    data to that space
    boolean
    checks free space list
    boolean
    checks for double occurences
    void
    clear all
    void
    Close file
    void
    Create a file.
    void
    delete file
    get an iterator over file pieces
    void
    flush out page table
    void
    free(int index, boolean shadow)
    Frees up space at index
    int
    write flags to file
    int
    get node size
    int
    get root location
    long
    get number of elements in page table
    int
    length(long pos)
    length of file
    boolean
    Open an existing file.
    byte[]
    read(int index, boolean shadow)
    Reads data at index from file and returns it
    long[]
    read grounds
    void
     
    void
    setBulkMode(boolean mode)
    set bulk mode
    void
    setFlags(int flags)
    write flags to file
    void
    setGrounds(long[] longs)
    write grounds
    void
    setNodeSize(int nodesize)
    set node size
    void
    setRoot(int index)
    set root location
    void
    setSize(long size)
    set number of elements in page table
    void
    start transaction
    void
    commit transaction
    void
    rollback transaction
    long
    write(byte[] data)
    write data at index 0
    int
    write(int oldindex, byte[] data)
    Searches for free space in file and writes
    data to that space
    long
    writeOffset(int oldindex, byte[] data)
    Write to an offset and return (new) offset

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _count

      public static int _count
    • buglog

      public static boolean buglog
  • Constructor Details

    • BplusDataFile

      public BplusDataFile(String filePath, int additionalHeadSpace, int nodeSize, boolean compress)
  • Method Details

    • setBugLog

      public void setBugLog(Boolean b)
    • create

      public void create() throws IOException, EDBException
      Create a file. If it exists it will be cleared. File has a header of 32 bytes
      Throws:
      IOException
      EDBException
    • open

      public boolean open() throws IOException, EDBException
      Open an existing file. Return true if successful.
      Returns:
      Throws:
      IOException
      EDBException
    • checkSanity1

      public boolean checkSanity1()
      checks for double occurences
      Returns:
    • checkSanity

      public boolean checkSanity()
      checks free space list
      Returns:
    • write

      public int write(int oldindex, byte[] data) throws IOException
      Searches for free space in file and writes
      data to that space
      Parameters:
      data - to write to file
      oldindex - , index to write to
      Throws:
      IOException
    • alloc

      public int alloc(int oldindex, byte[] data) throws IOException
      Searches for free space in file and writes
      data to that space
      Parameters:
      data - to write to file
      oldindex - , index to write to
      Throws:
      IOException
    • writeOffset

      public long writeOffset(int oldindex, byte[] data) throws IOException
      Write to an offset and return (new) offset
      Parameters:
      oldindex -
      data -
      Returns:
      Throws:
      IOException
    • read

      public byte[] read(int index, boolean shadow) throws IOException
      Reads data at index from file and returns it
      Parameters:
      index -
      shadow - , read from shadow tree
      Returns:
      Throws:
      IOException
    • free

      public void free(int index, boolean shadow) throws IOException
      Frees up space at index
      Parameters:
      index -
      Throws:
      IOException
    • setFlags

      public void setFlags(int flags) throws IOException
      write flags to file
      Parameters:
      flags -
      Throws:
      IOException
    • getFlags

      public int getFlags() throws IOException
      write flags to file
      Parameters:
      flags -
      Throws:
      IOException
    • close

      public void close() throws IOException
      Close file
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      flush out page table
      Throws:
      IOException
    • setGrounds

      public void setGrounds(long[] longs) throws IOException
      write grounds
      Throws:
      IOException
    • readGrounds

      public long[] readGrounds() throws IOException
      read grounds
      Throws:
      IOException
    • write

      public long write(byte[] data) throws IOException
      write data at index 0
      Throws:
      IOException
    • delete

      public void delete()
      delete file
    • setBulkMode

      public void setBulkMode(boolean mode)
      set bulk mode
    • transactionCommit

      public void transactionCommit() throws IOException
      commit transaction
      Throws:
      IOException
    • transactionBegin

      public void transactionBegin() throws IOException
      start transaction
      Throws:
      IOException
    • transactionRollback

      public void transactionRollback() throws IOException
      rollback transaction
      Throws:
      IOException
    • length

      public int length(long pos) throws IOException
      length of file
      Throws:
      IOException
    • clear

      public void clear() throws IOException, EDBException
      clear all
      Throws:
      IOException
      EDBException
    • elements

      public Iterator<DataFileElement> elements()
      get an iterator over file pieces
    • setRoot

      public void setRoot(int index)
      set root location
    • getRoot

      public int getRoot()
      get root location
    • setNodeSize

      public void setNodeSize(int nodesize)
      set node size
    • getNodeSize

      public int getNodeSize()
      get node size
    • setSize

      public void setSize(long size)
      set number of elements in page table
    • getSize

      public long getSize()
      get number of elements in page table