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 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 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
a1fb92d
add python tests.
kafka1991 Apr 14, 2025
7b75fc6
add stridesArrayView performance benchmark.
kafka1991 Apr 14, 2025
4b5655a
introduce double binary format protocol.
kafka1991 Apr 14, 2025
4076336
code format
kafka1991 Apr 14, 2025
612406f
fix little issue
kafka1991 Apr 22, 2025
e1ed453
f64 binary format test.
kafka1991 Apr 23, 2025
888665d
f64 binary format test.
kafka1991 Apr 23, 2025
1b3e755
fix cpp test for double binary format.
kafka1991 Apr 23, 2025
ceac17d
fix tests
kafka1991 Apr 23, 2025
c38c083
use direct buffer case when ndarray is not continus.
kafka1991 Apr 23, 2025
21cd6f9
ci import numpy
kafka1991 Apr 23, 2025
1f17a09
temp fix ci to specify nd_arr branch
kafka1991 Apr 23, 2025
73f784a
temp fix ci to specify nd_arr branch
kafka1991 Apr 23, 2025
5de599e
temp fix ci tests
kafka1991 Apr 23, 2025
37f8d20
fix ci tests
kafka1991 Apr 23, 2025
32f2a63
fix tests
kafka1991 Apr 23, 2025
1f12f27
add cpp array example.
kafka1991 Apr 24, 2025
89eaa79
fix logs
kafka1991 Apr 24, 2025
97c3179
fix array tests
kafka1991 Apr 24, 2025
359a74c
fix binary log.
kafka1991 Apr 25, 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
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
7 changes: 5 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 @@ -51,9 +51,12 @@ def main():
'--', '--nocapture', cwd='questdb-rs')
run_cmd('cargo', 'test', '--features=almost-all-features',
'--', '--nocapture', cwd='questdb-rs')
run_cmd('cargo', 'test', '--features=almost-all-features,protocol-version-1',
'--', '--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
13 changes: 12 additions & 1 deletion ci/run_tests_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ 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)
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
64 changes: 51 additions & 13 deletions cpp_test/mock_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,43 +190,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