Skip to content

Commit

Permalink
Change to use STRING instead of BYTE_ARRAY for (targetC|c)ontentHash …
Browse files Browse the repository at this point in the history
…columns
  • Loading branch information
Wes Biggs committed Aug 13, 2024
1 parent ae7fe5c commit 68b3154
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 21 deletions.
8 changes: 4 additions & 4 deletions __snapshots__/parquet.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`DSNP Schema Conversion Test File schema is encoded correctly 1`] = `
"type_length": null,
},
{
"converted_type": null,
"converted_type": 0,
"field_id": null,
"logicalType": null,
"name": "contentHash",
Expand Down Expand Up @@ -90,7 +90,7 @@ ParquetSchema {
"dLevelMax": 0,
"encoding": "PLAIN",
"name": "contentHash",
"originalType": undefined,
"originalType": "UTF8",
"path": [
"contentHash",
],
Expand Down Expand Up @@ -160,7 +160,7 @@ ParquetSchema {
"dLevelMax": 0,
"encoding": "PLAIN",
"name": "contentHash",
"originalType": undefined,
"originalType": "UTF8",
"path": [
"contentHash",
],
Expand Down Expand Up @@ -218,7 +218,7 @@ ParquetSchema {
"compression": "GZIP",
"encoding": "PLAIN",
"statistics": false,
"type": "BYTE_ARRAY",
"type": "UTF8",
},
"fromId": {
"compression": "GZIP",
Expand Down
10 changes: 3 additions & 7 deletions parquet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("DSNP Schema Conversion Test File", () => {

const row1 = {
announcementType: AnnouncementType.Broadcast,
contentHash: "0x12345678",
contentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
fromId: 12n,
url: "https://github.com/LibertyDSNP/parquetjs/",
};
Expand All @@ -35,18 +35,14 @@ describe("DSNP Schema Conversion Test File", () => {
it("schema is generated correctly", () => {
expect(parquetSchema).toMatchSnapshot();
});

Check failure on line 38 in parquet.spec.ts

View workflow job for this annotation

GitHub Actions / test

Delete `··`
it("schema is encoded correctly", () => {
expect(reader.metadata?.schema).toMatchSnapshot();
});

it("output matches input", async () => {
const cursor = reader.getCursor();
const row = await cursor.next();
const rowData = {
...row1,
contentHash: Buffer.from([48, 120, 49, 50, 51, 52, 53, 54, 55, 56]),
};
expect(row).toEqual(rowData);
expect(row).toEqual(row1);
});
});
2 changes: 1 addition & 1 deletion parquet/broadcast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Broadcast Spec", () => {

testCompression("broadcast", broadcastSchema, () => ({
announcementType: 2,
contentHash: generators.generateHash(),
contentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
fromId: generators.randInt(10000000),
url: `https://www.imadapp.com/data/posts/${generators.generateHash()}`,
}));
Expand Down
2 changes: 1 addition & 1 deletion parquet/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const broadcast: DSNPParquetSchema = [
},
{
name: "contentHash",
column_type: "BYTE_ARRAY",
column_type: "STRING",
compression: "GZIP",
bloom_filter: true,
},
Expand Down
2 changes: 1 addition & 1 deletion parquet/reply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Reply Spec", () => {

testCompression("reply", replySchema, () => ({
announcementType: 3,
contentHash: generators.generateHash(),
contentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
fromId: generators.randInt(10000000),
inReplyTo: `dsnp://${generators.randInt(10000000)}/${generators.generateHash()}`,
url: `https://www.imadapp.com/data/posts/${generators.generateHash()}`,
Expand Down
2 changes: 1 addition & 1 deletion parquet/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const reply: DSNPParquetSchema = [
},
{
name: "contentHash",
column_type: "BYTE_ARRAY",
column_type: "STRING",
compression: "GZIP",
bloom_filter: true,
},
Expand Down
2 changes: 1 addition & 1 deletion parquet/tombstone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe("Tombstone Spec", () => {
announcementType: 0,
fromId: generators.randInt(10000000),
targetAnnouncementType: 2,
targetContentHash: generators.generateHash(),
targetContentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
}));
});
2 changes: 1 addition & 1 deletion parquet/tombstone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const tombstone: DSNPParquetSchema = [
},
{
name: "targetContentHash",
column_type: "BYTE_ARRAY",
column_type: "STRING",
compression: "GZIP",
bloom_filter: true,
},
Expand Down
4 changes: 2 additions & 2 deletions parquet/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ describe("Update Spec", () => {

testCompression("update", updateSchema, () => ({
announcementType: 6,
contentHash: generators.generateHash(),
contentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
fromId: generators.randInt(10000000),
targetAnnouncementType: 2,
targetContentHash: generators.generateHash(),
targetContentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
url: `https://www.imadapp.com/data/posts/${generators.generateHash()}`,
}));
});
4 changes: 2 additions & 2 deletions parquet/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const update: DSNPParquetSchema = [
},
{
name: "contentHash",
column_type: "BYTE_ARRAY",
column_type: "STRING",
compression: "GZIP",
bloom_filter: true,
},
Expand Down Expand Up @@ -48,7 +48,7 @@ const update: DSNPParquetSchema = [
},
{
name: "targetContentHash",
column_type: "BYTE_ARRAY",
column_type: "STRING",
compression: "GZIP",
bloom_filter: true,
},
Expand Down

0 comments on commit 68b3154

Please sign in to comment.