refactor: replace iterator with cursor-based HasNext/Next/Get API#543
Open
liulx20 wants to merge 8 commits into
Open
refactor: replace iterator with cursor-based HasNext/Next/Get API#543liulx20 wants to merge 8 commits into
liulx20 wants to merge 8 commits into
Conversation
…t/Get API - Remove RowView class, const_iterator, begin()/end()/cbegin()/cend() - Add cursor-based traversal: HasNext(), Next(), Reset(), CurrentRowIndex() - Add typed value accessors using current cursor row: GetInt32(), GetUInt32(), GetInt64(), GetUInt64(), GetFloat(), GetDouble(), GetString(), GetBool() - Add IsNull() and GetValueAsString() for null-checking and generic access - Add ColumnCount() and ColumnNames() metadata helpers - Update documentation to reflect new API and usage examples - All existing interfaces (length, response, Serialize, etc.) preserved
- index.md: replace range-for with HasNext/Next loop - connection.md: replace range-for with HasNext/Next loop (2 occurrences)
- GetInt64: accepts Int32Array, UInt32Array, BoolArray - GetUInt64: accepts UInt32Array, BoolArray - GetFloat: accepts Int32Array, UInt32Array, BoolArray - GetDouble: accepts all numeric types and BoolArray - GetString: falls back to string representation for any type - GetInt32/GetUInt32: accept BoolArray - No narrowing conversions allowed (e.g. int64 → int32 still throws)
- CursorTraversal: HasNext/Next/Reset/CurrentRowIndex, throw on past-end - TypedGetters: GetInt32/GetString/GetDouble/GetBool per row - ImplicitWidening: int32→int64, int32→double, int32→float, bool→int32 - GetStringFallback: non-string columns return string representation - NarrowingConversionThrows: double→int32, string→int64 throw - IsNull: validity bitmap null detection - GetValueAsString: generic string access - SerializeAndDeserialize: round-trip test - EmptyResult: zero-row edge case - ColumnIndexOutOfRange: bounds check
…s all types - Remove GetValueAsString from header, implementation, docs, and tests - GetString with fallback to string representation covers the same use case - Update all doc examples from GetValueAsString to GetString
- Add GetColumnIndex(name) private helper for name→index lookup - Add string overloads: GetInt32(name), GetString(name), IsNull(name), etc. - All name-based overloads delegate to index-based versions - Throws on unknown column name with clear error message - Add tests: GetByColumnName, widening by name, IsNull by name, invalid name
| std::cout << record.ToString() << std::endl; | ||
| auto& qr = result.value(); | ||
| while (qr.HasNext()) { | ||
| std::cout << qr.GetString(0) << std::endl; |
| std::cout << record.ToString() << std::endl; | ||
| auto& qr = result.value(); | ||
| while (qr.HasNext()) { | ||
| std::cout << qr.GetString(0) << std::endl; |
| bool IsNull(size_t column_index) const; | ||
| bool IsNull(const std::string& column_name) const; | ||
|
|
||
| int32_t GetInt32(size_t column_index) const; |
Member
There was a problem hiding this comment.
What about Date/DateTime/TimeStamp
| } | ||
| } | ||
|
|
||
| double QueryResult::GetDouble(size_t column_index) const { |
Member
There was a problem hiding this comment.
Should we or not allow implicit type case?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes