Class Engine

java.lang.Object
com._1c.g5.v8.xmdb.impl.Engine
All Implemented Interfaces:
Closeable, AutoCloseable

public class Engine extends Object implements Closeable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected final ReentrantLock
    protects lifecycle methods such as commit, rollback and close()
    protected final ReentrantLock
    protects structural layout of records.
    protected Volume
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Engine(File file)
    Creates a new instance.
    Engine(File file, int pageSize)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    long
    clone(long cLink)
     
    void
     
    void
     
    void
     
    void
    delete(long clink)
    Deletes the data pointed by the specified clink.
    void
     
    void
     
    byte[]
    get(long compactLink)
    Read record bytes (all) from volume (Include joining long records
    get2(long compactLink)
    Read record bytes (all) from volume (Include joining long records
    byte
    getByte(long offset)
     
    int
    getInt(long offset)
     
    long
    getLong(long offset)
    Read long from specified offset
     
    boolean
     
    boolean
     
    long
    put(byte[] val, boolean reserveExtraSpace)
    Store bytes into volume and return internal link.
    long
    put(ByteBuffer bb, boolean reserveExtraSpace)
    Puts a sequence of bytes to this engine from the given buffer.
    void
    putByte(long offset, byte value)
     
    void
    putInt(long offset, int value)
     
    void
    putLong(long offset, long value)
     
    void
    renameTo(String newName)
     
    void
     
    void
     
    protected void
     
    long
    update(long clink, byte[] newVal, boolean reserveExtraSpace)
    Updates the record identified by the specified compact link (clink).
    long
    update(long clink, ByteBuffer newVal, boolean reserveExtraSpace)
    Updates the record identified by the specified compact link (clink).

    Methods inherited from class java.lang.Object

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

    • vol

      protected volatile Volume vol
    • closed

      protected volatile boolean closed
    • structuralLock

      protected final ReentrantLock structuralLock
      protects structural layout of records. Memory allocator is single threaded under this lock
    • commitLock

      protected final ReentrantLock commitLock
      protects lifecycle methods such as commit, rollback and close()
  • Constructor Details

    • Engine

      public Engine(File file)
      Creates a new instance.
      Parameters:
      file - the file to store data in. May not be null.
    • Engine

      public Engine(File file, int pageSize)
      Creates a new instance.
      Parameters:
      file - the file to store data in. May not be null.
      pageSize - the size of the page (minimal unit of disk space allocation). Must be greater than 0.
  • Method Details

    • sync

      protected void sync()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • get

      public byte[] get(long compactLink)
      Read record bytes (all) from volume (Include joining long records
      Parameters:
      compactLink -
      Returns:
    • get2

      public ByteBuffer get2(long compactLink)
      Read record bytes (all) from volume (Include joining long records
      Parameters:
      compactLink -
      Returns:
    • getLong

      public long getLong(long offset)
      Read long from specified offset
      Parameters:
      complexLink -
      Returns:
    • putLong

      public void putLong(long offset, long value)
    • getInt

      public int getInt(long offset)
    • putInt

      public void putInt(long offset, int value)
    • getByte

      public byte getByte(long offset)
    • putByte

      public void putByte(long offset, byte value)
    • put

      public long put(ByteBuffer bb, boolean reserveExtraSpace)
      Puts a sequence of bytes to this engine from the given buffer.
      Parameters:
      bb - the byte buffer, may not be null.
      reserveExtraSpace - the flag showing whether extra space should be reserved for future updates.
      Returns:
      compact link (clink) to the put data.
    • put

      public long put(byte[] val, boolean reserveExtraSpace)
      Store bytes into volume and return internal link. If data fit's in link (<= 7 bytes) than nothink is writing into volume, just construct appropriate link
      Parameters:
      val - bytes to store
      reserveExtraSpace - the flag showing whether extra space should be reserved for future updates.
      Returns:
      internal ling (not recid!)
    • update

      public long update(long clink, ByteBuffer newVal, boolean reserveExtraSpace)
      Updates the record identified by the specified compact link (clink).
      Parameters:
      clink - the compact link.
      newVal - the byte buffer containing new value.
      reserveExtraSpace - the flag showing whether extra space should be reserved for future updates.
      Returns:
      compact link (clink) to the updated record (might not be the same as the specified one).
    • update

      public long update(long clink, byte[] newVal, boolean reserveExtraSpace)
      Updates the record identified by the specified compact link (clink).
      Parameters:
      clink - the compact link.
      newVal - the byte array containing new value.
      reserveExtraSpace - the flag showing whether extra space should be reserved for future updates.
      Returns:
      compact link (clink) to the updated record (might not be the same as the specified one).
    • delete

      public void delete(long clink)
      Deletes the data pointed by the specified clink.
      Parameters:
      clink - the clink.
    • isClosed

      public boolean isClosed()
    • isReadOnly

      public boolean isReadOnly()
    • commit

      public void commit()
    • rollback

      public void rollback()
    • snapshot

      public void snapshot()
    • compact

      public void compact()
    • getVolume

      public Volume getVolume()
    • clone

      public long clone(long cLink)
    • renameTo

      public void renameTo(String newName)
    • detachStorage

      public void detachStorage()
    • attachStorage

      public void attachStorage()
    • drop

      public void drop()