static PTNode *
createTreeStream( stream & in,
PTNode * parent,
int16 level)
Create a Predicate or Query Tree node from an input stream in, with parent *parent and the level given by level. This static member of PTNode is called before a read from a file is attempted. Before we can use the read() or stream read functions we have to have a PTNode and that is created using this function.
void
read(stream & in)
void
write(stream & out)
Read and write functions. These are virtual in PTNode and have specializations
in all inherited classes.
char *
toString(stringOps what)
toString translates the Predicate nodes to a string. There are only
specializations for the PTLeafNode and PTOpNode classes. This function
is never called for QTNodes and throws an exception otherwise. The enum
stringOps has four values: none, sky, flux, both, indicating which part
of the Predicate String should be returned.
IndexMap
The IndexMap has a build function that is needed since the Indices are persistent in the database (a handle is needed for the federation) and a stream for the Partition Map.
void
build(istream& str, ooHandle(ooFDObj) & fdo)
Intersection and IndexISect
IndexISect has the standard logical operation methods &=, |= and invert() operating on the Sky and Flux Bitlists in a consistent manner. The member function
void
checkConsistency(size_t i)
is used to maintain consistency between the Sky and Flux BitLists (if a Flux BitList is emptied, clear all corresponding Sky Bits and vice versa). We have the usual read() and write() functions, where the input/output is to a stream and the BitLists are compressed. The rest of the functions are
void
init(const BitList & sky, const IndexMap &
indexMap)
This initializes the IndexISect with the given sky BitList and keeps the pointer to the IndexMap because the masks will have to be contacted during logical operations.
bool
isAll(bool val) const
bool
isAll(bool val, size_t fluxID) const
This overloaded function tests whether all bits in the Sky BitList or in the FluxBitList given by fluxID are true or false, as indicated by val.
The Intersection class has the standard &= and |= operator defined. An inversion does not make sense, see Section 4.3. There are several helper methods for these logical operators which are private members:
bool
checkConsistency() const
bool
testFullSky(const IndexISect & isect) const
bool
testFullFlux(const IndexISect & isect) const
int16
test4OR(const Intersection & is) const
void
orInPartial(IndexISect & _inPartial,
const IndexISect & region,
const Intersection & from)
The checkConsistency and testFull functions are doing as their name
says, the test4OR tests for the different cases of OR discussed in section
6.3 and returns a code for the case found. The orInPartial or's in all
bits from from into _inPartial which lies outside region.
BitList and BitListIterator
The following helper functions are provided for the BitList:
void
set( size_t index, bool value) |
Set a bit at a specific index to a given value. If the index is larger than the current size, the BitList expands itself to be able to hold that value at the given index. |
bool
operator [](size_t)
|
Get the bit at a given index. If the index exceeds the size, the return value is false'. All BitLists are treated as if they were of infinite size, all bits set to zero at initialization. |
size_t
size() const |
Get the size of the BitList. At construction time the size may be specified, and that much memory will be allocated. If the construction is done using the set() method, the size is 'minimal' i.e. as much as it needs to hold the last 'true' bit. |
size_t
count() const |
Count the TRUE bits |
size_t trim() | Just chop off all trailing 'false' bits. Returns new size. |
void
clear(bool keepLength = false) |
Clear the list, reset size to 0 by default. If true is given as an argument, the size is kept. |
bool
covers( const BitList & BL) |
Check if BL is a subset of the current list
|
bool
overlaps(const BitList & BL) |
Check if the current BitList overlaps with the other (i.e. they have at least one common Bit) |
void
compress(ostream &) |
Compress to output
|
void
decompress(istream &) |
Decompress from input |
The BitList class comes with the standard &=, |=, ^=, and invert() members. There are also the friend functions
BitList & and (BitList &, const BitList &,
const BitList &);
BitList & or (BitList &, const BitList &,
const BitList &);
BitList & xor (BitList &, const BitList &,
const BitList &);
BitList & not (BitList &, const BitList &);
which place the result into the first argument instead of altering the argument itself.
The constructor of the BitListIterator needs a BitList as an argument
(or if it is constructed without it an assignment has to take place) and
has the members
void setindex(
size_t index) |
Init: set current index |
bool
next( bool bit, size_t & _index)
|
Set the internal index to the next 'true' or 'false' bit, indicated by the first argument, and return the index in the second argument. Returns 'false' if it gets out of bounds. Example: For a BitList 001100110011 (from left to right, index starts at 0), the subsequent call to next(true,index) returns 'true' and sets index to 2, 3, 6, 7, 10, 11. The next call puts leaves index and returns 'false'. A subsequent next() call would again return 'true' and set index=2. |
bool
prev( bool bit, size_t & _index) |
Just like next(), but the index is moved backwards. |
bool
next(bool & bit)
|
Increment the internal index and put the value of the bit it points to into bit. Returns 'false' if the boundary is reached. Example: For a BitList 001100110011 the calls to next(val) return 'true' and set bit to 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1. The next call returns 'false' and does not set bit. A subsequent call would return again 'true' and set bit to the first bit in the list, in this case 0. |
bool
prev(bool & bit) |
Just like next() above, just decrement the internal index. The two versions of next() and prev() may be used in conjunction. |