|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unipi.di.textdb.TextDB
it.unipi.di.textdb.GZipFileCursor
public class GZipFileCursor
A forward only cursor over a GZip compressed file, implemented using the
standard interface to ZLib provided by the package java.util.zip.
Zip file format is also supported but, in this case, the compression and access is made using the JCraft library,
a 100% pure Java implementation of ZLib (see the JCraft home page).
NOTE: The JCraft library doesn't support the GZip format instead.
Field Summary |
---|
Fields inherited from class it.unipi.di.textdb.TextDB |
---|
DEFAULT_FIELD_SEPARATOR |
Constructor Summary | |
---|---|
GZipFileCursor(String filename)
Creates an instance of a GZipFileCursor over a zip or gzip compressed file. |
Method Summary | |
---|---|
TextDB |
build(PrintStream log)
Create a TextDB compressing the input file with GZip. |
static TextDB |
build(String filename,
boolean useZip)
Create a TextDB compressing the input file with GZip (optionally Zip). |
void |
close()
Closes the TextDB and releases all of its resources. |
String |
get(int record)
Returns the String in position pos for this compressed TextDB. |
int |
getCurrentPos()
Returns the current record position. |
String |
getCurrentValue()
Returns the content of the current record. |
String[] |
getRange(int i,
int j)
Returns the records having positions from i to j in the TextDB. |
String[] |
getSequential(int[] records)
Given a sorted array of record positions, this method returns all of them. |
String[] |
getSequential(int[] records,
int pos,
int length)
Given an array of record positions containing a sorted subrange defined by the parameters pos and length ,
this method returns the records for such positions. |
void |
getSequential(int[] records,
int field,
PrintStream out)
Given a sorted array of record positions and the position of a field, this method retrieves the specified field from those records. |
static void |
main(String[] args)
|
String |
next()
Moves the cursor on the next record and returns it. |
String |
next(int pos)
Moves the cursor on a specified record and returns it. |
void |
open()
Opens the TextDB. |
int |
size()
It always returns zero. |
Methods inherited from class it.unipi.di.textdb.TextDB |
---|
build, fromTDBFile, get, getFieldValues, getName, getRange, getRecordFields, getSequential, setFieldSeparator |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GZipFileCursor(String filename)
filename
- the TDB file containing the compressed fileMethod Detail |
---|
public void open() throws IOException
TextDB
open
in class TextDB
IOException
public String next() throws IOException
IOException
public String next(int pos) throws IOException
pos
- the position of the record where to move this cursor
IOException
public int getCurrentPos()
public String getCurrentValue()
public void close() throws IOException
TextDB
close
in class TextDB
IOException
public String get(int record) throws IOException
get
in class TextDB
record
- a position in the range [0, N-1]
IOException
public int size()
size
in class TextDB
public String[] getRange(int i, int j) throws IOException
TextDB
getRange
in class TextDB
i
- the starting position of the records to retrieve (inclusive)j
- the ending position of the records to retrieve (inclusive)
IOException
public String[] getSequential(int[] records) throws IOException
TextDB
getSequential
in class TextDB
records
- a sorted array of record positions
IOException
public String[] getSequential(int[] records, int pos, int length) throws IOException
TextDB
pos
and length
,
this method returns the records for such positions.
records[pos]
(included) to records[pos+length]
(exluded).
getSequential
in class TextDB
records
- array with a sorted subrange of records positionspos
- the starting position of the subrangelength
- the length of the subrange
IOException
public void getSequential(int[] records, int field, PrintStream out) throws IOException
TextDB
TextDB.getField(String, int)
provided by
this abstract class that selects a field of a record through a sequential access
to the record itself. The use of a more efficient implementation of this function
is encouraged.
getSequential
in class TextDB
records
- a sorted array of record positionsfield
- the position of the field to extract, or -1 to dump all fieldsout
- the output PrintStream
IOException
public static TextDB build(String filename, boolean useZip) throws IOException
filename
- the file to compressuseZip
- if true compress with zip (--best) instead of gzip
IOException
public TextDB build(PrintStream log) throws IOException
build
in class TextDB
log
- this parameter is not used
IOException
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |