Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
4 changes: 4 additions & 0 deletions .github/workflows/jsroot-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
node demo/node/file_proxy.js multi ./hsimple.root
node demo/node/file_proxy.js buffer ./hsimple.root
node demo/node/buffer_test.js
node demo/node/rntuple_test.js

tests_ubuntu:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,6 +177,8 @@ jobs:
node demo/node/file_proxy.js multi ./hsimple.root
node demo/node/file_proxy.js buffer ./hsimple.root
node demo/node/buffer_test.js
node demo/node/rntuple_test.js


build-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -223,4 +226,5 @@ jobs:
node demo/node/file_proxy.js multi ./hsimple.root
node demo/node/file_proxy.js buffer ./hsimple.root
node demo/node/buffer_test.js
node demo/node/rntuple_test.js

6 changes: 4 additions & 2 deletions demo/node/rntuple_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { readHeaderFooter } from 'jsroot/rntuple';


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

let file = await openFile('https://jsroot.gsi.de/files/tmp/ntpl001_staff.root');
// let file = await openFile('./simple.root');

let rntuple = await file.readObject('Staff');
// let rntuple = await file.readObject('myNtuple');

await readHeaderFooter(rntuple);

Expand Down
37 changes: 36 additions & 1 deletion modules/rntuple.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ const numRecordCluster = reader.readU32();
this.pageLocations = clusterPageLocations;
}

// Example Of Deserializing Page Content
// deserializePage(blob) {
// const reader = new RBufferReader(blob);
// console.log('Deserializing first 10 double values from data page ')
// for (let i = 0; i < 10; ++i) {
// const val = reader.readF64();
// console.log(val);
// }
// }


}


Expand Down Expand Up @@ -527,7 +538,7 @@ async function readHeaderFooter(tuple) {
tuple.builder.deserializeHeader(header_blob);

tuple.builder.deserializeFooter(footer_blob);

// Deserialize the Page List Envelope
const group = tuple.builder.clusterGroups?.[0];
if (!group || !group.pageListLocator)
throw new Error('No valid cluster group or page list locator found');
Expand All @@ -546,6 +557,30 @@ async function readHeaderFooter(tuple) {

tuple.builder.deserializePageList(unzipped_blob);
return true;

// Read the first page data
// const firstPage = tuple.builder?.pageLocations?.[0]?.[0]?.pages?.[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you comment out all the new code and changed back the rntuple file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like i don't know how can I add the root file in GitHub once I get to know that I will uncomment the code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just git add the root file in the demo directory (is that ok @linev)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that one file forcefully correctly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
still failing the checks ! Cant understand the problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!! Thankyou for clarification
And yes both my root and test file are present in demo/node directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that even though the test file is in a directory it's not necessarily true that the tests are run from that directory; you should be able to find out the working directory by printing out __dirname from the test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some tests one do:

   cd demo/node;  node make_image.js

See examples in the jsroot-ci.yml file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used absolute path with __dirname , the issue is resoved now !!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote before - much easier to run tests from current directory.
Then simple file path can be used.

// if (!firstPage || !firstPage.locator)
// throw new Error('No valid first page found in pageLocations');

// const pageOffset = Number(firstPage.locator.offset),
// pageSize = Number(firstPage.locator.size),
// uncompressedPageSize = 8000;
// console.log('Compressed size :', pageSize);

// return tuple.$file.readBuffer([pageOffset, pageSize]).then(compressedPage => {
// if (!(compressedPage instanceof DataView))
// throw new Error('Compressed page readBuffer did not return a DataView');

// return R__unzip(compressedPage, uncompressedPageSize).then(unzippedPage => {
// if (!(unzippedPage instanceof DataView))
// throw new Error('Unzipped page is not a DataView');

// tuple.builder.deserializePage(unzippedPage);

// return true;
// });
// });
});
});
});
Expand Down