org.basex.io
Class TableDiskAccess

java.lang.Object
  extended by org.basex.io.TableAccess
      extended by org.basex.io.TableDiskAccess

public final class TableDiskAccess
extends TableAccess

This class stores the table on disk and reads it block-wise.

Author:
Workgroup DBIS, University of Konstanz 2005-08, ISC License, Christian Gruen, Tim Petrowsky

Constructor Summary
TableDiskAccess(java.lang.String nm, java.lang.String f)
          Constructor.
 
Method Summary
 int blocks()
          Return the number of used blocks; needed for JUnit tests.
 void close()
          Closes the table access.
 void delete(int first, int nr)
          Delete a range of entries.
 void flush()
          Flushes the table contents.
 void insert(int pre, byte[] entries)
          Insert entries.
 int read1(int pos, int off)
          Reads a byte from the specified position and returns it as integer.
 int read2(int pos, int off)
          Reads a short value from the specified position and returns it as integer.
 int read4(int pos, int off)
          Reads an integer value from the specified position.
 long read5(int pos, int off)
          Reads an integer value from the specified position.
 int size()
          Return the entryCount; needed for JUnit tests.
 void write1(int pos, int off, int v)
          Writes a byte to the specified position.
 void write2(int pos, int off, int v)
          Writes 2 bytes to the specified position.
 void write4(int pos, int off, int v)
          Writes an integer value to the specified position.
 void write5(int pos, int off, long v)
          Writes a 5-byte value to the specified position.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableDiskAccess

public TableDiskAccess(java.lang.String nm,
                       java.lang.String f)
                throws java.io.IOException
Constructor.

Parameters:
nm - name of the database
f - prefix for all files (no ending)
Throws:
java.io.IOException - in case files cannot be read
Method Detail

flush

public void flush()
           throws java.io.IOException
Description copied from class: TableAccess
Flushes the table contents.

Specified by:
flush in class TableAccess
Throws:
java.io.IOException - in case of write errors

close

public void close()
           throws java.io.IOException
Description copied from class: TableAccess
Closes the table access.

Specified by:
close in class TableAccess
Throws:
java.io.IOException - in case of write errors

read1

public int read1(int pos,
                 int off)
Description copied from class: TableAccess
Reads a byte from the specified position and returns it as integer.

Specified by:
read1 in class TableAccess
Parameters:
pos - pre value
off - offset
Returns:
integer value

read2

public int read2(int pos,
                 int off)
Description copied from class: TableAccess
Reads a short value from the specified position and returns it as integer.

Specified by:
read2 in class TableAccess
Parameters:
pos - pre value
off - offset
Returns:
integer value

read4

public int read4(int pos,
                 int off)
Description copied from class: TableAccess
Reads an integer value from the specified position.

Specified by:
read4 in class TableAccess
Parameters:
pos - pre value
off - offset
Returns:
integer value

read5

public long read5(int pos,
                  int off)
Description copied from class: TableAccess
Reads an integer value from the specified position.

Specified by:
read5 in class TableAccess
Parameters:
pos - pre value
off - offset
Returns:
integer value

write1

public void write1(int pos,
                   int off,
                   int v)
Description copied from class: TableAccess
Writes a byte to the specified position.

Specified by:
write1 in class TableAccess
Parameters:
pos - pre value
off - offset
v - value to be written

write2

public void write2(int pos,
                   int off,
                   int v)
Description copied from class: TableAccess
Writes 2 bytes to the specified position.

Specified by:
write2 in class TableAccess
Parameters:
pos - pre value
off - offset
v - value to be written

write4

public void write4(int pos,
                   int off,
                   int v)
Description copied from class: TableAccess
Writes an integer value to the specified position.

Specified by:
write4 in class TableAccess
Parameters:
pos - pre value
off - offset
v - value to be written

write5

public void write5(int pos,
                   int off,
                   long v)
Description copied from class: TableAccess
Writes a 5-byte value to the specified position.

Specified by:
write5 in class TableAccess
Parameters:
pos - pre value
off - offset
v - value to be written

delete

public void delete(int first,
                   int nr)
Description copied from class: TableAccess
Delete a range of entries.

Specified by:
delete in class TableAccess
Parameters:
first - pre value of the first node to delete
nr - number of entries to be deleted

insert

public void insert(int pre,
                   byte[] entries)
Description copied from class: TableAccess
Insert entries.

Specified by:
insert in class TableAccess
Parameters:
pre - pre value of node to insert after
entries - array of bytes containing the entries to insert

size

public int size()
Return the entryCount; needed for JUnit tests.

Returns:
number of entries in storage.

blocks

public int blocks()
Return the number of used blocks; needed for JUnit tests.

Returns:
number of used blocks.