Skip to content

Commit

Permalink
Fix bug related to non unique references on genRefs functions
Browse files Browse the repository at this point in the history
  • Loading branch information
guilledk committed May 14, 2024
1 parent 36a5e06 commit f1d0eec
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guilledk/arrowbatch-nodejs",
"version": "1.0.0-rc8",
"version": "1.0.0-rc9",
"description": "Arrow Batch Storage protocol",
"main": "./build/index.js",
"type": "module",
Expand Down
28 changes: 27 additions & 1 deletion src/reader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,19 @@ export class ArrowBatchReader extends ArrowBatchContext {
auxiliary: boolean = false
): RowWithRefs {
const references = this.refMappings.get(tableName);
const processedRefs = new Set();
const uniqueRefs = [];
Object.values(references).forEach(val => {
const parentInfo = {
index: val.parentIndex,
mapping: val.parentMapping
};
if (!processedRefs.has(JSON.stringify(parentInfo))) {
processedRefs.add(JSON.stringify(parentInfo));
uniqueRefs.push(val);
}
});

const childRowMap = new Map<string, RowWithRefs[]>();
for (const [refName, reference] of Object.entries(references)) {
const refs = this.getRowsFromBufferByRef(
Expand Down Expand Up @@ -356,8 +369,21 @@ export class ArrowBatchReader extends ArrowBatchContext {
tables: ArrowCachedTables
): RowWithRefs {
const references = this.refMappings.get(tableName);
const processedRefs = new Set();
const uniqueRefs = [];
Object.values(references).forEach(val => {
const parentInfo = {
index: val.parentIndex,
mapping: val.parentMapping
};
if (!processedRefs.has(JSON.stringify(parentInfo))) {
processedRefs.add(JSON.stringify(parentInfo));
uniqueRefs.push(val);
}
});

const childRowMap = new Map<string, RowWithRefs[]>();
for (const [refName, reference] of Object.entries(references)) {
for (const reference of uniqueRefs) {
const refs = this.getRowsFromTablesByRef(
tableName, reference.parentMapping, row[reference.parentIndex], tables);

Expand Down

0 comments on commit f1d0eec

Please sign in to comment.