Skip to content

Commit

Permalink
Update docs and add simple test for readme encoding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Jan 5, 2024
1 parent 19707ef commit dc56f95
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ var schema = new parquet.ParquetSchema({
The Parquet hybrid run length and bitpacking encoding allows to compress runs
of numbers very efficiently. Note that the RLE encoding can only be used in
combination with the `BOOLEAN`, `INT32` and `INT64` types. The RLE encoding
requires an additional `bitWidth` parameter that contains the maximum number of
requires an additional `typeLength` parameter that contains the maximum number of
bits required to store the largest value of the field.

``` js
var schema = new parquet.ParquetSchema({
age: { type: 'UINT_32', encoding: 'RLE', bitWidth: 7 },
age: { type: 'UINT_32', encoding: 'RLE', typeLength: 7 },
});
```

Expand Down
21 changes: 21 additions & 0 deletions test/readme-examples.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from "chai";

import { ParquetSchema } from '../parquet';

describe("Readme Encoding Examples", function () {
it("PLAIN should work", function () {
const ps = new ParquetSchema({
name: { type: 'UTF8', encoding: 'PLAIN' },
});
expect(ps).to.be.a("object");
expect(ps.schema.name.encoding).to.eq("PLAIN");
});

it("RLE should work", function () {
const ps = new ParquetSchema({
age: { type: 'UINT_32', encoding: 'RLE', typeLength: 7 },
});
expect(ps).to.be.a("object");
expect(ps.schema.age.typeLength).to.eq(7);
});
});

0 comments on commit dc56f95

Please sign in to comment.