-
Notifications
You must be signed in to change notification settings - Fork 6
4.Rows
Rows table corresponds to the rows of original table, each "row" of the rows table consists on "RecordByteSize" bytes. Rows table contains "NumberOfRecords" rows.
Each row consists of the bit indices into the symbol tables, each bit index is unsigned integer (not longer then 32 bits). Width of individual bit index is specified in the "BitWidth" tag of corresponding column metadata.
Columns in bit index row are logically ordered: rightmost column has "BitOffset" of "0". Leftmost column (first column in the bit index row) will have the maximum "BitOffset".
When reading bytes for the row from QVD file we should reverse them - first byte read contains least significant bits of the last logical field, next byte read contains more significant bytes of the last logical field (in the case of width greater then 8), etc.
If table column has single value then its "BitWidth" will be zero (column is not present in bit index), "NoOfSymbols" will be 1 and the value for each row can be obtained from the first symbol of the corresponding symbol table.
If a table column has NULL values then
- "Bias" for that column will be "-2"
- bit index will contain 0 for the cases where column value is NULL in the row
- all non NULL values will have bit index incremented by 2 (e.g. first symbol will have the index of 2)
NULL values are not counted as symbols so e.g. column with 2 values (1 and NULL) will have 1 symbol ("NoOfSymbols" is 1) and will have "Bias" of -2.
Columns which contain only non NULL values will have "Bias" of 0 so we can always add column "Bias" to index in the row prior to getting the value from the symbol table. This works for columns containing NULLs and not containing NULLs. If resulting index is negative - column value for the row is NULL (I encountered cases where resulting index was -1).
There also might be cases when the value of the column is empty, this is considered as a value (for the symbol) and is represented as the value of type 4 (string) with the lenght of 0 (i.e. symbol will contain bytes 4 and 0 in symbol table).
There might be case when table contains column without values (which seems to be equal to having value of NULL). In such case "Bias" will be equal to "-2" but "BitWith" might be any small integer (don't ask me - why...). This means we should read bit indices from bit index row and ignore them.