Skip to content
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

feat(adapters-kv): add rename and copy support to kv adapters #2513

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

oowl
Copy link
Member

@oowl oowl commented Jun 22, 2023

add rename and copy support to kv adapters, it will bring kv base services to rename and copy capability

  • memory
  • dashmap
  • moka

@oowl
Copy link
Member Author

oowl commented Jun 22, 2023

@tisonkun @kassane It seems the zig fmt error is unexpected, Can you help me take a look? And in main branch, zig test is still failed

╭─ouyang@attenuation-home ~/code/incubator-opendal/bindings/zig ‹main●› 
╰─$ zig fmt --check ./test/bdd.zig                                                                                                                                                                                                                           1 ↵
╭─ouyang@attenuation-home ~/code/incubator-opendal/bindings/zig ‹main●› 
╰─$ zig version                                                                                                                                                                                                                                            130 ↵
0.11.0-dev.3771+128fd7dd0
╭─ouyang@attenuation-home ~/code/incubator-opendal/bindings/zig ‹main●› 
╰─$ zig fmt --check .              
./test/bdd.zig
╭─ouyang@attenuation-home ~/code/incubator-opendal/bindings/zig ‹main●› 
╰─$ zig build test --summary all                                                                                                                                                                                                                             1 ↵
make: Entering directory '/home/ouyang/code/incubator-opendal/bindings/c'
mkdir -p ./build
cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
make: Leaving directory '/home/ouyang/code/incubator-opendal/bindings/c'
zig test Debug native: error: the following command failed with 1 compilation errors:
/usr/lib/zig/zig test /home/ouyang/code/incubator-opendal/bindings/zig/test/bdd.zig -lopendal_c -lc++ --cache-dir /home/ouyang/code/incubator-opendal/bindings/zig/zig-cache --global-cache-dir /home/ouyang/.cache/zig --name test --mod opendal::/home/ouyang/code/incubator-opendal/bindings/zig/src/opendal.zig --deps opendal -I /home/ouyang/code/incubator-opendal/bindings/c/include -L /home/ouyang/code/incubator-opendal/target/debug --listen=- 
Build Summary: 1/4 steps succeeded; 1 failed
test transitive failure
├─ run make success 161ms MaxRSS:55M
└─ run test transitive failure
   └─ zig test Debug native 1 errors
test/bdd.zig:65:35: error: invalid builtin function: '@enumToInt'
    try testing.expectEqual(code, @enumToInt(Code.OK));

@kassane
Copy link
Contributor

kassane commented Jun 22, 2023

Zig changed API

-@enumToInt(Code.OK))
+@intFromEnum(Code.OK))

https://ziglang.org/documentation/master/#intFromEnum

@oowl
Copy link
Member Author

oowl commented Jun 22, 2023

@kassane Maybe we need to pin zig toolchain version in CI 😆, The lack of a stable ABI can be troublesome at times.

@kassane
Copy link
Contributor

kassane commented Jun 22, 2023

@kassane Maybe we need to pin zig toolchain version in CI 😆, The lack of a stable ABI can be troublesome at times.

Await 0.11.0 release.

@oowl
Copy link
Member Author

oowl commented Jun 22, 2023

@kassane Would you mind helping us to fix this error by opening another PR? or I can fix it in the current PR.

@kassane
Copy link
Contributor

kassane commented Jun 22, 2023

@oowl,

try:

diff --git a/bindings/zig/test/bdd.zig b/bindings/zig/test/bdd.zig
index c998454c..79748fa3 100644
--- a/bindings/zig/test/bdd.zig
+++ b/bindings/zig/test/bdd.zig
@@ -62,16 +62,16 @@ test "Opendal BDD test" {
         .len = std.mem.len(testkit.content),
     };
     const code = opendal.c.opendal_operator_blocking_write(testkit.p, testkit.path, data);
-    try testing.expectEqual(code, @enumToInt(Code.OK));
+    try testing.expectEqual(code, @intFromEnum(Code.OK));
 
     // The blocking file "test" should exist
     var e: opendal.c.opendal_result_is_exist = opendal.c.opendal_operator_is_exist(testkit.p, testkit.path);
-    try testing.expectEqual(e.code, @enumToInt(Code.OK));
+    try testing.expectEqual(e.code, @intFromEnum(Code.OK));
     try testing.expect(e.is_exist);
 
     // The blocking file "test" entry mode must be file
     var s: opendal.c.opendal_result_stat = opendal.c.opendal_operator_stat(testkit.p, testkit.path);
-    try testing.expectEqual(s.code, @enumToInt(Code.OK));
+    try testing.expectEqual(s.code, @intFromEnum(Code.OK));
     var meta: [*c]opendal.c.opendal_metadata = s.meta;
     try testing.expect(opendal.c.opendal_metadata_is_file(meta));
 
@@ -82,7 +82,7 @@ test "Opendal BDD test" {
     // The blocking file "test" must have content "Hello, World!"
     var r: opendal.c.opendal_result_read = opendal.c.opendal_operator_blocking_read(testkit.p, testkit.path);
     defer opendal.c.opendal_bytes_free(r.data);
-    try testing.expect(r.code == @enumToInt(Code.OK));
+    try testing.expect(r.code == @intFromEnum(Code.OK));
     try testing.expectEqual(std.mem.len(testkit.content), r.data.*.len);
 
     var count: usize = 0;

Testing

➜ zig build test --summary all
make: Entrando no diretório '/home/kassane/Documentos/incubator-opendal/bindings/c'

mkdir -p ./build
cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
make: Saindo do diretório '/home/kassane/Documentos/incubator-opendal/bindings/c'

Build Summary: 4/4 steps succeeded; 2/2 tests passed
test success
├─ run make success 143ms MaxRSS:55M
└─ run test 2 passed 1ms MaxRSS:10M
   └─ zig test Debug native success 1s MaxRSS:816M
➜  zig git:(main) ✗ zig version
0.11.0-dev.3771+128fd7dd0

@oowl oowl force-pushed the feat/kv-adapters-rename-and-copy branch from 2a7a0ce to 8b231a0 Compare June 22, 2023 17:48
@oowl
Copy link
Member Author

oowl commented Jun 22, 2023

I have squashed my commit, So maybe we merge it no need to squash it. And thanks @kassane

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants