Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions demo/node/rntuple_test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { version, openFile } from 'jsroot';

import { readHeaderFooter } from 'jsroot/rntuple';

import path from 'path';
import { fileURLToPath } from 'url';

console.log(`JSROOT version ${version}`);
// const file = await openFile('https://jsroot.gsi.de/files/tmp/ntpl001_staff.root'),
// rntuple = await file.readObject('Staff');

const file = await openFile('./simple.root'),
const __filename = fileURLToPath(import.meta.url),
__dirname = path.dirname(__filename),

rootFilePath = path.join(__dirname, 'simple.root'),
file = await openFile(rootFilePath),
rntuple = await file.readObject('myNtuple');

await readHeaderFooter(rntuple);
Expand Down
12 changes: 12 additions & 0 deletions modules/rntuple.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,18 @@ async function readHeaderFooter(tuple) {
tuple.builder.deserializeHeader(header_blob);

tuple.builder.deserializeFooter(footer_blob);

// Column Validation
const firstColumn = tuple.builder.columnDescriptors?.[0];
if (!firstColumn)
throw new Error(' No column descriptor found');

if (firstColumn.coltype !== 13)
throw new Error(` Expected column type 7 (kReal64), got ${firstColumn.coltype}`);

const field = tuple.builder.fieldDescriptors?.[firstColumn.fieldId];
console.log(`Field: ${field?.name ?? 'undefined'} | Type: ${field?.typeName ?? 'unknown'}`);

// Deserialize the Page List Envelope
const group = tuple.builder.clusterGroups?.[0];
if (!group || !group.pageListLocator)
Expand Down