Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "hyparquet", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "parquet file parser for javascript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -187,6 +187,7 @@ import { Encoding, PageType } from './constants.js' | ||
if (typeof data[0] === 'number') { | ||
return data.map(v => v * scaleFactor) | ||
return scaleFactor === 1 ? data : data.map(v => v * scaleFactor) | ||
} else if (typeof data[0] === 'bigint') { | ||
return scaleFactor === 1 ? data : data.map(v => Number(v) * scaleFactor) | ||
} else { | ||
// TODO: parse byte string | ||
throw new Error('parquet decimal byte string not supported') | ||
return data.map(v => parseDecimal(v) * scaleFactor) | ||
} | ||
@@ -211,1 +212,16 @@ } | ||
} | ||
/** | ||
* Parse decimal from byte array. | ||
* | ||
* @param {Uint8Array} bytes | ||
* @returns {number} | ||
*/ | ||
function parseDecimal(bytes) { | ||
// TODO: handle signed | ||
let value = 0 | ||
for (const byte of bytes) { | ||
value = value << 8 | byte | ||
} | ||
return value | ||
} |
@@ -60,8 +60,7 @@ import { Encoding, ParquetType } from './constants.js' | ||
offset += plainObj.byteLength | ||
} else if (daph.encoding === Encoding.PLAIN_DICTIONARY) { | ||
const plainObj = readPlain(dataView, columnMetadata.type, nval, offset) | ||
values = plainObj.value | ||
offset += plainObj.byteLength | ||
// TODO: dictionary decoding | ||
} else if (daph.encoding === Encoding.RLE_DICTIONARY) { | ||
} else if ( | ||
daph.encoding === Encoding.PLAIN_DICTIONARY || | ||
daph.encoding === Encoding.RLE_DICTIONARY || | ||
daph.encoding === Encoding.RLE | ||
) { | ||
// bit width is stored as single byte | ||
@@ -182,3 +181,5 @@ let bitWidth | ||
*/ | ||
export function assembleObjects(definitionLevels, repetitionLevels, value, isNull, nullValue, maxDefinitionLevel, prevIndex) { | ||
export function assembleObjects( | ||
definitionLevels, repetitionLevels, value, isNull, nullValue, maxDefinitionLevel, prevIndex | ||
) { | ||
let vali = 0 | ||
@@ -185,0 +186,0 @@ let started = false |
@@ -135,3 +135,5 @@ | ||
// TODO: extract SchemaElement for this column | ||
const columnData = readColumn(arrayBuffer, bufferOffset, rowGroup, columnMetadata, metadata.schema) | ||
const columnData = readColumn( | ||
arrayBuffer, bufferOffset, rowGroup, columnMetadata, metadata.schema | ||
) | ||
if (columnData.length !== Number(rowGroup.num_rows)) { | ||
@@ -138,0 +140,0 @@ throw new Error('parquet column length does not match row group length') |
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
74275
2029