Skip to content

feat: Adding PbjReader - #900

Open
ldintr wants to merge 2 commits into
fromUTF8from
PbjReader
Open

feat: Adding PbjReader#900
ldintr wants to merge 2 commits into
fromUTF8from
PbjReader

Conversation

@ldintr

@ldintr ldintr commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLIGive Feedback 💬

@ldintr
ldintr requested review from a team as code owners August 25, 2026 19:57
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

JUnit Test Report

   521 files  ±0     521 suites  ±0   28s ⏱️ -3s
 1 537 tests ±0   1 533 ✅ ±0   4 💤 ±0  0 ❌ ±0 
10 755 runs  ±0  10 727 ✅ ±0  28 💤 ±0  0 ❌ ±0 

Results for commit c5b6e24. ± Comparison against base commit ecf32a3.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

Integration Test Report

    428 files  ±0      428 suites  ±0   23m 41s ⏱️ + 7m 59s
115 048 tests ±0  115 048 ✅ ±0  0 💤 ±0  0 ❌ ±0 
115 292 runs  ±0  115 292 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit c5b6e24. ± Comparison against base commit ecf32a3.

♻️ This comment has been updated with latest results.

@ldintr
ldintr requested review from a team as code owners August 25, 2026 20:12
@ldintr
ldintr requested a review from rbarker-dev August 25, 2026 20:12
@ldintr ldintr changed the title Adding PbjReader feat: Adding PbjReader Aug 25, 2026
@ldintr ldintr self-assigned this Aug 25, 2026
Comment thread pbj-core/pbj-runtime/src/main/java/com/hedera/pbj/runtime/io/buffer/Bytes.java Outdated
Comment on lines +43 to +66
private static final boolean useStacktrace =
!"false".equalsIgnoreCase(System.getProperty("pbj.ReaderWriter.useStackTrace"));

public static final int EOF = -1,
Closed = -2,
DataEncoding = 1,
BufferUnderflow = 2,
Parse = 3,
IllegalArgument = 4,
IOError = 5,
Unsupported = 6, // used with WIRE_TYPE_GROUP_START, WIRE_TYPE_GROUP_END
UsageError = 9,
UnknownField = 10,
BufferOverflow = 11,
MaxDepthReached = 12,
MalformString = 13;

private static final UnknownFieldException premadeUnknown;
private static final BufferUnderflowException premadeUnderflow;
private static final BufferOverflowException premadeOverflow;
private static final RuntimeException premadeRuntime, premadeUnsupported;
private static final DataEncodingException premadeDataEncoding;
private static final IllegalArgumentException premadeIllegal;
private static final ParseException premadeParseEmpty, premadeParseUnknown, premadeMaxDepth;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

static members in Java should all be UPPER_SNAKE_CASE. Otherwise, it's too easy to confuse them with instance members or local variables.

@ldintr ldintr Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll have to do this in a later PR, or force push so the PRs after this commit doesn't break from the rename

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A force-push shouldn't be necessary for this. You should be able to add a commit to the current branch, and then merge changes from upstream branches to upper PRs.

Comment on lines +496 to +498
} else if (errorKind == Parse) {
cause = new RuntimeException(message);
includeCause = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still concerned about setting includeCause to false in this branch. To me it seems as though we're going to lose some context-related information.

@ldintr ldintr Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IIRC CN depends on this behavior. Will fix in future commit when we decide on removing or keeping error codes. I added this to my note

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to modify the CN code once the CN is being integrated with the PbjReader. As of now, this current implementation seems to lose an important piece of information about an exception, and I'd prefer we don't lose it.

}

@Override
public void close() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've already seen this code a couple of times in previous iterations, so I mostly just skimmed it through this time. However, I'd like @artemananiev to review it thoroughly this time.

Comment on lines +4 to +11
/**
* Implemented by {@link ReadableSequentialData} types that are backed directly by a heap byte array.
* Callers (e.g. {@link com.hedera.pbj.runtime.io.buffer.PbjReader}) can detect this and use the array directly
* instead of copying data through an intermediate buffer.
*/
public interface ByteArraySequentialData {
/** The raw backing byte array. */
byte[] byteArrayUnsafe();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed previously, these operations look unsafe and we'd prefer not to introduce such APIs. Can we not use an approach similar to what's done with Bytes in this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, this was meant for a later commit. IIRC there was some issue with RandomAccessSequenceAdapter being private but I think I can solve it. I'll remove this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove it in this PR, so that we don't merge that interface accidentally.

Signed-off-by: ldintr <levo.d@swirldslabs.com>
Signed-off-by: ldintr <levo.d@swirldslabs.com>
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.

2 participants