Skip to content

$file.readBuffer to read the data from disk #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 30, 2025

Conversation

Krmjn09
Copy link
Collaborator

@Krmjn09 Krmjn09 commented Jun 26, 2025

Screenshot 2025-06-26 191056
first 10 double values from data page

@Krmjn09 Krmjn09 requested review from linev and silverweed June 26, 2025 13:53
@silverweed
Copy link
Contributor

Very good, these numbers look correct!
Please be sure to mark all the temporary code as such with comments and fix the eslint warnings.

The next step after this would be to get the column type and page uncompressed size from the schema you deserialized in the header. In this case you should find that the column type is 7 (kReal64).


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

Choose a reason for hiding this comment

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

If you using local simple.root file - please add it to PR, otherwise tests will fail

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, why did they not fail in the CI? Are the rntuple tests not run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tests in rntuple_test file are kind of like a checker for the fields and columns if they did not match for ntupl_staff001 it will answer like expected the first field as category but got doubles

Copy link
Collaborator Author

@Krmjn09 Krmjn09 Jun 26, 2025

Choose a reason for hiding this comment

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

So the tests are running in my terminal but gives failure instead of Ok

Copy link
Collaborator Author

@Krmjn09 Krmjn09 Jun 26, 2025

Choose a reason for hiding this comment

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

I think it's passing all checks even if the simple.root is not in GitHub because I haven't still added rntuple_test.js in jsroot ci.yml file yet

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 will do that as soon as possible

@Krmjn09 Krmjn09 requested a review from linev June 26, 2025 14:33
@@ -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.

@Krmjn09 Krmjn09 requested a review from silverweed June 27, 2025 09:19
console.log(`Field: ${field?.name ?? 'undefined'} | Type: ${field?.typeName ?? 'unknown'}`);
throw new Error('No column descriptor found');

const field = tuple.builder.fieldDescriptors?.[firstColumn.fieldId];

// Returns the size in bytes of one value based on its type
function getElementSize(typeName) {
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 in the future you should get the element size from the Column Descriptor (from the "bits on storage" field)

@silverweed
Copy link
Contributor

Thanks @Krmjn09 !
The next steps (which we'll discuss tomorrow in more detail) will be to finally get to display some data using jsroot's drawing capabilities. We'll start from a 1D histogram displaying the data you deserialized from simple.root and then improve the code a bit to allow us to read different types of data.

@silverweed silverweed merged commit 8b6eca9 into root-project:dev Jun 30, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants