Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "hyparquet", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "parquet file parser for javascript", | ||
@@ -30,5 +30,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "20.11.3", | ||
"@types/node": "20.11.5", | ||
"@typescript-eslint/eslint-plugin": "6.19.0", | ||
"@vitest/coverage-v8": "1.2.0", | ||
"@vitest/coverage-v8": "1.2.1", | ||
"eslint": "8.56.0", | ||
@@ -39,4 +39,4 @@ "eslint-plugin-import": "2.29.1", | ||
"typescript": "5.3.3", | ||
"vitest": "1.2.0" | ||
"vitest": "1.2.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
export { AsyncBuffer, FileMetaData } from './types' | ||
export { AsyncBuffer, FileMetaData, SchemaTree } from './types' | ||
@@ -41,3 +41,3 @@ /** | ||
* @param {number} initialFetchSize initial fetch size in bytes (default 512kb) | ||
* @returns {Promise<FileMetaData>} metadata object | ||
* @returns {Promise<FileMetaData>} parquet metadata object | ||
*/ | ||
@@ -50,3 +50,3 @@ export async function parquetMetadataAsync(asyncBuffer: AsyncBuffer, initialFetchSize: number = 1 << 19 /* 512kb */): Promise<FileMetaData> | ||
* @param {ArrayBuffer} arrayBuffer parquet file contents | ||
* @returns {FileMetaData} metadata object | ||
* @returns {FileMetaData} parquet metadata object | ||
*/ | ||
@@ -56,2 +56,10 @@ export function parquetMetadata(arrayBuffer: ArrayBuffer): FileMetaData | ||
/** | ||
* Return a tree of schema elements from parquet metadata. | ||
* | ||
* @param {FileMetaData} metadata parquet metadata object | ||
* @returns {SchemaTree} tree of schema elements | ||
*/ | ||
export function parquetSchema(metadata: SchemaElement[]): SchemaTree | ||
/** | ||
* Decompress snappy data. | ||
@@ -58,0 +66,0 @@ * Accepts an output buffer to avoid allocating a new buffer for each call. |
@@ -1,3 +0,3 @@ | ||
import { parquetMetadata, parquetMetadataAsync } from './metadata.js' | ||
export { parquetMetadata, parquetMetadataAsync } | ||
import { parquetMetadata, parquetMetadataAsync, parquetSchema } from './metadata.js' | ||
export { parquetMetadata, parquetMetadataAsync, parquetSchema } | ||
@@ -4,0 +4,0 @@ import { parquetRead } from './read.js' |
@@ -0,1 +1,2 @@ | ||
import { schemaTree } from './schema.js' | ||
import { deserializeTCompactProtocol } from './thrift.js' | ||
@@ -20,3 +21,3 @@ | ||
* @param {number} initialFetchSize initial fetch size in bytes | ||
* @returns {Promise<FileMetaData>} metadata object | ||
* @returns {Promise<FileMetaData>} parquet metadata object | ||
*/ | ||
@@ -50,3 +51,3 @@ export async function parquetMetadataAsync(asyncBuffer, initialFetchSize = 1 << 19 /* 512kb */) { | ||
* @param {ArrayBuffer} arrayBuffer parquet file contents | ||
* @returns {FileMetaData} metadata object | ||
* @returns {FileMetaData} parquet metadata object | ||
*/ | ||
@@ -145,1 +146,12 @@ export function parquetMetadata(arrayBuffer) { | ||
} | ||
/** | ||
* Return a tree of schema elements from parquet metadata. | ||
* | ||
* @typedef {import("./types.d.ts").SchemaTree} SchemaTree | ||
* @param {FileMetaData} metadata parquet metadata object | ||
* @returns {SchemaTree} tree of schema elements | ||
*/ | ||
export function parquetSchema(metadata) { | ||
return schemaTree(metadata.schema, 0) | ||
} |
@@ -5,3 +5,3 @@ import { FieldRepetitionType } from './constants.js' | ||
* @typedef {import('./types.js').SchemaElement} SchemaElement | ||
* @typedef {{ element: SchemaElement, children: SchemaTree[], endIndex: number }} SchemaTree | ||
* @typedef {import('./types.js').SchemaTree} SchemaTree | ||
*/ | ||
@@ -13,9 +13,9 @@ | ||
* @param {SchemaElement[]} schema | ||
* @param {number} i index of the root element | ||
* @param {number} rootIndex index of the root element | ||
* @returns {SchemaTree} tree of schema elements | ||
*/ | ||
function schemaTree(schema, i) { | ||
const root = schema[i] | ||
export function schemaTree(schema, rootIndex) { | ||
const root = schema[rootIndex] | ||
const children = [] | ||
i++ | ||
let count = 1 | ||
@@ -25,4 +25,4 @@ // Read the specified number of children | ||
while (children.length < root.num_children) { | ||
const child = schemaTree(schema, i) | ||
i = child.endIndex | ||
const child = schemaTree(schema, rootIndex + count) | ||
count += child.count | ||
children.push(child) | ||
@@ -32,3 +32,3 @@ } | ||
return { endIndex: i, element: root, children } | ||
return { count, element: root, children } | ||
} | ||
@@ -35,0 +35,0 @@ |
@@ -37,2 +37,8 @@ /** | ||
export interface SchemaTree { | ||
element: SchemaElement | ||
children: SchemaTree[] | ||
count: number | ||
} | ||
export interface SchemaElement { | ||
@@ -39,0 +45,0 @@ type?: ParquetType |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71356
1917