Package org.basex.io.random
Class TableAccess
java.lang.Object
org.basex.io.random.TableAccess
- Direct Known Subclasses:
TableDiskAccess,TableMemAccess
This abstract class defines the methods for accessing the
database table representation.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Closes the table access.protected abstract voidcopy(byte[] entries, int pre, int last) Copies the specified values into the database.abstract voiddelete(int pre, int count) Deletes the specified number of entries from the database.protected abstract voiddirty()Marks the data structures as dirty.abstract voidflush(boolean all) Flushes the table contents.abstract voidinsert(int pre, byte[] entries) Inserts the specified entries into the database.abstract booleanlock(boolean write) Tries to acquires a lock on the table.abstract intread1(int pre, int offset) Reads a byte value and returns it as an integer value.abstract intread2(int pre, int offset) Reads a short value and returns it as an integer value.abstract intread4(int pre, int offset) Reads an integer value.abstract longread5(int pre, int offset) Reads a 5-byte value and returns it as a long value.final voidreplace(int pre, byte[] entries, int count) Replaces entries in the database.abstract voidwrite1(int pre, int offset, int value) Writes a byte value to the specified position.abstract voidwrite2(int pre, int offset, int value) Writes a short value to the specified position.abstract voidwrite4(int pre, int offset, int value) Writes an integer value to the specified position.abstract voidwrite5(int pre, int offset, long value) Writes a 5-byte value to the specified position.
-
Method Details
-
flush
Flushes the table contents.- Parameters:
all- flush all contents or only buffers- Throws:
IOException- I/O exception
-
close
Closes the table access.- Throws:
IOException- I/O exception
-
lock
public abstract boolean lock(boolean write) Tries to acquires a lock on the table. If a lock exists, it is first released.- Parameters:
write- write/read lock- Returns:
- success flag
-
read1
public abstract int read1(int pre, int offset) Reads a byte value and returns it as an integer value.- Parameters:
pre- pre valueoffset- offset- Returns:
- integer value
-
read2
public abstract int read2(int pre, int offset) Reads a short value and returns it as an integer value.- Parameters:
pre- pre valueoffset- offset- Returns:
- integer value
-
read4
public abstract int read4(int pre, int offset) Reads an integer value.- Parameters:
pre- pre valueoffset- offset- Returns:
- integer value
-
read5
public abstract long read5(int pre, int offset) Reads a 5-byte value and returns it as a long value.- Parameters:
pre- pre valueoffset- offset- Returns:
- integer value
-
write1
public abstract void write1(int pre, int offset, int value) Writes a byte value to the specified position.- Parameters:
pre- pre valueoffset- offsetvalue- value to be written
-
write2
public abstract void write2(int pre, int offset, int value) Writes a short value to the specified position.- Parameters:
pre- pre valueoffset- offsetvalue- value to be written
-
write4
public abstract void write4(int pre, int offset, int value) Writes an integer value to the specified position.- Parameters:
pre- pre valueoffset- offsetvalue- value to be written
-
write5
public abstract void write5(int pre, int offset, long value) Writes a 5-byte value to the specified position.- Parameters:
pre- pre valueoffset- offsetvalue- value to be written
-
replace
public final void replace(int pre, byte[] entries, int count) Replaces entries in the database.- Parameters:
pre- node to be replacedentries- new entriescount- number of entries to be replaced
-
dirty
protected abstract void dirty()Marks the data structures as dirty. -
copy
protected abstract void copy(byte[] entries, int pre, int last) Copies the specified values into the database.- Parameters:
entries- entries to copypre- first target pre valuelast- last pre value
-
delete
public abstract void delete(int pre, int count) Deletes the specified number of entries from the database.- Parameters:
pre- pre value of the first node to deletecount- 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 valueentries- array of bytes containing the entries to insert
-