You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/09/14 14:26:48 UTC

[GitHub] [incubator-kvrocks] tanruixiang opened a new pull request, #875: Move TCL test unit/type/bitmap to Go case

tanruixiang opened a new pull request, #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875

   it closes #823 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
PragmaTwice commented on code in PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#discussion_r973593224


##########
tests/gocase/unit/type/bitmap/bitmap_test.go:
##########
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package bitmap
+
+import (
+	"bytes"
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+type BITOP int32
+
+const (
+	AND BITOP = 0
+	OR  BITOP = 1
+	XOR BITOP = 2
+	NOT BITOP = 3
+)
+
+func Set2SetBit(t *testing.T, rdb *redis.Client, ctx context.Context, key string, bs []byte) {
+	buf := bytes.NewBuffer([]byte{})
+	for _, v := range bs {
+		buf.WriteString(fmt.Sprintf("%08b", v))
+	}
+	for index, value := range buf.String() {
+		require.NoError(t, rdb.SetBit(ctx, key, int64(index), int(value)-int('0')).Err())
+	}
+}
+func GetBitmap(t *testing.T, rdb *redis.Client, ctx context.Context, keys ...string) []string {
+	buf := []string{}
+	for _, key := range keys {
+		cmd := rdb.Get(ctx, key)
+		require.NoError(t, cmd.Err())
+		buf = append(buf, cmd.Val())
+	}
+	return buf
+}
+func SimulateBitOp(op BITOP, values ...[]byte) string {
+	maxlen := 0
+	binarayArray := []string{}

Review Comment:
   `binary`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
PragmaTwice commented on code in PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#discussion_r973675853


##########
tests/gocase/unit/type/bitmap/bitmap_test.go:
##########
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package bitmap
+
+import (
+	"bytes"
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+type BITOP int32
+
+const (
+	AND BITOP = 0
+	OR  BITOP = 1
+	XOR BITOP = 2
+	NOT BITOP = 3
+)
+
+func Set2SetBit(t *testing.T, rdb *redis.Client, ctx context.Context, key string, bs []byte) {
+	buf := bytes.NewBuffer([]byte{})
+	for _, v := range bs {
+		buf.WriteString(fmt.Sprintf("%08b", v))
+	}
+	for index, value := range buf.String() {
+		require.NoError(t, rdb.SetBit(ctx, key, int64(index), int(value)-int('0')).Err())
+	}
+}
+func GetBitmap(t *testing.T, rdb *redis.Client, ctx context.Context, keys ...string) []string {
+	buf := []string{}
+	for _, key := range keys {
+		cmd := rdb.Get(ctx, key)
+		require.NoError(t, cmd.Err())
+		buf = append(buf, cmd.Val())
+	}
+	return buf
+}
+func SimulateBitOp(op BITOP, values ...[]byte) string {
+	maxlen := 0
+	binarayArray := []string{}

Review Comment:
   I mean, it is a typo, binaray -> binary



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun merged pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun merged PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#issuecomment-1250063764

   @git-hulk @PragmaTwice Hi. Do you have time to review for me? Thank you very much for your help.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on a diff in pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on code in PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#discussion_r973593594


##########
tests/gocase/unit/type/bitmap/bitmap_test.go:
##########
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package bitmap
+
+import (
+	"bytes"
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+type BITOP int32
+
+const (
+	AND BITOP = 0
+	OR  BITOP = 1
+	XOR BITOP = 2
+	NOT BITOP = 3
+)
+
+func Set2SetBit(t *testing.T, rdb *redis.Client, ctx context.Context, key string, bs []byte) {
+	buf := bytes.NewBuffer([]byte{})
+	for _, v := range bs {
+		buf.WriteString(fmt.Sprintf("%08b", v))
+	}
+	for index, value := range buf.String() {
+		require.NoError(t, rdb.SetBit(ctx, key, int64(index), int(value)-int('0')).Err())
+	}
+}
+func GetBitmap(t *testing.T, rdb *redis.Client, ctx context.Context, keys ...string) []string {
+	buf := []string{}
+	for _, key := range keys {
+		cmd := rdb.Get(ctx, key)
+		require.NoError(t, cmd.Err())
+		buf = append(buf, cmd.Val())
+	}
+	return buf
+}
+func SimulateBitOp(op BITOP, values ...[]byte) string {
+	maxlen := 0
+	binarayArray := []string{}

Review Comment:
   > `binary`?
   
   It means 01 string. Name it according to `tcl` test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tisonkun commented on pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#issuecomment-1250659736

   Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] tanruixiang commented on a diff in pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
tanruixiang commented on code in PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#discussion_r973677171


##########
tests/gocase/unit/type/bitmap/bitmap_test.go:
##########
@@ -0,0 +1,238 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package bitmap
+
+import (
+	"bytes"
+	"context"
+	"fmt"
+	"strconv"
+	"strings"
+	"testing"
+
+	"github.com/apache/incubator-kvrocks/tests/gocase/util"
+	"github.com/go-redis/redis/v9"
+	"github.com/stretchr/testify/require"
+)
+
+type BITOP int32
+
+const (
+	AND BITOP = 0
+	OR  BITOP = 1
+	XOR BITOP = 2
+	NOT BITOP = 3
+)
+
+func Set2SetBit(t *testing.T, rdb *redis.Client, ctx context.Context, key string, bs []byte) {
+	buf := bytes.NewBuffer([]byte{})
+	for _, v := range bs {
+		buf.WriteString(fmt.Sprintf("%08b", v))
+	}
+	for index, value := range buf.String() {
+		require.NoError(t, rdb.SetBit(ctx, key, int64(index), int(value)-int('0')).Err())
+	}
+}
+func GetBitmap(t *testing.T, rdb *redis.Client, ctx context.Context, keys ...string) []string {
+	buf := []string{}
+	for _, key := range keys {
+		cmd := rdb.Get(ctx, key)
+		require.NoError(t, cmd.Err())
+		buf = append(buf, cmd.Val())
+	}
+	return buf
+}
+func SimulateBitOp(op BITOP, values ...[]byte) string {
+	maxlen := 0
+	binarayArray := []string{}

Review Comment:
   > I mean, it is a typo, binaray -> binary
   
   After you pointed it out, I didn't even find this mistake. Thank you very much for your careful help. I've fixed it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-kvrocks] git-hulk commented on pull request #875: Move TCL test unit/type/bitmap to Go case

Posted by GitBox <gi...@apache.org>.
git-hulk commented on PR #875:
URL: https://github.com/apache/incubator-kvrocks/pull/875#issuecomment-1250067359

   > @git-hulk @PragmaTwice Hi. Do you have time to review for me? Thank you very much for your help.
   
   Sure, thanks for your contribution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org