You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@claude[agent] review changes. give short summary in comment.
Review Summary
Changed: This PR adds lazy String instantiation by reading string bytes into ByteBuffers first, with opt-in BinaryString type for deferred conversion. Also includes Session API formalization, improved error messages, Variant null handling, and DNS/auth fixes.
Core Changes:
BinaryString interface with BinaryStringImpl for lazy String conversion via ByteBuffer (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java:1452-1504)
Type hint system allowing BinaryString.class to defer String allocation (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java:135-146)
Session extracted into dedicated Session class with thread-safe operations (client-v2/src/main/java/com/clickhouse/client/api/Session.java:1-100)
Compatibility Risk: MEDIUM
Breaking/High-Risk Changes:
readValue() signature changed to accept Class<?> type hint - impacts internal callers in AbstractBinaryFormatReader
Array/Map item reading now forces String.class hint instead of BinaryString - prevents unexpected type changes in collections (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java:684,867)
Variant null discriminator byte handling changed: 0xFF now treated as null (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java:916-918)
readValue() error context enhanced with row number and timing - exception messages changed
BinaryStringImpl.asBytes() throws UnsupportedOperationException for off-heap buffers - new failure mode
AbstractBinaryFormatReader.readValue() now unwraps BinaryString to String automatically - output type preserved
Issues Found:
Bug - Incorrect buffer handling in BinaryStringImpl (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java:1487-1492)
new String(buffer.array(), ...) reads entire backing array, not just the buffer range
Should use new String(buffer.array(), buffer.position(), buffer.remaining(), ...)
Impact: Extra bytes or incorrect strings when buffer doesn't start at 0 or uses a slice
Inconsistency - Missing BinaryString unwrapping in readValue(String) (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java:230)
readValue(int) unwraps BinaryString, but readValue(String) delegates without unwrapping
Impact: Column-by-name access could return BinaryString when column-by-index returns String
Performance - Unnecessary allocation in error path (client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java:260-269)
timeSinceLastNext() called twice per exception
Minor: Pre-calculate before constructing message
Tests: Variant null tests added and passing. No dedicated BinaryString tests visible in diff. Session tests added.
Docs: No changes to docs/features.md despite new type-hint API being user-facing in custom reader scenarios.
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions!
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2263
Closes #2558
Closes #2608
Checklist
Delete items not relevant to your PR: