Copilot commented on code in PR #2911:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2911#discussion_r2601706400


##########
hugegraph-server/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseStore.java:
##########
@@ -114,6 +114,14 @@ protected List<String> tableNames() {
                           .collect(Collectors.toList());
     }
 
+    protected List<String> truncatedTableNames() {
+        // Exclude meta table to preserve system metadata during graph clear
+        return this.tables.entrySet().stream()
+                          .filter(e -> !(HugeType.META == e.getKey()))
+                          .map(e -> e.getValue().table())

Review Comment:
   This filter condition `!(HugeType.META == e.getKey())` is redundant because 
`HugeType.META` is never registered via `registerTableManager()` and therefore 
will never exist in the `this.tables` map. The meta table is added separately 
in `HbaseSystemStore.tableNames()` (line 582) by calling `this.meta.table()`. 
   
   The fix works correctly because `truncatedTableNames()` simply doesn't 
include the meta table at all (since it's not in the map), but the explicit 
filter is misleading and suggests META might be in the map. Consider removing 
the filter:
   
   ```java
   protected List<String> truncatedTableNames() {
       // Exclude meta table to preserve system metadata during graph clear
       return this.tables.values().stream()
                         .map(BackendTable::table)
                         .collect(Collectors.toList());
   }
   ```
   ```suggestion
           return this.tables.values().stream()
                             .map(BackendTable::table)
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/BaseHbaseUnitTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.unit.hbase;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.hugegraph.backend.store.hbase.HbaseSessions;
+import org.apache.hugegraph.backend.store.hbase.HbaseStoreProvider;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.testutil.Utils;
+import org.apache.hugegraph.unit.BaseUnitTest;
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class BaseHbaseUnitTest extends BaseUnitTest {
+
+    private static final String GRAPH_NAME = "test_graph";
+
+    protected HugeConfig config;
+    protected HbaseStoreProvider provider;
+    protected HbaseSessions sessions;
+
+    @Before
+    public void setup() throws IOException {
+        Configuration conf = Utils.getConf();
+        this.config = new HugeConfig(conf);
+        this.provider = new HbaseStoreProvider();
+        this.provider.open(GRAPH_NAME);
+        this.provider.loadSystemStore(config).open(config);
+        this.provider.loadGraphStore(config).open(config);
+        this.provider.loadSchemaStore(config).open(config);
+        this.provider.init();
+        this.sessions =
+                new HbaseSessions(config, GRAPH_NAME, 
this.provider.loadGraphStore(config).store());
+        this.sessions.open();
+    }
+
+    @After
+    public void tearDown() {
+        if (this.sessions != null) {
+            try {
+                this.sessions.close();
+            } catch (Exception e) {
+                LOG.warn("Failed to close sessions ", e);
+            }
+        }
+        if (this.provider != null){

Review Comment:
   Missing space after `if` keyword. Should be `if (this.provider != null) {` 
for consistency with the code style used elsewhere in the method (line 56).
   ```suggestion
           if (this.provider != null) {
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/BaseHbaseUnitTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.unit.hbase;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.hugegraph.backend.store.hbase.HbaseSessions;
+import org.apache.hugegraph.backend.store.hbase.HbaseStoreProvider;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.testutil.Utils;
+import org.apache.hugegraph.unit.BaseUnitTest;
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class BaseHbaseUnitTest extends BaseUnitTest {
+
+    private static final String GRAPH_NAME = "test_graph";
+
+    protected HugeConfig config;
+    protected HbaseStoreProvider provider;
+    protected HbaseSessions sessions;
+
+    @Before
+    public void setup() throws IOException {
+        Configuration conf = Utils.getConf();
+        this.config = new HugeConfig(conf);
+        this.provider = new HbaseStoreProvider();
+        this.provider.open(GRAPH_NAME);
+        this.provider.loadSystemStore(config).open(config);
+        this.provider.loadGraphStore(config).open(config);
+        this.provider.loadSchemaStore(config).open(config);
+        this.provider.init();
+        this.sessions =
+                new HbaseSessions(config, GRAPH_NAME, 
this.provider.loadGraphStore(config).store());
+        this.sessions.open();
+    }
+
+    @After
+    public void tearDown() {
+        if (this.sessions != null) {
+            try {
+                this.sessions.close();
+            } catch (Exception e) {
+                LOG.warn("Failed to close sessions ", e);
+            }
+        }
+        if (this.provider != null){
+            try {
+                this.provider.close();
+            }catch (Exception e){

Review Comment:
   Missing space after `catch` keyword. Should be `} catch (Exception e) {` for 
consistency with the code style used on line 59.
   ```suggestion
               } catch (Exception e) {
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/BaseHbaseUnitTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.unit.hbase;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.hugegraph.backend.store.hbase.HbaseSessions;
+import org.apache.hugegraph.backend.store.hbase.HbaseStoreProvider;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.testutil.Utils;
+import org.apache.hugegraph.unit.BaseUnitTest;
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class BaseHbaseUnitTest extends BaseUnitTest {
+
+    private static final String GRAPH_NAME = "test_graph";
+
+    protected HugeConfig config;
+    protected HbaseStoreProvider provider;
+    protected HbaseSessions sessions;
+
+    @Before
+    public void setup() throws IOException {
+        Configuration conf = Utils.getConf();
+        this.config = new HugeConfig(conf);
+        this.provider = new HbaseStoreProvider();
+        this.provider.open(GRAPH_NAME);
+        this.provider.loadSystemStore(config).open(config);
+        this.provider.loadGraphStore(config).open(config);
+        this.provider.loadSchemaStore(config).open(config);
+        this.provider.init();
+        this.sessions =
+                new HbaseSessions(config, GRAPH_NAME, 
this.provider.loadGraphStore(config).store());
+        this.sessions.open();
+    }
+
+    @After
+    public void tearDown() {
+        if (this.sessions != null) {
+            try {
+                this.sessions.close();
+            } catch (Exception e) {
+                LOG.warn("Failed to close sessions ", e);
+            }
+        }
+        if (this.provider != null){
+            try {
+                this.provider.close();
+            }catch (Exception e){
+                LOG.warn("Failed to close provider ",e);

Review Comment:
   Missing space after comma in log message. Should be `"Failed to close 
provider ", e` for consistency with line 60.
   ```suggestion
                   LOG.warn("Failed to close provider ", e);
   ```



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/BaseHbaseUnitTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.unit.hbase;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.hugegraph.backend.store.hbase.HbaseSessions;
+import org.apache.hugegraph.backend.store.hbase.HbaseStoreProvider;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.testutil.Utils;
+import org.apache.hugegraph.unit.BaseUnitTest;
+import org.junit.After;
+import org.junit.Before;
+
+import java.io.IOException;
+
+public class BaseHbaseUnitTest extends BaseUnitTest {
+
+    private static final String GRAPH_NAME = "test_graph";
+
+    protected HugeConfig config;
+    protected HbaseStoreProvider provider;
+    protected HbaseSessions sessions;
+
+    @Before
+    public void setup() throws IOException {
+        Configuration conf = Utils.getConf();
+        this.config = new HugeConfig(conf);
+        this.provider = new HbaseStoreProvider();
+        this.provider.open(GRAPH_NAME);
+        this.provider.loadSystemStore(config).open(config);
+        this.provider.loadGraphStore(config).open(config);
+        this.provider.loadSchemaStore(config).open(config);
+        this.provider.init();
+        this.sessions =
+                new HbaseSessions(config, GRAPH_NAME, 
this.provider.loadGraphStore(config).store());
+        this.sessions.open();
+    }
+
+    @After
+    public void tearDown() {
+        if (this.sessions != null) {
+            try {
+                this.sessions.close();
+            } catch (Exception e) {
+                LOG.warn("Failed to close sessions ", e);
+            }
+        }
+        if (this.provider != null){
+            try {
+                this.provider.close();
+            }catch (Exception e){

Review Comment:
   Missing space after `catch` keyword. Should be `} catch (Exception e) {` for 
consistency with the code style used on line 59.
   ```suggestion
               } catch (Exception e) {
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to