Fennel: /home/pub/open/dev/fennel/lucidera/colstore/LcsBitOps.h File Reference (original) (raw)

Go to the source code of this file.

Typedefs
typedef uint8_t WidthVec [WIDTH_VECTOR_SIZE]
typedef WidthVec * PWidthVec
typedef uint8_t * PtrVec [WIDTH_VECTOR_SIZE]
typedef PtrVec * PPtrVec
typedef void(*) PBitVecFuncPtr (uint16_t *v, const PtrVec p, uint pos)
typedef void(*) PByteBitVecFuncPtr (uint8_t *v, const PtrVec p, uint pos)
Functions
FENNEL_BEGIN_NAMESPACE void setBits (uint8_t *pB, uint nBits, uint whatBits, uint16_t v)
Sets nBits(1,2,4) starting at whatBits in *pB, from the LSB of v.
void readBits (uint8_t b, uint nBits, uint fromBits, uint16_t *v, uint toBits)
Copies nBits(1,2,4), starting at fromBits from byte B to uint16_t V, starting at toBits.
uint calcWidth (uint n)
Calculates the # of bits it takes to encode n different values correct the number so that no more then 2 vectors (1,2,4,8,16) wide are required.
uint bitVecWidth (uint l, WidthVec w)
uint bitVecPtr (uint iCount, uint iW, WidthVec w, PtrVec p, uint8_t *pVec)
Calculates the offsets of the bitVecs, returns the number of bytes the bitVecs will take.
uint sizeofBitVec (uint nRow, uint iW, WidthVec w)
Returns size of bit vector.
void readBitVecs (uint16_t *v, uint iV, const WidthVec w, const PtrVec p, uint pos, uint count)
Reads bit vectors.
void readBitVec0 (uint16_t *v, const PtrVec p, uint pos)
Sets bit vector to 0.
void readBitVec16 (uint16_t *v, const PtrVec p, uint pos)
Reads one row from a bit vector with 1 or 2 vectors only.
void readBitVec8 (uint16_t *v, const PtrVec p, uint pos)
Reads an 8-bit vector.
void readBitVec4 (uint16_t *v, const PtrVec p, uint pos)
Reads a 4-bit vector.
void readBitVec2 (uint16_t *v, const PtrVec p, uint pos)
Reads a 2-bit vector.
void readBitVec1 (uint16_t *v, const PtrVec p, uint pos)
Reads a 1-bit vector.
void readBitVec12 (uint16_t *v, const PtrVec p, uint pos)
Reads a 12-bit vector (8 bits + 4 bits).
void readBitVec10 (uint16_t *v, const PtrVec p, uint pos)
Reads a 10-bit vector (8 bits + 2 bits).
void readBitVec9 (uint16_t *v, const PtrVec p, uint pos)
Reads a 9-bit vector (8 bits + 1 bit).
void readBitVec6 (uint16_t *v, const PtrVec p, uint pos)
Reads a 6 bit vector (4 bits + 2 bits).
void readBitVec5 (uint16_t *v, const PtrVec p, uint pos)
Reads a 5-bit vector (4 bits + 1 bit).
void readBitVec3 (uint16_t *v, const PtrVec p, uint pos)
Reads a 3-bit vector (2 bits + 1 bit).
Variables
const uint WIDTH_VECTOR_SIZE = 4

Typedef Documentation


Function Documentation

Definition at line 103 of file LcsBitOps.h.

Referenced by LcsClusterDump::dump(), LcsClusterNodeWriter::moveFromIndexToTemp(), LcsClusterNodeWriter::moveFromTempToIndex(), LcsClusterNodeWriter::pickCompressionMode(), LcsClusterNodeWriter::putCompressedBatch(), LcsClusterNodeWriter::rollBackLastBatch(), and LcsColumnReader::sync().

00104 { 00105 uint8_t po2; 00106 uint iW; 00107 WidthVec t; 00108 int i,j; 00109 00110 for (po2 = 1, iW = 0; l ; l >>= 1, po2 *= 2) { 00111 if (l & 0x1) { 00112 t[iW++] = po2; 00113 } 00114 } 00115 00116 for (i = iW - 1, j = 0; i >= 0 ; w[j++] = t[i--]) { 00117 } 00118 return iW; 00119 }

Calculates the # of bits it takes to encode n different values correct the number so that no more then 2 vectors (1,2,4,8,16) wide are required.

Returns:

number of bits required

Definition at line 54 of file LcsBitOps.h.

Referenced by LcsClusterNodeWriter::addValue(), LcsClusterDump::dump(), LcsClusterNodeWriter::moveFromIndexToTemp(), LcsClusterNodeWriter::moveFromTempToIndex(), LcsClusterNodeWriter::rollBackLastBatch(), LcsColumnReader::sync(), and LcsClusterNodeWriter::undoValue().

00055 { 00056 uint w; 00057 00058
00059 w = 0; 00060 if (n > 0) { 00061 n--; 00062 } 00063 while (n) { 00064 w++; 00065 n >>= 1; 00066 } 00067 00068
00069
00070
00071 switch (w) { 00072 case 7: 00073 w = 8; 00074 break; 00075 case 11: 00076 w = 12; 00077 break; 00078 case 13: 00079 case 14: 00080 case 15: 00081 w = 16; 00082 break; 00083 default: 00084 break; 00085 } 00086 00087 return w; 00088 }

Copies nBits(1,2,4), starting at fromBits from byte B to uint16_t V, starting at toBits.

Definition at line 41 of file LcsBitOps.h.

Referenced by readBitVec1(), readBitVec10(), readBitVec12(), readBitVec2(), readBitVec3(), readBitVec4(), readBitVec5(), readBitVec6(), readBitVec9(), and readBitVecs().

00043 { 00044 *v |= (((b & (((1 << nBits) -1) << fromBits)) >> fromBits) << toBits); 00045 }

Sets bit vector to 0.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 246 of file LcsBitOps.h.

Referenced by LcsColumnReader::sync().

00247 { 00248
00249
00250 *v = 0; 00251 }

Reads a 1-bit vector.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 322 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00323 { 00324
00325 *v = 0; 00326 readBits(p[0][pos / 8], 1, pos % 8, v, 0); 00327 }

Reads a 10-bit vector (8 bits + 2 bits).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 353 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00354 { 00355 *v = (p[0] + pos); 00356 readBits(p[1][pos/4], 2, (pos2) % 8, v, 8); 00357 }

Reads a 12-bit vector (8 bits + 4 bits).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 338 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00339 { 00340 *v = (p[0] + pos); 00341 readBits(p[1][pos/2], 4, (pos4) % 8, v, 8); 00342 }

Reads one row from a bit vector with 1 or 2 vectors only.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 262 of file LcsBitOps.h.

Referenced by LcsColumnReader::sync().

00263 { 00264 *v = (p[0] + pos2); 00265 }

Reads a 2-bit vector.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 306 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00307 { 00308
00309 v = 0; 00310 readBits(p[0][pos/4], 2, (pos2) % 8, v, 0); 00311 }

Reads a 3-bit vector (2 bits + 1 bit).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 417 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00418 { 00419
00420 *v = 0; 00421 readBits(p[0][pos / 4], 2, (pos * 2) % 8, v, 0); 00422 readBits(p[1][pos / 8], 1, pos % 8, v, 2); 00423 }

Reads a 4-bit vector.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 290 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00291 { 00292
00293 v = 0; 00294 readBits(p[0][pos/2], 4, (pos4) % 8, v, 0); 00295 }

Reads a 5-bit vector (4 bits + 1 bit).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 400 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00401 { 00402
00403 *v = 0; 00404 readBits(p[0][pos / 2], 4, (pos * 4) % 8, v, 0); 00405 readBits(p[1][pos / 8], 1, pos % 8, v, 4); 00406 }

Reads a 6 bit vector (4 bits + 2 bits).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 383 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00384 { 00385
00386 v = 0; 00387 readBits(p[0][pos/2], 4, (pos4) % 8, v, 0); 00388 readBits(p[1][pos/4], 2, (pos*2) % 8, v, 4); 00389 }

Reads an 8-bit vector.

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 276 of file LcsBitOps.h.

Referenced by LcsColumnReader::sync().

00277 { 00278 *v = *(p[0] + pos); 00279 }

Reads a 9-bit vector (8 bits + 1 bit).

Parameters:

v destination of ref numbers
p bitVec offsets
pos first row of interest

Definition at line 368 of file LcsBitOps.h.

References readBits().

Referenced by LcsColumnReader::sync().

00369 { 00370 *v = *(p[0] + pos); 00371 readBits(p[1][pos / 8], 1, pos % 8, v, 8); 00372 }

Reads bit vectors.

Parameters:

v destination of ref numbers
iV # of bit vectors
w bitVec width vector
p bitVec offsets
pos first row of interest
count how many rows to read

Definition at line 184 of file LcsBitOps.h.

References readBits().

Referenced by LcsClusterDump::dump(), LcsColumnReader::readCompressedBatch(), and LcsClusterNodeWriter::rollBackLastBatch().

00187 { 00188 uint i, j, k; 00189 uint b; 00190 00191
00192 memset(v, 0, sizeof(uint16_t) * count); 00193 00194
00195 for (i = 0, b = 0; i < iV; i++) { 00196
00197
00198
00199 switch (w[i]) { 00200 case 16: 00201 memcpy(v, p[i] + pos2, sizeof(uint16_t) * count); 00202 break; 00203 00204 case 8: 00205 for (j = 0; j < count; j++) { 00206 v[j] = (p[i] + pos)[j]; 00207 } 00208 break; 00209 00210 case 4: 00211 for (j = 0, k = pos4; j < count; j++, k += 4) { 00212 readBits(p[i][k / 8], 4, k % 8, &v[j], b); 00213 } 00214 break; 00215 00216 case 2: 00217 for (j = 0, k = pos*2; j < count; j++, k += 2) { 00218 readBits(p[i][k / 8], 2, k % 8, &v[j], b); 00219 } 00220 break; 00221 00222 case 1: 00223 for (j = 0, k = pos; j < count; j++, k++) { 00224 readBits(p[i][k / 8], 1, k % 8, &v[j], b); 00225 } 00226 break; 00227 00228 default: 00229 assert(false);
00230 break; 00231 } 00232 00233 b += w[i]; 00234 } 00235 }

Returns size of bit vector.

Parameters:

nRow number of rows
iW size of the vectors
w bitVec width vector

Definition at line 158 of file LcsBitOps.h.

Referenced by LcsClusterNodeWriter::pickCompressionMode().

00159 { 00160 uint t; 00161 uint i; 00162 00163 for (i = 0, t = 0; i < iW; i++) { 00164 t += ((w[i] * nRow + 7) / 8); 00165 } 00166 return t; 00167 }


Variable Documentation


Generated on Mon Jun 22 04:00:22 2009 for Fennel by doxygen 1.5.1