org.basex.io.random
Class TableAccess

java.lang.Object
  extended by org.basex.io.random.TableAccess
Direct Known Subclasses:
TableDiskAccess, TableMemAccess

public abstract class TableAccess
extends java.lang.Object

This abstract class defines the methods for accessing the database table representation.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
protected  boolean dirty
          Dirty index flag.
protected  MetaData meta
          Meta data.
 
Method Summary
abstract  void close()
          Closes the table access.
protected abstract  void copy(byte[] entries, int pre, int last)
          Copies the specified values into the database.
abstract  void delete(int pre, int nr)
          Deletes the specified number of entries from the database.
abstract  void flush()
          Flushes the table contents.
abstract  void insert(int pre, byte[] entries)
          Inserts the specified entries into the database.
abstract  boolean lock(boolean excl)
          Tries to acquires a lock on the table.
abstract  int read1(int p, int o)
          Reads a byte value and returns it as an integer value.
abstract  int read2(int p, int o)
          Reads a short value and returns it as an integer value.
abstract  int read4(int p, int o)
          Reads an integer value.
abstract  long read5(int p, int o)
          Reads a 5-byte value and returns it as a long value.
 void replace(int pre, byte[] entries, int sub)
          Replaces entries in the database.
 void set(int pre, byte[] entries)
          Copies the specified entries into the database.
abstract  void write1(int p, int o, int v)
          Writes a byte value to the specified position.
abstract  void write2(int p, int o, int v)
          Writes a short value to the specified position.
abstract  void write4(int p, int o, int v)
          Writes an integer value to the specified position.
abstract  void write5(int p, int o, long v)
          Writes a 5-byte value to the specified position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

meta

protected final MetaData meta
Meta data.


dirty

protected boolean dirty
Dirty index flag.

Method Detail

flush

public abstract void flush()
                    throws java.io.IOException
Flushes the table contents.

Throws:
java.io.IOException - I/O exception

close

public abstract void close()
                    throws java.io.IOException
Closes the table access.

Throws:
java.io.IOException - I/O exception

lock

public abstract boolean lock(boolean excl)
Tries to acquires a lock on the table. If a lock exists, it is first released.

Parameters:
excl - exclusive/shared lock
Returns:
success flag

read1

public abstract int read1(int p,
                          int o)
Reads a byte value and returns it as an integer value.

Parameters:
p - pre value
o - offset
Returns:
integer value

read2

public abstract int read2(int p,
                          int o)
Reads a short value and returns it as an integer value.

Parameters:
p - pre value
o - offset
Returns:
integer value

read4

public abstract int read4(int p,
                          int o)
Reads an integer value.

Parameters:
p - pre value
o - offset
Returns:
integer value

read5

public abstract long read5(int p,
                           int o)
Reads a 5-byte value and returns it as a long value.

Parameters:
p - pre value
o - offset
Returns:
integer value

write1

public abstract void write1(int p,
                            int o,
                            int v)
Writes a byte value to the specified position.

Parameters:
p - pre value
o - offset
v - value to be written

write2

public abstract void write2(int p,
                            int o,
                            int v)
Writes a short value to the specified position.

Parameters:
p - pre value
o - offset
v - value to be written

write4

public abstract void write4(int p,
                            int o,
                            int v)
Writes an integer value to the specified position.

Parameters:
p - pre value
o - offset
v - value to be written

write5

public abstract void write5(int p,
                            int o,
                            long v)
Writes a 5-byte value to the specified position.

Parameters:
p - pre value
o - offset
v - value to be written

replace

public final void replace(int pre,
                          byte[] entries,
                          int sub)
Replaces entries in the database.

Parameters:
pre - node to be replaced
entries - new entries
sub - size of the subtree that is replaced

set

public final void set(int pre,
                      byte[] entries)
Copies the specified entries into the database.

Parameters:
pre - pre value
entries - array of bytes containing the entries to insert

copy

protected abstract void copy(byte[] entries,
                             int pre,
                             int last)
Copies the specified values into the database.

Parameters:
entries - entries to copy
pre - first target pre value
last - last pre value

delete

public abstract void delete(int pre,
                            int nr)
Deletes the specified number of entries from the database.

Parameters:
pre - pre value of the first node to delete
nr - number of entries to be deleted

insert

public abstract void insert(int pre,
                            byte[] entries)
Inserts the specified entries into the database.

Parameters:
pre - pre value
entries - array of bytes containing the entries to insert