de.lmu.ifi.dbs.elki.persistent
Class OnDiskUpperTriangleMatrix

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.persistent.OnDiskUpperTriangleMatrix

public class OnDiskUpperTriangleMatrix
extends Object

Class representing an upper triangle matrix backed by an on-disk array of O((n+1)*n/2) size


Field Summary
private  OnDiskArray array
          Data storage
private  int matrixsize
          Size of the matrix
private static long serialVersionUID
          Serial number, also used for generating a magic
private static int TRIANGLE_HEADER_SIZE
          Size of this class' header
 
Constructor Summary
OnDiskUpperTriangleMatrix(File filename, int magicseed, int extraheadersize, int recordsize, boolean writable)
          Constructor to access an existing array.
OnDiskUpperTriangleMatrix(File filename, int magicseed, int extraheadersize, int recordsize, int matrixsize)
          Constructor to access a new array.
 
Method Summary
private static int arraysize(int matrixsize)
          Compute the size of the needed backing array from the matrix dimensions.
 void close()
          Close the matrix file.
private  int computeOffset(int x, int y)
          Compute the offset within the file.
 int getMatrixSize()
          Query the size of the matrix.
 ByteBuffer getRecordBuffer(int x, int y)
          Get a record buffer
 void resizeMatrix(int newsize)
          Resize the matrix to cover newsize x newsize.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial number, also used for generating a magic

See Also:
Constant Field Values

TRIANGLE_HEADER_SIZE

private static final int TRIANGLE_HEADER_SIZE
Size of this class' header

See Also:
Constant Field Values

matrixsize

private int matrixsize
Size of the matrix


array

private OnDiskArray array
Data storage

Constructor Detail

OnDiskUpperTriangleMatrix

public OnDiskUpperTriangleMatrix(File filename,
                                 int magicseed,
                                 int extraheadersize,
                                 int recordsize,
                                 boolean writable)
                          throws IOException
Constructor to access an existing array.

Parameters:
filename - File name
magicseed - Magic number
extraheadersize - Size of extra header data
recordsize - Record size
writable - flag to open writable
Throws:
IOException - on IO errors

OnDiskUpperTriangleMatrix

public OnDiskUpperTriangleMatrix(File filename,
                                 int magicseed,
                                 int extraheadersize,
                                 int recordsize,
                                 int matrixsize)
                          throws IOException
Constructor to access a new array.

Parameters:
filename - File name
magicseed - Magic number
extraheadersize - Size of extra header data
recordsize - Record size
matrixsize - Size of matrix to store
Throws:
IOException - on IO errors
Method Detail

resizeMatrix

public void resizeMatrix(int newsize)
                  throws IOException
Resize the matrix to cover newsize x newsize.

Parameters:
newsize - New matrix size.
Throws:
IOException - on IO errors

arraysize

private static int arraysize(int matrixsize)
Compute the size of the needed backing array from the matrix dimensions.

Parameters:
matrixsize - size of the matrix
Returns:
size of the array

computeOffset

private int computeOffset(int x,
                          int y)
Compute the offset within the file.

Parameters:
x - First coordinate
y - Second coordinate
Returns:
Linear offset

getRecordBuffer

public ByteBuffer getRecordBuffer(int x,
                                  int y)
                           throws IOException
Get a record buffer

Parameters:
x - First coordinate
y - Second coordinate
Returns:
Byte buffer for the record
Throws:
IOException - on IO errors

close

public void close()
           throws IOException
Close the matrix file.

Throws:
IOException - on IO errors

getMatrixSize

public int getMatrixSize()
Query the size of the matrix.

Returns:
size of the matrix

Release 0.4.0 (2011-09-20_1324)