You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by GitBox <gi...@apache.org> on 2022/06/01 02:25:24 UTC

[GitHub] [incubator-hugegraph] javeme commented on a diff in pull request #1891: Add system schema store

javeme commented on code in PR #1891:
URL: https://github.com/apache/incubator-hugegraph/pull/1891#discussion_r886263353


##########
hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java:
##########
@@ -782,5 +782,45 @@ public void removeOlapTable(Id id) {
             table.dropTable(this.session());
             this.unregisterTableManager(name);
         }
+
+        public CassandraSessionPool.Session getSession() {

Review Comment:
   remove getSession() method and CassandraStore.session()



##########
hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseStore.java:
##########
@@ -550,5 +550,45 @@ public long getCounter(HugeType type) {
             throw new UnsupportedOperationException(
                       "HbaseGraphStore.getCounter()");
         }
+
+        public Session getSession() {

Review Comment:
   ditto



##########
hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java:
##########
@@ -782,5 +782,45 @@ public void removeOlapTable(Id id) {
             table.dropTable(this.session());
             this.unregisterTableManager(name);
         }
+
+        public CassandraSessionPool.Session getSession() {
+            return super.sessions.session();
+        }
+    }
+
+    public static class CassandraSystemStore extends CassandraGraphStore {
+
+        private final CassandraTables.Meta meta;
+
+        public CassandraSystemStore(BackendStoreProvider provider,
+                                    String keyspace, String store) {
+            super(provider, keyspace, store);
+
+            this.meta = new CassandraTables.Meta();
+        }
+
+        @Override
+        public void init() {
+            super.init();
+            this.checkOpened();
+            CassandraSessionPool.Session session = this.getSession();
+            String driverVersion = this.provider().driverVersion();
+            this.meta.writeVersion(session, driverVersion);

Review Comment:
   this.meta.writeVersion(session(), driverVersion)



##########
hugegraph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java:
##########
@@ -782,5 +782,45 @@ public void removeOlapTable(Id id) {
             table.dropTable(this.session());
             this.unregisterTableManager(name);
         }
+
+        public CassandraSessionPool.Session getSession() {
+            return super.sessions.session();
+        }
+    }
+
+    public static class CassandraSystemStore extends CassandraGraphStore {
+
+        private final CassandraTables.Meta meta;
+
+        public CassandraSystemStore(BackendStoreProvider provider,
+                                    String keyspace, String store) {
+            super(provider, keyspace, store);
+
+            this.meta = new CassandraTables.Meta();
+        }
+
+        @Override
+        public void init() {
+            super.init();
+            this.checkOpened();
+            CassandraSessionPool.Session session = this.getSession();
+            String driverVersion = this.provider().driverVersion();
+            this.meta.writeVersion(session, driverVersion);
+            LOG.info("Write down the backend version: {}", driverVersion);
+        }
+
+        @Override
+        public String storedVersion() {
+            this.checkOpened();
+            CassandraSessionPool.Session session = this.getSession();
+            return this.meta.readVersion(session);

Review Comment:
   this.meta.readVersion(session())



##########
hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java:
##########
@@ -1092,5 +1095,57 @@ public void removeOlapTable(Id id) {
             this.dropTable(db, table.table());
             this.unregisterTableManager(this.olapTableName(id));
         }
+
+        public Session getSession() {
+            return super.sessions.session();
+        }
+    }
+
+    public static class RocksDBSystemStore extends RocksDBGraphStore {
+
+        private final RocksDBTables.Meta meta;
+
+        public RocksDBSystemStore(BackendStoreProvider provider,
+                                  String database, String store) {
+            super(provider, database, store);
+
+            this.meta = new RocksDBTables.Meta(database);
+        }
+
+        @Override
+        public synchronized void init() {
+            super.init();
+            Lock writeLock = this.storeLock().writeLock();
+            writeLock.lock();
+            try {
+                super.checkOpened();

Review Comment:
   remove checkOpened() after replaced by session() call



##########
hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java:
##########
@@ -471,5 +471,46 @@ public long getCounter(HugeType type) {
             throw new UnsupportedOperationException(
                       "MysqlGraphStore.getCounter()");
         }
+
+        public Session getSession() {

Review Comment:
   ditto



##########
hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java:
##########
@@ -179,18 +179,17 @@ public interface HugeGraph extends Graph {
 
     String backend();
 
-    String backendVersion();
-
-    BackendStoreSystemInfo backendStoreSystemInfo();
-
     BackendFeatures backendStoreFeatures();
 
+    BackendStoreInfo backendStoreInfo();
+
     GraphMode mode();
 
     void mode(GraphMode mode);
 
     GraphReadMode readMode();
 
+

Review Comment:
   empty line



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java:
##########
@@ -998,6 +998,12 @@ public HugeGraph graph() {
             return this.taskScheduler.graph();
         }
 
+        @Override
+        public void init() {
+            verifyAdminPermission();

Review Comment:
   this.verifyAdminPermission()



##########
hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java:
##########
@@ -1092,5 +1095,57 @@ public void removeOlapTable(Id id) {
             this.dropTable(db, table.table());
             this.unregisterTableManager(this.olapTableName(id));
         }
+
+        public Session getSession() {

Review Comment:
   ditto



##########
hugegraph-core/src/main/java/com/baidu/hugegraph/schema/VertexLabel.java:
##########
@@ -40,7 +40,7 @@ public class VertexLabel extends SchemaLabel {
     // OLAP_VL_ID means all of vertex label ids
     private static final Id OLAP_VL_ID = IdGenerator.of(SchemaLabel.OLAP_VL_ID);
     // OLAP_VL_NAME means all of vertex label names
-    private static final String OLAP_VL_NAME = "~olap";
+    private static final String OLAP_VL_NAME = "olap";

Review Comment:
   "*olap"



##########
hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java:
##########
@@ -1161,6 +1167,12 @@ private String currentUsername() {
             return null;
         }
 
+        @Override
+        public void init() {
+            verifyAdminPermission();

Review Comment:
   ditto



-- 
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: commits-unsubscribe@hugegraph.apache.org

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