Skip to content

Commit d23a289

Browse files
authored
Merge pull request eclipse-score#20 from joshualicht/cpp_implementation
Initial Implementation of the CPP KVS
2 parents 49b5b95 + 8ced7ab commit d23a289

29 files changed

+3496
-4
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build --java_language_version=17
22
build --tool_java_language_version=17
33
build --java_runtime_version=remotejdk_17
44
build --tool_java_runtime_version=remotejdk_17
5+
build --@score-baselibs//score/json:base_library=nlohmann
56

67
test --test_output=errors
78

BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,15 @@ use_format_targets()
4141
exports_files([
4242
"MODULE.bazel",
4343
])
44+
45+
alias(
46+
name = "kvs_cpp",
47+
actual = "//src/cpp:kvs_cpp",
48+
visibility = ["//visibility:public"],
49+
)
50+
51+
test_suite(
52+
name = "test_kvs_cpp",
53+
tests = ["//tests/cpp:test_kvs_cpp"],
54+
visibility = ["//visibility:public"],
55+
)

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[workspace]
22
resolver = "2"
33
members=[
4-
"src",
4+
"src/rust",
55
]
66

77
[workspace.package]
@@ -10,8 +10,8 @@ edition = "2021"
1010

1111

1212
[workspace.dependencies]
13-
rust-kvs = { path = "src" }
13+
rust-kvs = { path = "src/rust" }
1414

1515
adler32 = "1.2.0"
1616
tinyjson = "2.5.1"
17-
pico-args = "0.5"
17+
pico-args = "0.5"

MODULE.bazel

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,21 @@ crate.from_cargo(
7676
cargo_lockfile = "//:Cargo.lock",
7777
manifests = [
7878
"//:Cargo.toml",
79-
"//src:Cargo.toml",
79+
"//src/rust:Cargo.toml",
8080
],
8181
)
8282
use_repo(crate, "crates")
83+
84+
#bazel_dep on module 'rules_boost' has no version -> override needed
85+
archive_override(
86+
module_name = "rules_boost",
87+
strip_prefix = "rules_boost-master",
88+
urls = ["https://github.com/nelhage/rules_boost/archive/refs/heads/master.tar.gz"],
89+
)
90+
91+
bazel_dep(name = "score-baselibs", version = "0.0.0")
92+
git_override(
93+
module_name = "score-baselibs",
94+
commit = "f0a394a602986ddf7abac6a238b9d44535a4b597",
95+
remote = "git@github.com:eclipse-score/baselibs.git",
96+
)

src/cpp/BUILD

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
# The filegroup is used to collect all source files for the tests.
15+
filegroup(
16+
name = "kvs_srcs",
17+
srcs = glob([
18+
"src/*.cpp",
19+
"inc/**/*.hpp",
20+
]),
21+
visibility = [
22+
"//tests/cpp:__pkg__",
23+
],
24+
)
25+
26+
cc_library(
27+
name = "kvs_cpp",
28+
srcs = glob(["src/*.cpp"]),
29+
hdrs = glob([
30+
"inc/**/*.hpp",
31+
]),
32+
includes = ["inc"],
33+
visibility = ["//:__pkg__"],
34+
deps = [
35+
"@score-baselibs//score/filesystem:filesystem",
36+
"@score-baselibs//score/json:interface",
37+
"@score-baselibs//score/json:json_parser",
38+
"@score-baselibs//score/result:result",
39+
],
40+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Apache License Version 2.0 which is available at
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* SPDX-License-Identifier: Apache-2.0
12+
********************************************************************************/
13+
#ifndef SCORE_LIB_KVS_INTERNAL_KVS_HELPER_HPP
14+
#define SCORE_LIB_KVS_INTERNAL_KVS_HELPER_HPP
15+
16+
#include <sstream>
17+
#include <string>
18+
19+
/*
20+
* This header defines helper functions used internally by the Key-Value Store (KVS) implementation.
21+
* It exists to allow unit tests to access these internal functions.
22+
*/
23+
24+
uint32_t parse_hash_adler32(std::istream& in);
25+
uint32_t calculate_hash_adler32(const std::string& data);
26+
std::array<uint8_t,4> get_hash_bytes_adler32(uint32_t hash);
27+
std::array<uint8_t,4> get_hash_bytes(const std::string& data);
28+
score::Result<std::unordered_map<std::string, KvsValue>> parse_json_data(const std::string& data);
29+
score::Result<std::unordered_map<std::string, KvsValue>> open_json(const std::string& prefix, OpenJsonNeedFile need_file);
30+
score::ResultBlank write_json_data(const std::string& filename_prefix, const std::string& buf);
31+
score::Result<KvsValue> any_to_kvsvalue(const score::json::Any& any);
32+
score::Result<score::json::Any> kvsvalue_to_any(const KvsValue& kv);
33+
34+
#endif // SCORE_LIB_KVS_INTERNAL_KVS_HELPER_HPP

0 commit comments

Comments
 (0)