Skip to content

introduce ndarr support #98

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
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
87aa240
c client nd array begin.
kafka1991 Apr 1, 2025
6bd3223
Ndarray support for rust client.
kafka1991 Apr 2, 2025
b518a99
optimize doc.
kafka1991 Apr 2, 2025
53a430e
add tests.
kafka1991 Apr 2, 2025
b1ebd1d
fix comments.
kafka1991 Apr 2, 2025
006af98
fix docs.
kafka1991 Apr 3, 2025
a31716a
fix tests and compile error in ffi.
kafka1991 Apr 3, 2025
463a2d3
format code.
kafka1991 Apr 3, 2025
44fae08
ffi supported
kafka1991 Apr 3, 2025
93c6f9d
ndarray c api
kafka1991 Apr 3, 2025
e9da558
format
kafka1991 Apr 3, 2025
0e8a9e5
c++ api support.
kafka1991 Apr 3, 2025
261163c
add include.
kafka1991 Apr 3, 2025
a565109
code format.
kafka1991 Apr 3, 2025
d1edbbc
Merge remote-tracking branch 'origin/main' into array
kafka1991 Apr 6, 2025
e161b1d
conflict resolve
kafka1991 Apr 6, 2025
4a59ec0
code review.
kafka1991 Apr 7, 2025
0c513b1
code format.
kafka1991 Apr 7, 2025
4a58346
c example
kafka1991 Apr 7, 2025
1a6cf6f
make mock.rs recv works.
kafka1991 Apr 7, 2025
9caed7a
easier pre-ci 'proj' script to build lint and test changes
amunra Apr 7, 2025
c2583f1
c api add strides.
kafka1991 Apr 7, 2025
0476faf
add strideArrayView for rust array ingress api
kafka1991 Apr 8, 2025
31e57c5
add strideArrayView for rust array ingress api
kafka1991 Apr 8, 2025
533224a
add benchmark test.
kafka1991 Apr 8, 2025
8d30e57
fix tests
kafka1991 Apr 9, 2025
36203a6
better memory copy.
kafka1991 Apr 9, 2025
feaf5be
code format
kafka1991 Apr 9, 2025
c4bed10
make c api works.
kafka1991 Apr 9, 2025
f3011e1
make c api works.
kafka1991 Apr 9, 2025
70eaa24
code format
kafka1991 Apr 9, 2025
526e8ae
make c++ tests work.
kafka1991 Apr 9, 2025
9c16d74
fix compile error.
kafka1991 Apr 9, 2025
5dae9d0
make c++20 build happy
kafka1991 Apr 9, 2025
ea52293
code format
kafka1991 Apr 9, 2025
193b887
fix cpp problem on windows.
kafka1991 Apr 10, 2025
523a855
lint issues
amunra Apr 10, 2025
3442cbe
introduce line protocol version
kafka1991 Apr 14, 2025
2b927ae
support https
kafka1991 May 5, 2025
edb40fc
code format.
kafka1991 May 5, 2025
c9f1476
implement NDArrayView for common built-in array, vector and slices.
kafka1991 May 6, 2025
a883112
code format
kafka1991 May 6, 2025
f3e8681
add tests for build-in array,vector and slice.
kafka1991 May 6, 2025
1ee3b58
add line protocol version tests for rust client.
kafka1991 May 6, 2025
d34c651
make line protocol version c++ interface more ideamatic
kafka1991 May 6, 2025
9c78839
fix build failure.
kafka1991 May 6, 2025
ced8e05
fix little comment
kafka1991 May 6, 2025
ef8ab61
add system_test.
kafka1991 May 7, 2025
ed3fc06
add more system array tests
kafka1991 May 7, 2025
3839403
code format
kafka1991 May 7, 2025
33767f3
better c/cpp array examples.
kafka1991 May 7, 2025
6e8d77e
fix test.py
kafka1991 May 7, 2025
6168e7f
add array example tests.
kafka1991 May 7, 2025
d758e6d
c error code.
kafka1991 May 8, 2025
bf8ae37
remove unnecessary mut.
kafka1991 May 8, 2025
fa6f04d
make c++20 happy
kafka1991 May 8, 2025
3ce862e
more ideamatic python array interface
kafka1991 May 8, 2025
6678679
code format and cpp compile fix.
kafka1991 May 8, 2025
6f1e7e3
fixed encapsulation issue (we were leaking internal types to the publ…
amunra May 8, 2025
d76b272
Merge branch 'array' of https://github.com/questdb/c-questdb-client i…
amunra May 8, 2025
8d739f1
typo fixed.
kafka1991 May 9, 2025
710a69f
cleanup and added todo comments
amunra May 9, 2025
997937c
Merge branch 'array' of https://github.com/questdb/c-questdb-client i…
amunra May 9, 2025
75d01ae
removed slow build debug artifacts upload which we generally don't need
amunra May 9, 2025
066d0a1
Merge remote-tracking branch 'origin/main' into array
amunra May 9, 2025
7017bc3
fix failed tests.
kafka1991 May 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ if (QUESTDB_TESTS_AND_EXAMPLES)
line_sender_c_example
examples/concat.c
examples/line_sender_c_example.c)
compile_example(
line_sender_c_example_array
examples/concat.c
examples/line_sender_c_example_array.c)
compile_example(
line_sender_c_example_auth
examples/concat.c
Expand All @@ -123,6 +127,9 @@ if (QUESTDB_TESTS_AND_EXAMPLES)
compile_example(
line_sender_cpp_example
examples/line_sender_cpp_example.cpp)
compile_example(
line_sender_cpp_example_array
examples/line_sender_cpp_example_array.cpp)
compile_example(
line_sender_cpp_example_auth
examples/line_sender_cpp_example_auth.cpp)
Expand Down
4 changes: 4 additions & 0 deletions ci/compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ steps:
rustup default $(toolchain)
condition: ne(variables['toolchain'], '')
displayName: "Update and set Rust toolchain"
- script: |
python -m pip install --upgrade pip
pip install numpy
displayName: 'Install Python Dependencies'
- script: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DQUESTDB_TESTS_AND_EXAMPLES=ON
env:
JAVA_HOME: $(JAVA_HOME_11_X64)
Expand Down
5 changes: 3 additions & 2 deletions ci/run_all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def main():
build_cxx20_dir.glob(f'**/test_line_sender{exe_suffix}')))

system_test_path = pathlib.Path('system_test') / 'test.py'
qdb_v = '8.2.3' # The version of QuestDB we'll test against.
#qdb_v = '8.2.3' # The version of QuestDB we'll test against.

run_cmd('cargo', 'test',
'--', '--nocapture', cwd='questdb-rs')
Expand All @@ -53,7 +53,8 @@ def main():
'--', '--nocapture', cwd='questdb-rs')
run_cmd(str(test_line_sender_path))
run_cmd(str(test_line_sender_path_CXX20))
run_cmd('python3', str(system_test_path), 'run', '--versions', qdb_v, '-v')
#run_cmd('python3', str(system_test_path), 'run', '--versions', qdb_v, '-v')
run_cmd('python3', str(system_test_path), 'run', '--repo', './questdb_nd_arr', '-v')


if __name__ == '__main__':
Expand Down
21 changes: 16 additions & 5 deletions ci/run_tests_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,25 @@ stages:
cd questdb-rs
cargo build --examples --features almost-all-features
displayName: "Build Rust examples"
############################# temp for test begin #####################
- script: |
git clone -b nd_arr --depth 1 https://github.com/questdb/questdb.git ./questdb_nd_arr
displayName: git clone questdb
- task: Maven@3
displayName: "Compile QuestDB"
inputs:
mavenPOMFile: 'questdb_nd_arr/pom.xml'
jdkVersionOption: '1.11'
options: "-DskipTests -Pbuild-web-console"
############################# temp for test end #####################
- script: python3 ci/run_all_tests.py
env:
JAVA_HOME: $(JAVA_HOME_11_X64)
displayName: "Tests"
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: ./build
displayName: "Publish build directory"
# - task: PublishBuildArtifacts@1
# inputs:
# pathToPublish: ./build
# displayName: "Publish build directory"
- job: FormatAndLinting
displayName: "cargo fmt and clippy"
pool:
Expand Down Expand Up @@ -115,7 +126,7 @@ stages:
submodules: false
- template: compile.yaml
- script: |
git clone --depth 1 https://github.com/questdb/questdb.git
git clone -b nd_arr --depth 1 https://github.com/questdb/questdb.git
displayName: git clone questdb
- task: Maven@3
displayName: "Compile QuestDB"
Expand Down
65 changes: 52 additions & 13 deletions cpp_test/mock_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "mock_server.hpp"

#include <string.h>
#include <string>

#if defined(PLATFORM_UNIX)
# include <fcntl.h>
Expand Down Expand Up @@ -190,43 +191,81 @@ bool mock_server::wait_for_data(std::optional<double> wait_timeout_sec)
return !!count;
}

int32_t bytes_to_int32_le(const std::byte* bytes)
{
return static_cast<int32_t>(
(bytes[0] << 0) | (bytes[1] << 8) | (bytes[2] << 16) |
(bytes[3] << 24));
}

size_t mock_server::recv(double wait_timeout_sec)
{
if (!wait_for_data(wait_timeout_sec))
return 0;

char chunk[1024];
std::byte chunk[1024];
size_t chunk_len{sizeof(chunk)};
std::vector<char> accum;
std::vector<std::byte> accum;
for (;;)
{
wait_for_data();
sock_ssize_t count =
::recv(_conn_fd, &chunk[0], static_cast<sock_len_t>(chunk_len), 0);
sock_ssize_t count = ::recv(
_conn_fd,
reinterpret_cast<char*>(&chunk[0]),
static_cast<sock_len_t>(chunk_len),
0);
if (count == -1)
throw std::runtime_error{"Bad `recv()`."};
const size_t u_count = static_cast<size_t>(count);
accum.insert(accum.end(), chunk, chunk + u_count);
if (accum.size() < 2)
continue;
if ((accum[accum.size() - 1] == '\n') &&
(accum[accum.size() - 2] != '\\'))
if ((accum[accum.size() - 1] == std::byte('\n')) &&
(accum[accum.size() - 2] != std::byte('\\')))
break;
}

size_t received_count{0};
const char* head{&accum[0]};
for (size_t index = 1; index < accum.size(); ++index)
const std::byte* head{&accum[0]};
size_t index{1};
while (index < accum.size())
{
const char& last = accum[index];
const char& prev = accum[index - 1];
if ((last == '\n') && (prev != '\\'))
const std::byte& last = accum[index];
const std::byte& prev = accum[index - 1];
if (last == std::byte('=') && prev == std::byte('='))
{
index++;
std::byte& binary_type = accum[index];
if (binary_type == std::byte(16)) // DOUBLE_BINARY_FORMAT_TYPE
index += sizeof(double) + 1;
else if (binary_type == std::byte(14)) // ARRAY_BINARY_FORMAT_TYPE
{
index++;
const std::byte& array_elem_type = accum[index];
if (array_elem_type == std::byte(10))
{
index++;
const size_t dims = size_t(accum[index]);
index++;
size_t data_size{sizeof(double)};
for (size_t i = 0; i < dims; i++)
{
data_size *= bytes_to_int32_le(&accum[index]);
index += sizeof(int32_t);
}
index += data_size;
}
}
continue;
}
else if ((last == std::byte('\n')) && (prev != std::byte('\\')))
{
const char* tail{&last + 1};
_msgs.emplace_back(head, tail - head);
const std::byte* tail{&last + 1};
_msgs.emplace_back(head, tail);
head = tail;
++received_count;
}
index++;
}
return received_count;
}
Expand Down
19 changes: 14 additions & 5 deletions cpp_test/mock_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@

#pragma once

#include <cassert>
#include <vector>
#include <string>
#include <cstdint>
#include <optional>
#include <stdexcept>

#include "build_env.h"
#if __cplusplus < 202002L
# include "questdb/ingress/line_sender.hpp"
#else
# include <span>
#endif

#if defined(PLATFORM_UNIX)
typedef int socketfd_t;
Expand Down Expand Up @@ -60,9 +64,14 @@ class mock_server

size_t recv(double wait_timeout_sec = 0.1);

const std::vector<std::string>& msgs() const
#if __cplusplus >= 202002L
using buffer_view = std::span<const std::byte>;
#endif

buffer_view msgs(size_t index) const
{
return _msgs;
assert(index < _msgs.size());
return {_msgs[index].data(), _msgs[index].size()};
}

void close();
Expand All @@ -75,7 +84,7 @@ class mock_server
socketfd_t _listen_fd;
socketfd_t _conn_fd;
uint16_t _port;
std::vector<std::string> _msgs;
std::vector<std::vector<std::byte>> _msgs;
};

} // namespace questdb::ingress::test
Loading
Loading