2024-08-19 01:23:54 +00:00
|
|
|
import { BoundaryOrder } from './constants.js'
|
|
|
|
|
import { convertMetadata } from './metadata.js'
|
|
|
|
|
import { deserializeTCompactProtocol } from './thrift.js'
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {DataReader} reader
|
2024-12-02 16:47:42 +00:00
|
|
|
* @param {SchemaElement} schema
|
|
|
|
|
* @returns {ColumnIndex}
|
2024-08-19 01:23:54 +00:00
|
|
|
*/
|
|
|
|
|
export function readColumnIndex(reader, schema) {
|
|
|
|
|
const thrift = deserializeTCompactProtocol(reader)
|
|
|
|
|
return {
|
|
|
|
|
null_pages: thrift.field_1,
|
|
|
|
|
min_values: thrift.field_2.map((/** @type {any} */ m) => convertMetadata(m, schema)),
|
|
|
|
|
max_values: thrift.field_3.map((/** @type {any} */ m) => convertMetadata(m, schema)),
|
|
|
|
|
boundary_order: BoundaryOrder[thrift.field_4],
|
|
|
|
|
null_counts: thrift.field_5,
|
|
|
|
|
repetition_level_histograms: thrift.field_6,
|
|
|
|
|
definition_level_histograms: thrift.field_7,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {DataReader} reader
|
2024-12-02 16:47:42 +00:00
|
|
|
* @returns {OffsetIndex}
|
2024-08-19 01:23:54 +00:00
|
|
|
*/
|
|
|
|
|
export function readOffsetIndex(reader) {
|
|
|
|
|
const thrift = deserializeTCompactProtocol(reader)
|
|
|
|
|
return {
|
|
|
|
|
page_locations: thrift.field_1.map(pageLocation),
|
|
|
|
|
unencoded_byte_array_data_bytes: thrift.field_2,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-12-02 16:47:42 +00:00
|
|
|
* @import {ColumnIndex, DataReader, OffsetIndex, PageLocation, SchemaElement} from '../src/types.d.ts'
|
2024-08-19 01:23:54 +00:00
|
|
|
* @param {any} loc
|
2024-12-02 16:47:42 +00:00
|
|
|
* @returns {PageLocation}
|
2024-08-19 01:23:54 +00:00
|
|
|
*/
|
|
|
|
|
function pageLocation(loc) {
|
|
|
|
|
return {
|
|
|
|
|
offset: loc.field_1,
|
|
|
|
|
compressed_page_size: loc.field_2,
|
|
|
|
|
first_row_index: loc.field_3,
|
|
|
|
|
}
|
|
|
|
|
}
|