LbmByteSegment Class Reference

This class encapsulates a single byte segment, as opposed to a tuple which contains a set of them. More...

#include <LbmByteSegment.h>

List of all members.

Public Member Functions

void reset ()
LcsRid getSrid () const
 Returns the Srid of the starting byte (not the first rid set).
bool isNull () const
 Whether the segment has valid data.
LbmByteNumber getEnd () const
 Returns the end byte number.
LcsRid getEndRid () const
 Returns the end rid (one past last valid rid).
void advanceToByteNum (LbmByteNumber newStartByteNum)
 Ensures the segment begins with the requested byte number.
uint countBits ()
 Count the number of bits in the current byte segment.
void print (std::ostream &output)
 Prints a byte segment.

Static Public Member Functions

static uint countBits (TupleDatum const &datum)
 Counts the number of rows represented by a bitmap datum.
static uint countBits (PConstBuffer pBuf, uint len)
 Counts the number of bits in an array.
static void verifyBitsInByte ()

Public Attributes

LbmByteNumber byteNum
PBuffer byteSeg
uint len

Static Public Attributes

static const uint bitsInByte []
 This array quickly dertermines how many bits are set in a byte.


Detailed Description

This class encapsulates a single byte segment, as opposed to a tuple which contains a set of them.

Definition at line 35 of file LbmByteSegment.h.


Member Function Documentation

void LbmByteSegment::reset (  )  [inline]

Definition at line 44 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::getSegment(), and LbmUnionWorkspace::reset().

00045     {
00046         byteNum = (LbmByteNumber) 0;
00047         byteSeg = NULL;
00048         len = 0;
00049     }

LcsRid LbmByteSegment::getSrid (  )  const [inline]

Returns the Srid of the starting byte (not the first rid set).

Definition at line 54 of file LbmByteSegment.h.

References byteNumberToRid().

Referenced by LbmUnionExecStream::transfer(), and LbmChopperExecStream::writeSegment().

00055     {
00056         return byteNumberToRid(byteNum);
00057     }

bool LbmByteSegment::isNull (  )  const [inline]

Whether the segment has valid data.

Definition at line 62 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::addSegment().

00063     {
00064         return byteSeg == NULL;
00065     }

LbmByteNumber LbmByteSegment::getEnd (  )  const [inline]

Returns the end byte number.

Definition at line 70 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::addSegment().

00071     {
00072         return byteNum + len;
00073     }

LcsRid LbmByteSegment::getEndRid (  )  const [inline]

Returns the end rid (one past last valid rid).

Definition at line 78 of file LbmByteSegment.h.

References byteNumberToRid().

Referenced by LbmChopperExecStream::writeSegment().

00079     {
00080         return byteNumberToRid(getEnd());
00081     }

void LbmByteSegment::advanceToByteNum ( LbmByteNumber  newStartByteNum  )  [inline]

Ensures the segment begins with the requested byte number.

As a result, the beginning of the segment or even the entire segment may be truncated.

This function assumes bytes are reverse order.

Definition at line 90 of file LbmByteSegment.h.

References opaqueToInt().

Referenced by LbmUnionWorkspace::addSegment().

00091     {
00092         // ignore null values
00093         if (isNull()) {
00094             return;
00095         }
00096 
00097         // check if the segment will have valid data after truncation
00098         if (getEnd() <= newStartByteNum) {
00099             reset();
00100             return;
00101         }
00102 
00103         // advance the segment in place if required
00104         if (byteNum < newStartByteNum) {
00105             uint diff = opaqueToInt(newStartByteNum - byteNum);
00106             byteNum += diff;
00107             byteSeg -= diff;
00108             len -= diff;
00109         }
00110     }

uint LbmByteSegment::countBits (  )  [inline]

Count the number of bits in the current byte segment.

Definition at line 115 of file LbmByteSegment.h.

Referenced by LbmNormalizerExecStream::readSegment(), and LbmRepeatingAggComputer::updateAccumulator().

00116     {
00117         return countBits(byteSeg - len + 1, len);
00118     }

static uint LbmByteSegment::countBits ( TupleDatum const &  datum  )  [inline, static]

Counts the number of rows represented by a bitmap datum.

An empty datum represents a single row.

Definition at line 124 of file LbmByteSegment.h.

References TupleDatum::cbData, and TupleDatum::pData.

00125     {
00126         if (datum.pData == NULL || datum.cbData == 0) {
00127             return 1;
00128         }
00129         return countBits(datum.pData, datum.cbData);
00130     }

static uint LbmByteSegment::countBits ( PConstBuffer  pBuf,
uint  len 
) [inline, static]

Counts the number of bits in an array.

Definition at line 135 of file LbmByteSegment.h.

00136     {
00137         uint total = 0;
00138         for (uint i = 0; i < len; i++) {
00139             total += bitsInByte[pBuf[i]];
00140         }
00141         return total;
00142     }

static void LbmByteSegment::verifyBitsInByte (  )  [inline, static]

Definition at line 144 of file LbmByteSegment.h.

Referenced by LbmNormalizerExecStreamTest::testBitsInByte().

00145     {
00146         for (uint i = 0; i < 256; i++) {
00147             uint slowBits = 0;
00148             for (uint j = 0; j < 8; j++) {
00149                 if (i & (1 << j)) {
00150                     slowBits++;
00151                 }
00152             }
00153             assert (slowBits == bitsInByte[i]);
00154         }
00155     }

void LbmByteSegment::print ( std::ostream &  output  )  [inline]

Prints a byte segment.

This function assumes bytes are in order.

Definition at line 162 of file LbmByteSegment.h.

References opaqueToInt().

00163     {
00164         output << std::dec << opaqueToInt(byteNum) << ".";
00165         output << std::dec << len << " (";
00166         for (uint i = 0; i < len; i++) {
00167             uint val = byteSeg[i];
00168             if (i > 0) {
00169                 output << ",";
00170             }
00171             output << std::hex << val;
00172         }
00173         output << ")" << std::endl;
00174     }


Member Data Documentation

const uint LbmByteSegment::bitsInByte [static]

This array quickly dertermines how many bits are set in a byte.

Definition at line 38 of file LbmByteSegment.h.

LbmByteNumber LbmByteSegment::byteNum

Definition at line 40 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::addSegment(), LbmUnionWorkspace::advancePastSegment(), LbmUnionWorkspace::getSegment(), LbmUnionExecStream::readSegment(), LbmNormalizerExecStream::readSegment(), and LbmChopperExecStream::readSegment().

PBuffer LbmByteSegment::byteSeg

Definition at line 41 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::addSegment(), LbmUnionWorkspace::getSegment(), LbmUnionExecStream::readSegment(), LbmNormalizerExecStream::readSegment(), LbmChopperExecStream::readSegment(), LbmUnionExecStream::transfer(), and LbmChopperExecStream::writeSegment().

uint LbmByteSegment::len

Definition at line 42 of file LbmByteSegment.h.

Referenced by LbmUnionWorkspace::addSegment(), LbmUnionWorkspace::advancePastSegment(), LbmUnionWorkspace::getSegment(), LbmUnionExecStream::readSegment(), LbmNormalizerExecStream::readSegment(), LbmChopperExecStream::readSegment(), LbmUnionExecStream::transfer(), and LbmChopperExecStream::writeSegment().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:33 2009 for Fennel by  doxygen 1.5.1