You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "Pengzna (via GitHub)" <gi...@apache.org> on 2024/04/09 03:44:05 UTC
[PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Pengzna opened a new pull request, #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513
Subtask of https://github.com/apache/incubator-hugegraph/issues/2265 and https://github.com/apache/incubator-hugegraph/issues/2482
The corresponding tests will be merged after `store-core` and `store-node`
Detailed doc can be seen in [this link](https://hugegraph.feishu.cn/wiki/M8Sdw2s0YiP2YCkQ9zxcO2vVnth)
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570471887
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/util/ZipUtils.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.zip.CheckedInputStream;
+import java.util.zip.CheckedOutputStream;
+import java.util.zip.Checksum;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.NullOutputStream;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public final class ZipUtils {
+
+ public static void compress(final String rootDir, final String sourceDir,
+ final String outputFile, final Checksum checksum) throws
+ IOException {
+ try (final FileOutputStream fos = new FileOutputStream(outputFile);
+ final CheckedOutputStream cos = new CheckedOutputStream(fos, checksum);
+ final ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos))) {
+ ZipUtils.compressDirectoryToZipFile(rootDir, sourceDir, zos);
+ zos.flush();
+ fos.getFD().sync();
+ }
+ }
+
+ private static void compressDirectoryToZipFile(final String rootDir, final String sourceDir,
+ final ZipOutputStream zos) throws IOException {
+ final String dir = Paths.get(rootDir, sourceDir).toString();
+ final File[] files = new File(dir).listFiles();
+ for (final File file : files) {
+ final String child = Paths.get(sourceDir, file.getName()).toString();
+ if (file.isDirectory()) {
+ compressDirectoryToZipFile(rootDir, child, zos);
+ } else {
+ zos.putNextEntry(new ZipEntry(child));
+ try (final FileInputStream fis = new FileInputStream(file);
+ final BufferedInputStream bis = new BufferedInputStream(fis)) {
+ IOUtils.copy(bis, zos);
+ }
+ }
+ }
+ }
+
+ public static void decompress(final String sourceFile, final String outputDir,
+ final Checksum checksum) throws IOException {
+ try (final FileInputStream fis = new FileInputStream(sourceFile);
+ final CheckedInputStream cis = new CheckedInputStream(fis, checksum);
+ final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(cis))) {
+ ZipEntry entry;
+ while ((entry = zis.getNextEntry()) != null) {
+ final String fileName = entry.getName();
Review Comment:
this is a Zip Slip sec issue, fixed
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1556851314
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
Review Comment:
## Implicit narrowing conversion in compound assignment
Implicit cast of source type int to narrower destination type byte.
[Show more details](https://github.com/apache/incubator-hugegraph/security/code-scanning/62)
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
+ } else {
+ // Process overflow (like [1, 255] => [2, 0])
+ int i = bytes.length - 1;
+ for (; i > 0 && bytes[i] == BYTE_MAX_VALUE; --i) {
+ bytes[i] += 0x01;
+ }
+ if (bytes[i] == BYTE_MAX_VALUE) {
+ assert i == 0;
+ throw new DBStoreException("Unable to increase bytes: %s", Bytes.toHex(bytes));
+ }
+ bytes[i] += 0x01;
Review Comment:
## Implicit narrowing conversion in compound assignment
Implicit cast of source type int to narrower destination type byte.
[Show more details](https://github.com/apache/incubator-hugegraph/security/code-scanning/64)
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/util/ZipUtils.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.zip.CheckedInputStream;
+import java.util.zip.CheckedOutputStream;
+import java.util.zip.Checksum;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.NullOutputStream;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public final class ZipUtils {
+
+ public static void compress(final String rootDir, final String sourceDir,
+ final String outputFile, final Checksum checksum) throws
+ IOException {
+ try (final FileOutputStream fos = new FileOutputStream(outputFile);
+ final CheckedOutputStream cos = new CheckedOutputStream(fos, checksum);
+ final ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos))) {
+ ZipUtils.compressDirectoryToZipFile(rootDir, sourceDir, zos);
+ zos.flush();
+ fos.getFD().sync();
+ }
+ }
+
+ private static void compressDirectoryToZipFile(final String rootDir, final String sourceDir,
+ final ZipOutputStream zos) throws IOException {
+ final String dir = Paths.get(rootDir, sourceDir).toString();
+ final File[] files = new File(dir).listFiles();
+ for (final File file : files) {
+ final String child = Paths.get(sourceDir, file.getName()).toString();
+ if (file.isDirectory()) {
+ compressDirectoryToZipFile(rootDir, child, zos);
+ } else {
+ zos.putNextEntry(new ZipEntry(child));
+ try (final FileInputStream fis = new FileInputStream(file);
+ final BufferedInputStream bis = new BufferedInputStream(fis)) {
+ IOUtils.copy(bis, zos);
+ }
+ }
+ }
+ }
+
+ public static void decompress(final String sourceFile, final String outputDir,
+ final Checksum checksum) throws IOException {
+ try (final FileInputStream fis = new FileInputStream(sourceFile);
+ final CheckedInputStream cis = new CheckedInputStream(fis, checksum);
+ final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(cis))) {
+ ZipEntry entry;
+ while ((entry = zis.getNextEntry()) != null) {
+ final String fileName = entry.getName();
Review Comment:
## Arbitrary file access during archive extraction ("Zip Slip")
Unsanitized archive entry, which may contain '..', is used in a [file system operation](1).
Unsanitized archive entry, which may contain '..', is used in a [file system operation](2).
[Show more details](https://github.com/apache/incubator-hugegraph/security/code-scanning/50)
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
+ } else {
+ // Process overflow (like [1, 255] => [2, 0])
+ int i = bytes.length - 1;
+ for (; i > 0 && bytes[i] == BYTE_MAX_VALUE; --i) {
+ bytes[i] += 0x01;
Review Comment:
## Implicit narrowing conversion in compound assignment
Implicit cast of source type int to narrower destination type byte.
[Show more details](https://github.com/apache/incubator-hugegraph/security/code-scanning/63)
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` submodule [incubator-hugegraph]
Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies merged PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570478461
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
Review Comment:
fixed
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570992201
##########
hugegraph-store/hg-store-rocksdb/src/main/java/place-holder.txt:
##########
Review Comment:
> why we need this empty file?
@imbajin Don’t know what the use of this file is. Ignore it for now and wait for confirmation before processing 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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570992201
##########
hugegraph-store/hg-store-rocksdb/src/main/java/place-holder.txt:
##########
Review Comment:
I don’t know what the use of this file is. Ignore it for now and wait for confirmation before processing 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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570535514
##########
hugegraph-store/hg-store-rocksdb/src/main/java/place-holder.txt:
##########
Review Comment:
why we need this empty file?
##########
hugegraph-store/hg-store-rocksdb/pom.xml:
##########
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.hugegraph</groupId>
+ <artifactId>hugegraph-store</artifactId>
+ <version>${revision}</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>hg-store-rocksdb</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hugegraph</groupId>
+ <artifactId>hugegraph-common</artifactId>
+ <version>1.2.0</version>
Review Comment:
```suggestion
<version>1.3.0</version>
```
TODO: also we should use the param to unify 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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] feat(store): integrate `store-rocksdb` into Hugegraph [incubator-hugegraph]
Posted by "Pengzna (via GitHub)" <gi...@apache.org>.
Pengzna commented on code in PR #2513:
URL: https://github.com/apache/incubator-hugegraph/pull/2513#discussion_r1570478717
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
+ } else {
+ // Process overflow (like [1, 255] => [2, 0])
+ int i = bytes.length - 1;
+ for (; i > 0 && bytes[i] == BYTE_MAX_VALUE; --i) {
+ bytes[i] += 0x01;
Review Comment:
fixed
##########
hugegraph-store/hg-store-rocksdb/src/main/java/org/apache/hugegraph/rocksdb/access/SessionOperatorImpl.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * 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 org.apache.hugegraph.rocksdb.access;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.apache.hugegraph.rocksdb.access.RocksDBSession.CFHandleLock;
+import org.apache.hugegraph.rocksdb.access.util.Asserts;
+import org.apache.hugegraph.store.term.HgPair;
+import org.apache.hugegraph.util.Bytes;
+import org.rocksdb.ReadOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.RocksIterator;
+import org.rocksdb.Slice;
+import org.rocksdb.Snapshot;
+import org.rocksdb.WriteBatch;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SessionOperatorImpl implements SessionOperator {
+
+ private final RocksDB db;
+ private final RocksDBSession session;
+ private WriteBatch batch;
+
+ public SessionOperatorImpl(RocksDBSession session) {
+ this.session = session;
+ this.db = session.getDB();
+ }
+
+ public static final byte[] increaseOne(byte[] bytes) {
+ final byte BYTE_MAX_VALUE = (byte) 0xff;
+ assert bytes.length > 0;
+ byte last = bytes[bytes.length - 1];
+ if (last != BYTE_MAX_VALUE) {
+ bytes[bytes.length - 1] += 0x01;
+ } else {
+ // Process overflow (like [1, 255] => [2, 0])
+ int i = bytes.length - 1;
+ for (; i > 0 && bytes[i] == BYTE_MAX_VALUE; --i) {
+ bytes[i] += 0x01;
+ }
+ if (bytes[i] == BYTE_MAX_VALUE) {
+ assert i == 0;
+ throw new DBStoreException("Unable to increase bytes: %s", Bytes.toHex(bytes));
+ }
+ bytes[i] += 0x01;
Review Comment:
fixed
--
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@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org