Skip to content

feat: RandomAccessData.put methods#837

Open
anthony-swirldslabs wants to merge 1 commit into
mainfrom
790-RandomAccessDataPut
Open

feat: RandomAccessData.put methods#837
anthony-swirldslabs wants to merge 1 commit into
mainfrom
790-RandomAccessDataPut

Conversation

@anthony-swirldslabs
Copy link
Copy Markdown
Contributor

Description:
Introducing new RandomAccessData.put*() methods for absolute writes into RandomAccessData objects. By default the methods throw an exception, and this works perfectly for the immutable Bytes which implements this interface. Other implementations, such as BufferedData and MemoryData have overrides that implement actual put operations.

The methods are: putByte(long, byte), putBytes(long, byte[]), putBytes(long, byte[], int, int), putLong(long, long), and putVarLong(long, long) which is the minimum set of methods that could be immediately useful in the MerkleDB implementation in the Consensus Node. If necessary, we can add methods for other types (float, String, and whatnot) in the future.

Unit tests are updated to verify all the new methods.

Related issue(s):

Fixes #790

Notes for reviewer:
All tests should pass.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
@anthony-swirldslabs anthony-swirldslabs self-assigned this May 20, 2026
@anthony-swirldslabs anthony-swirldslabs requested review from a team as code owners May 20, 2026 22:26
@github-actions
Copy link
Copy Markdown

JUnit Test Report

   521 files  ±  0     521 suites  ±0   30s ⏱️ +2s
 1 536 tests + 17   1 532 ✅ + 17   4 💤 ±0  0 ❌ ±0 
10 754 runs  +347  10 726 ✅ +347  28 💤 ±0  0 ❌ ±0 

Results for commit a9acfaa. ± Comparison against base commit 03830e4.

This pull request removes 6 and adds 23 tests. Note that renamed tests count towards both.
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] FLOAT, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49cd30@1f2d0ca2, [0.1, 0.5, 100.0], 12, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49cf58@e353e1d
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] STRING, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d4a8ad8@2ef812b, [string 1, testing here, testing there], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d4a8d00@5e0602ff
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] BYTES, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d4a8f28@6715a6da, [010203, ff7f0f, 42da07370bff], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d4a9150@29f86630
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] DOUBLE, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49d180@4687fee7, [0.1, 0.5, 100.0, 1.7653472635472653E240], 32, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49d3a8@4a0fc665
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [3] BOOL, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49d5d0@1067bc4c, [true, false, false, true, true, true], 6, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49d7f8@69ee0861
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [4] ENUM, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49da20@69f55ea, [0, 2, 1], 3, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000005d49dc48@2b370ca9
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] FLOAT, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149cd30@471d6571, [0.1, 0.5, 100.0], 12, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149cf58@213bd66a
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [1] STRING, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000614a8ad8@7a05cdc8, [string 1, testing here, testing there], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000614a8d00@5f3fafca
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] BYTES, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000614a8f28@3ca564aa, [010203, ff7f0f, 42da07370bff], com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x00000000614a9150@562ec518
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [2] DOUBLE, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149d180@5cf39df6, [0.1, 0.5, 100.0, 1.7653472635472653E240], 32, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149d3a8@46ae897c
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [3] BOOL, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149d5d0@1146e32e, [true, false, false, true, true, true], 6, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149d7f8@511ad0dd
com.hedera.pbj.runtime.ProtoWriterToolsTest ‑ [4] ENUM, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149da20@4cd7128, [0, 2, 1], 3, com.hedera.pbj.runtime.ProtoWriterToolsTest$$Lambda/0x000000006149dc48@22b4ad0c
com.hedera.pbj.runtime.io.buffer.BufferedDataTest ‑ putByte() works
com.hedera.pbj.runtime.io.buffer.BufferedDataTest ‑ putBytes(long, byte[]) works
com.hedera.pbj.runtime.io.buffer.BufferedDataTest ‑ putBytes(long, byte[], int, int) works
com.hedera.pbj.runtime.io.buffer.ByteArrayBufferedDataTest ‑ putByte() works
…

@github-actions
Copy link
Copy Markdown

Integration Test Report

    426 files  ±0      426 suites  ±0   16m 10s ⏱️ - 3m 25s
115 030 tests ±0  115 030 ✅ ±0  0 💤 ±0  0 ❌ ±0 
115 274 runs  ±0  115 274 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a9acfaa. ± Comparison against base commit 03830e4.

This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both.
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000041c78a38@25315eb9
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x0000000041c78c80@6f2d916f
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [1] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x000000008bc88800@28f4506c
com.hedera.pbj.integration.test.ParserNeverWrapsTest ‑ [2] com.hedera.pbj.integration.test.ParserNeverWrapsTest$$Lambda/0x000000008bc88a48@40fd4bc5

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.

BufferedData to provide random write access API

1 participant