Skip to content

Commit ae3a7d2

Browse files
authored
Merge pull request #339 from Krmjn09/feature/footer-deserialisation
Added Logic for footer Deserialisation
2 parents cc2d079 + 2971c20 commit ae3a7d2

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

modules/rntuple.mjs

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,29 @@ deserializeFooter(footer_blob) {
141141

142142
const reader = new RBufferReader(footer_blob);
143143

144-
this.footerFeatureFlags = reader.readU32();
145-
this.headerChecksum = reader.readU32();
144+
// Read the envelope metadata
145+
this._readEnvelopeMetadata(reader);
146146

147-
console.log('Footer Feature Flags:', this.footerFeatureFlags);
148-
console.log('Header Checksum:', this.headerChecksum);
147+
148+
// Feature flag(32 bits)
149+
this._readFeatureFlags(reader);
150+
// Header checksum (64-bit xxhash3)
151+
this.headerChecksum = reader.readU64();
152+
153+
const schemaExtensionSize = reader.readS64();
154+
155+
console.log('Schema extension frame size:', schemaExtensionSize);
156+
if (schemaExtensionSize < 0)
157+
throw new Error('Schema extension frame is not a record frame, which is unexpected.');
158+
159+
// Schema extension record frame (4 list frames inside)
160+
this._readFieldDescriptors(reader);
161+
this._readColumnDescriptors(reader);
162+
this._readAliasColumn(reader);
163+
this._readExtraTypeInformation(reader);
164+
165+
// Cluster Group record frame
166+
this._readClusterGroups(reader);
149167
}
150168

151169

@@ -272,8 +290,8 @@ _readColumnDescriptors(reader) {
272290
this.columnDescriptors = columnDescriptors;
273291
}
274292
_readAliasColumn(reader){
275-
const aliasColumnListSize = reader.readS64(); // signed 64-bit
276-
const aliasListisList = aliasColumnListSize < 0;
293+
const aliasColumnListSize = reader.readS64(),
294+
aliasListisList = aliasColumnListSize < 0;
277295
if (!aliasListisList)
278296
throw new Error('Alias column list frame is not a list frame, which is required.');
279297
const aliasColumnCount = reader.readU32(); // number of alias column entries
@@ -292,8 +310,8 @@ _readAliasColumn(reader){
292310
this.aliasColumns = aliasColumns;
293311
}
294312
_readExtraTypeInformation(reader) {
295-
const extraTypeInfoListSize = reader.readS64(); // signed 64-bit
296-
const isList = extraTypeInfoListSize < 0;
313+
const extraTypeInfoListSize = reader.readS64(),
314+
isList = extraTypeInfoListSize < 0;
297315

298316
if (!isList)
299317
throw new Error('Extra type info frame is not a list frame, which is required.');
@@ -314,6 +332,34 @@ _readExtraTypeInformation(reader) {
314332
}
315333
this.extraTypeInfo = extraTypeInfo;
316334
}
335+
_readClusterGroups(reader) {
336+
const clusterGroupListSize = reader.readS64(),
337+
isList = clusterGroupListSize < 0;
338+
if (!isList) throw new Error('Cluster group frame is not a list frame');
339+
340+
const groupCount = reader.readU32();
341+
console.log('Cluster Group Count:', groupCount);
342+
343+
const clusterGroups = [];
344+
345+
for (let i = 0; i < groupCount; ++i) {
346+
const clusterRecordSize = reader.readS64(),
347+
minEntry = reader.readU64(),
348+
entrySpan = reader.readU64(),
349+
numClusters = reader.readU32();
350+
351+
console.log(`Cluster Record Size: ${clusterRecordSize}`);
352+
console.log(`Min Entry: ${minEntry}, Entry Span: ${entrySpan}, Num Clusters: ${numClusters}`);
353+
354+
clusterGroups.push({
355+
minEntry,
356+
entrySpan,
357+
numClusters,
358+
});
359+
}
360+
361+
this.clusterGroups = clusterGroups;
362+
}
317363

318364
}
319365

0 commit comments

Comments
 (0)