-
Notifications
You must be signed in to change notification settings - Fork 11
feat: support decimal #52
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
Open
RaphDal
wants to merge
26
commits into
main
Choose a base branch
from
rd_decimal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
008c5ed
refactor: move the example-aot project to the proper folder
RaphDal 31f2972
feat: add BufferV3 and support for DECIMAL column values in IBuffer i…
RaphDal e509af7
feat: add support for decimal
RaphDal af2acea
Merge branch 'main' into rd_decimal
RaphDal 16635e9
fix: update Buffer creation for ProtocolVersion.Auto to use BufferV3
RaphDal ea890c8
typo: fix typo in readme
RaphDal cfdb79e
📝 Add docstrings to `rd_decimal`
coderabbitai[bot] c9492d7
refactor: replace direct byte comparison with WaitAssert for improved…
RaphDal 4850e7f
fix: handle null value in Column method of ISender interface
RaphDal 5319a31
fix: handle null values in DECIMAL case of JsonSpecTestRunner
RaphDal e85fd36
refactor: remove unused using directive for System.Runtime.InteropSer…
RaphDal 079195e
refactor: improve XML documentation for Buffer and IBuffer interfaces
RaphDal d9cd6d1
Merge pull request #53 from questdb/coderabbitai/docstrings/ea890c8
RaphDal 92eadc4
fix: handle nullable decimal values in BufferV3
RaphDal 6564091
fix: fix culture in dummy servers.
RaphDal d2b5163
refactor: enhance XML documentation across Buffer classes and senders
RaphDal 3bf58c8
Update src/net-questdb-client/Senders/ISender.cs
RaphDal 89d923c
Update src/net-questdb-client/Buffers/BufferV3.cs
RaphDal 82a07fc
Update src/net-questdb-client/Senders/HttpSender.cs
RaphDal 81db9f5
fix: correct error message wording for invalid table and column names
RaphDal c20de68
fix: ensure two's complement conversion is unchecked for negative man…
RaphDal b59e1ce
fix: improve buffer management in BufferV1 by resetting line start le…
RaphDal 1be64bc
fix: update timestamp in TcpTests to use a specific date for consistency
RaphDal 1495cb1
fix: update TcpTests to use AtNowAsync for current timestamp in test …
RaphDal bc20a0d
fix: don't write column when the value is null
RaphDal 331083e
test: add BufferTests for decimal negation scenarios
RaphDal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
File renamed without changes.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /******************************************************************************* | ||
| * ___ _ ____ ____ | ||
| * / _ \ _ _ ___ ___| |_| _ \| __ ) | ||
| * | | | | | | |/ _ \/ __| __| | | | _ \ | ||
| * | |_| | |_| | __/\__ \ |_| |_| | |_) | | ||
| * \__\_\\__,_|\___||___/\__|____/|____/ | ||
| * | ||
| * Copyright (c) 2014-2019 Appsicle | ||
| * Copyright (c) 2019-2024 QuestDB | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| ******************************************************************************/ | ||
|
|
||
| using System.Text; | ||
| using NUnit.Framework; | ||
| using QuestDB.Enums; | ||
|
|
||
| namespace net_questdb_client_tests; | ||
|
|
||
| internal static class DecimalTestHelpers | ||
| { | ||
| /// <summary> | ||
| /// Asserts that the buffer contains a decimal field for the specified column with the given scale and mantissa bytes. | ||
| /// </summary> | ||
| /// <param name="buffer">The encoded row payload to search for the column's decimal field.</param> | ||
| /// <param name="columnName">The name of the column whose decimal payload is expected in the buffer.</param> | ||
| /// <param name="expectedScale">The expected scale byte of the decimal field.</param> | ||
| /// <param name="expectedMantissa">The expected mantissa bytes of the decimal field.</param> | ||
| internal static void AssertDecimalField(ReadOnlySpan<byte> buffer, | ||
| string columnName, | ||
| byte expectedScale, | ||
| ReadOnlySpan<byte> expectedMantissa) | ||
| { | ||
| var payload = ExtractDecimalPayload(buffer, columnName); | ||
| Assert.That(payload.Length, | ||
| Is.GreaterThanOrEqualTo(4 + expectedMantissa.Length), | ||
| $"Decimal field `{columnName}` payload shorter than expected."); | ||
| Assert.That(payload[0], Is.EqualTo((byte)'=')); | ||
| Assert.That(payload[1], Is.EqualTo((byte)BinaryFormatType.DECIMAL)); | ||
| Assert.That(payload[2], Is.EqualTo(expectedScale), $"Unexpected scale for `{columnName}`."); | ||
| Assert.That(payload[3], | ||
| Is.EqualTo((byte)expectedMantissa.Length), | ||
| $"Unexpected mantissa length for `{columnName}`."); | ||
| CollectionAssert.AreEqual(expectedMantissa.ToArray(), payload.Slice(4, expectedMantissa.Length).ToArray(), | ||
| $"Mantissa bytes for `{columnName}` did not match expectation."); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Asserts that the buffer contains a null decimal field payload for the specified column. | ||
| /// </summary> | ||
| /// <param name="buffer">Buffer containing the encoded record(s) to inspect.</param> | ||
| /// <param name="columnName">Name of the column whose decimal payload should be null.</param> | ||
| /// <remarks> | ||
| /// Verifies the payload starts with '=' then the DECIMAL type marker, and that both scale and mantissa length are zero. | ||
| /// </remarks> | ||
| internal static void AssertDecimalNullField(ReadOnlySpan<byte> buffer, string columnName) | ||
| { | ||
| var payload = ExtractDecimalPayload(buffer, columnName); | ||
| Assert.That(payload.Length, | ||
| Is.GreaterThanOrEqualTo(4), | ||
| $"Decimal field `{columnName}` payload shorter than expected."); | ||
| Assert.That(payload[0], Is.EqualTo((byte)'=')); | ||
| Assert.That(payload[1], Is.EqualTo((byte)BinaryFormatType.DECIMAL)); | ||
| Assert.That(payload[2], Is.EqualTo(0), $"Unexpected scale for `{columnName}`."); | ||
| Assert.That(payload[3], Is.EqualTo(0), $"Unexpected mantissa length for `{columnName}`."); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Locate and return the payload bytes for a decimal column identified by name. | ||
| /// </summary> | ||
| /// <param name="buffer">The byte span containing the encoded record payload to search.</param> | ||
| /// <param name="columnName">The column name whose payload prefix ("columnName=") will be located.</param> | ||
| /// <returns>The slice of <paramref name="buffer"/> immediately after the found "columnName=" prefix.</returns> | ||
| private static ReadOnlySpan<byte> ExtractDecimalPayload(ReadOnlySpan<byte> buffer, string columnName) | ||
| { | ||
| var prefix = Encoding.ASCII.GetBytes($"{columnName}="); | ||
| var index = buffer.IndexOf(prefix.AsSpan()); | ||
| Assert.That(index, Is.GreaterThanOrEqualTo(0), $"Column `{columnName}` not found in payload."); | ||
| return buffer[(index + prefix.Length)..]; | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.