|
||||||||||
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.BucketedZip
public class BucketedZip
This is a TextDB
which uses a combination of a bucketing scheme
and the Zip data compression technique. A bucket is defined
as a fixed-number of contiguous records. Each bucket is compressed with
Zip (thus it has variable length),
and may be accessed via a pointer (also called jumper) kept in a
file on disk.
At query time the bucket containing the requested record is identified,
using its corresponding jumper, loaded in memory and (fully-)uncompressed until
the requested record is met.
ExternalSort
Field Summary | |
---|---|
static int |
DEFAULT_BUCKET_SIZE
|
static int |
DEFAULT_COMPRESSION_LEVEL
|
Fields inherited from class it.unipi.di.textdb.TextDB |
---|
DEFAULT_FIELD_SEPARATOR, fieldSeparator, filename |
Constructor Summary | |
---|---|
BucketedZip(String filename)
Create a new BucketedZip object loading the needed data structures from the provided file. |
Method Summary | |
---|---|
TextDB |
build(String outfile,
PrintStream log)
Builds the TextDB over the textual file identified by the filename string used in the constructor (see TextDB.TextDB(String) ). |
static TextDB |
build(String inputfile,
String outfile,
int bucketSize,
int level,
PrintStream log)
Build a BucketedZip over an input file. |
void |
close()
Closes the TextDB and releases all of its resources. |
String |
get(int record)
Returns the record for a given position in the range [0, N-1], where N is the number of records present in the TextDB. |
String[] |
getRange(int i,
int j)
Returns the records having positions from i to j in the TextDB. |
void |
getRange(int i,
int j,
int field,
BufferedWriter out)
Print on the passed PrintStream the specified field for the records in the range [i,j]. |
String[] |
getSequential(int[] records)
Given a sorted array of record positions, this method returns all of them. |
void |
getSequential(int[] records,
int field,
BufferedWriter out)
Given a sorted array of record positions and the position of a field, this method retrieves the specified field from those records. |
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. |
static void |
main(String[] args)
|
void |
open()
Opens the TextDB. |
int |
size()
Returns the number of records contained in this TextDB. |
Methods inherited from class it.unipi.di.textdb.TextDB |
---|
build, fromTDBFile, get, getField, getFieldValues, getName, getRange, getRecordFields, getSequential, setFieldSeparator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUCKET_SIZE
public static final int DEFAULT_COMPRESSION_LEVEL
Constructor Detail |
---|
public BucketedZip(String filename)
filename
- the file containing the content and the data structures to load, stored in TDB formatMethod Detail |
---|
public void close() throws IOException
TextDB
close
in class TextDB
IOException
public int size()
TextDB
size
in class TextDB
public String get(int record) throws IOException
TextDB
get
in class TextDB
record
- a position in the range [0, N-1]
IOException
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 void getRange(int i, int j, int field, BufferedWriter out) throws IOException
TextDB
PrintStream
the specified field for the records in the range [i,j].
If not present, an empty line will be dumped out.
getRange
in class TextDB
i
- the starting position of the records to be fetched (included)j
- the ending position of the records to be fetched (included)field
- the position (counting from 0) of the field to return for all the records in range, or -1 to retrieve the entire recordout
- the output BufferedWriter
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, BufferedWriter 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 BufferedWriter
IOException
public void open() throws IOException
TextDB
open
in class TextDB
IOException
public static TextDB build(String inputfile, String outfile, int bucketSize, int level, PrintStream log) throws IOException
inputfile
- the file to compressoutfile
- the output file namebucketSize
- the maximum size (in the number of records) of each bucketlevel
- the compression level (from 0 = FASTEST to 9 = BEST COMPRESSION)log
- a PrintStream
where to send the log messages. If null that messages will be suppressed
IOException
public TextDB build(String outfile, PrintStream log) throws IOException
TextDB
TextDB.TextDB(String)
).
This method runs a build process with default values for all input parameters.
PrintStream
, or suppressed
if the passed reference is null.
build
in class TextDB
outfile
- The output file name.log
- a PrintStream for log messages. A null value will suppress any output message
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 |