de.uni_leipzig.asv.coocc
Class BinFileMultColFile

java.lang.Object
  extended byde.uni_leipzig.asv.coocc.BinFileMultColFile
All Implemented Interfaces:
BinFileMultCol

public class BinFileMultColFile
extends Object
implements BinFileMultCol

This class gives access to collocations which is slower but less memory-intense. It loads up only the index file and operates on the file per random accesses.


Field Summary
protected  int columns
          The number of columns to assume
protected  RandomAccessFile dataFileReader
          This represents the datafile
protected  byte[] indexFile
          This is the indexfile which is loaded into memory
 
Constructor Summary
BinFileMultColFile(String fileName, int columns)
          Sole constructor.
 
Method Summary
static boolean existsFileDump(String fileName)
          Tests, whether the required files for this class, given with the fileName exist and are not of null-length (like after a failed start of FilePreparer
 List getData(Integer wordNr)
          For a given number returns the row
 List getData(Integer number, int maxItems)
          Returns the data for the given number up to the given maximum.
 List getData(Integer number, int myColumns, int maxItems)
          Returns the data for the given number up to the given maximum.
 List getData(Integer number, int maxItems, int[] minCols, int[] maxCols)
          Returns the data for the given number up to the given maximum in a list.
 List getData(Integer number, int myColumns, int maxItems, int[] minCols, int[] maxCols)
          Returns the data for the given number up to the given maximum.
 Map getDataAsMap(Integer wordNr)
          Returns the data for the given number up to the given maximum in a map.
 Map getDataAsMap(Integer number, int maxItems)
          Returns the data for the given number up to the given maximum in a map.
 Map getDataAsMap(Integer number, int myColumns, int maxItems)
          Returns the data for the given number up to the given maximum.
 Map getDataAsMap(Integer number, int maxItems, int[] minCols, int[] maxCols)
          Returns the data for the given number up to the given maximum in a map.
 Map getDataAsMap(Integer number, int myColumns, int maxItems, int[] minCols, int[] maxCols)
          Returns the data for the given number up to the given maximum in a map.
 List getSingleColumn(Integer number, int col)
          Column here is the column in the initial datafile, count begins with 1.
 List getSingleColumn(Integer number, int maxItems, int col)
           
static void main(String[] args)
          With this main method it's possible to test a prepared file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexFile

protected byte[] indexFile
This is the indexfile which is loaded into memory


dataFileReader

protected RandomAccessFile dataFileReader
This represents the datafile


columns

protected int columns
The number of columns to assume

Constructor Detail

BinFileMultColFile

public BinFileMultColFile(String fileName,
                          int columns)
Sole constructor. Reads the index after which it is ready to deliver data.

Parameters:
fileName -
columns - How many columns the original file had (must match exactly!)
Method Detail

existsFileDump

public static boolean existsFileDump(String fileName)
Tests, whether the required files for this class, given with the fileName exist and are not of null-length (like after a failed start of FilePreparer

Parameters:
fileName - relative or absolute filename without index or data extensions
Returns:

getData

public List getData(Integer wordNr)
For a given number returns the row

Specified by:
getData in interface BinFileMultCol
Parameters:
wordNr - Integer
Returns:
List::Integer[]

getData

public List getData(Integer number,
                    int maxItems)
Returns the data for the given number up to the given maximum.

Specified by:
getData in interface BinFileMultCol
Parameters:
maxItems -
Returns:

getData

public List getData(Integer number,
                    int myColumns,
                    int maxItems)
Returns the data for the given number up to the given maximum.

Specified by:
getData in interface BinFileMultCol
Parameters:
number - = the first column
myColumns - = how many columns to return
maxItems - = at max this count of items
Returns:

getData

public List getData(Integer number,
                    int myColumns,
                    int maxItems,
                    int[] minCols,
                    int[] maxCols)
Returns the data for the given number up to the given maximum.

Specified by:
getData in interface BinFileMultCol
Parameters:
number - = the first column
myColumns - = how many columns to return
maxItems - = at max this count of items
minCols - = for each column each value minimum is specified here
maxCols - = for each column each value maximum is specified here
Returns:

getData

public List getData(Integer number,
                    int maxItems,
                    int[] minCols,
                    int[] maxCols)
Returns the data for the given number up to the given maximum in a list.

Specified by:
getData in interface BinFileMultCol
Parameters:
maxItems - How many items to return at max
minCols - for each column the minimum allowed value (the whoe row will otherwise be omitted)
maxCols - for each column the maximum allowed value (the whoe row will otherwise be omitted)
Returns:
List::Integer[]

getDataAsMap

public Map getDataAsMap(Integer wordNr)
Returns the data for the given number up to the given maximum in a map.

Specified by:
getDataAsMap in interface BinFileMultCol
Parameters:
wordNr - The number of the item of which to return the columns
Returns:
Map::Integer->Integer[]

getDataAsMap

public Map getDataAsMap(Integer number,
                        int myColumns,
                        int maxItems)
Returns the data for the given number up to the given maximum.

Specified by:
getDataAsMap in interface BinFileMultCol
Parameters:
myColumns - How many columns to return
maxItems - How many items to return at max
Returns:
Map::Integer->Integer[]

getDataAsMap

public Map getDataAsMap(Integer number,
                        int maxItems)
Returns the data for the given number up to the given maximum in a map.

Specified by:
getDataAsMap in interface BinFileMultCol
Parameters:
maxItems - How many items to return at max
Returns:
Map::Integer->Integer[]

getDataAsMap

public Map getDataAsMap(Integer number,
                        int myColumns,
                        int maxItems,
                        int[] minCols,
                        int[] maxCols)
Returns the data for the given number up to the given maximum in a map.

Specified by:
getDataAsMap in interface BinFileMultCol
Parameters:
myColumns - How many columns to return
maxItems - How many items to return at max
minCols - for each column the minimum allowed value (the whoe row will otherwise be omitted)
maxCols - for each column the maximum allowed value (the whoe row will otherwise be omitted)
Returns:
Map::Integer->Integer[]

getDataAsMap

public Map getDataAsMap(Integer number,
                        int maxItems,
                        int[] minCols,
                        int[] maxCols)
Returns the data for the given number up to the given maximum in a map.

Specified by:
getDataAsMap in interface BinFileMultCol
Parameters:
maxItems - How many items to return at max otherwise be omitted)
maxCols - for each column the maximum allowed value (the whoe row will otherwise be omitted)
Returns:
Map::Integer->Integer[]

getSingleColumn

public List getSingleColumn(Integer number,
                            int col)
Column here is the column in the initial datafile, count begins with 1. Return the specified column completely.

Specified by:
getSingleColumn in interface BinFileMultCol
Parameters:
number -
col -
Returns:
List::Integer

getSingleColumn

public List getSingleColumn(Integer number,
                            int maxItems,
                            int col)
Specified by:
getSingleColumn in interface BinFileMultCol

main

public static void main(String[] args)
With this main method it's possible to test a prepared file. It will print some testcases. Takes two parameters, first is the filename, the second is the number of columns the has. The third is the number of columns to return.

Parameters:
args - String[]