diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java index c7a43e228..30bffab81 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java @@ -150,4 +150,8 @@ public class CacheManager { "Invalid cache implement: %s", cache.getClass()); return cache; } + + public void clearCache() { + this.caches.clear(); + } } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java index ef6bcc03b..e6a5e7853 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java @@ -86,8 +86,7 @@ public class CachedSchemaTransactionV2 extends SchemaTransactionV2 { private Cache cache(String prefix, long capacity) { // TODO: uncomment later - graph space - //final String name = prefix + "-" + this.graph().spaceGraphName(); - final String name = prefix + "-" + ""; + final String name = prefix + "-" + this.graphName(); // NOTE: must disable schema cache-expire due to getAllSchema() return CacheManager.instance().cache(name, capacity); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java index ce399fe40..316535139 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java @@ -23,7 +23,6 @@ import java.lang.reflect.Method; import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.id.IdGenerator; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.job.SysJob; import org.apache.hugegraph.schema.SchemaElement; import org.apache.hugegraph.type.HugeType; @@ -89,7 +88,7 @@ public abstract class SchemaJob extends SysJob { protected static void removeSchema(ISchemaTransaction tx, SchemaElement schema) { try { - Method method = SchemaTransaction.class + Method method = ISchemaTransaction.class .getDeclaredMethod("removeSchema", SchemaElement.class); method.setAccessible(true); @@ -109,10 +108,10 @@ public abstract class SchemaJob extends SysJob { * @param tx The update operation actual execute * @param schema the schema to be updated */ - protected static void updateSchema(SchemaTransaction tx, + protected static void updateSchema(ISchemaTransaction tx, SchemaElement schema) { try { - Method method = SchemaTransaction.class + Method method = ISchemaTransaction.class .getDeclaredMethod("updateSchema", SchemaElement.class); method.setAccessible(true); diff --git a/hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java b/hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java index 27de0e029..e091bc42f 100755 --- a/hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java +++ b/hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java @@ -247,7 +247,7 @@ public class HstoreSessionsImpl extends HstoreSessions { this.gotNext = false; // QUESTION: Resetting the position may result in the caller being unable to // retrieve the corresponding position. - // this.position = null; + this.position = null; } if (!ArrayUtils.isEmpty(this.keyBegin) || !ArrayUtils.isEmpty(this.keyEnd)) { @@ -320,7 +320,7 @@ public class HstoreSessionsImpl extends HstoreSessions { } else { // QUESTION: Resetting the position may result in the caller being unable to // retrieve the corresponding position. - // this.position = null; + this.position = null; } return gotNext; } diff --git a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/BaseCoreTest.java b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/BaseCoreTest.java index dea160b08..a04253384 100644 --- a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/BaseCoreTest.java +++ b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/BaseCoreTest.java @@ -21,6 +21,7 @@ import java.util.Random; import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.HugeGraphParams; +import org.apache.hugegraph.backend.cache.CacheManager; import org.apache.hugegraph.backend.store.BackendFeatures; import org.apache.hugegraph.dist.RegisterUtil; import org.apache.hugegraph.masterelection.GlobalMasterInfo; @@ -90,6 +91,9 @@ public class BaseCoreTest { public void setup() { this.clearData(); this.clearSchema(); + // QUESTION: here we should consider to clear cache + // but with this line of code, many ci will fail + // this.clearCache(); } @After @@ -146,6 +150,11 @@ public class BaseCoreTest { }); } + private void clearCache() { + CacheManager cacheManager = CacheManager.instance(); + cacheManager.clearCache(); + } + protected void mayCommitTx() { // Commit tx probabilistically for test if (new Random().nextBoolean()) { diff --git a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java index 80d04e984..1189356bf 100644 --- a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java +++ b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java @@ -5195,6 +5195,7 @@ public class EdgeCoreTest extends BaseCoreTest { query.scan(String.valueOf(Long.MIN_VALUE), String.valueOf(Long.MAX_VALUE)); } else { + // QUESTION:The query method may not be well adapted query.scan(BackendTable.ShardSplitter.START, BackendTable.ShardSplitter.END); } diff --git a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/MultiGraphsTest.java b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/MultiGraphsTest.java index 85c2e33c7..084956798 100644 --- a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/MultiGraphsTest.java +++ b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/MultiGraphsTest.java @@ -92,11 +92,11 @@ public class MultiGraphsTest extends BaseCoreTest { SchemaManager schema = g1.schema(); - schema.propertyKey("id").asInt().create(); - schema.propertyKey("name").asText().create(); - schema.propertyKey("age").asInt().valueSingle().create(); - schema.propertyKey("city").asText().create(); - schema.propertyKey("weight").asDouble().valueList().create(); + schema.propertyKey("id").asInt().checkExist(false).create(); + schema.propertyKey("name").asText().checkExist(false).create(); + schema.propertyKey("age").asInt().valueSingle().checkExist(false).create(); + schema.propertyKey("city").asText().checkExist(false).create(); + schema.propertyKey("weight").asDouble().valueList().checkExist(false).create(); schema.propertyKey("born").asDate().ifNotExist().create(); schema.propertyKey("time").asDate().ifNotExist().create(); @@ -211,8 +211,8 @@ public class MultiGraphsTest extends BaseCoreTest { g1.serverStarted(GlobalMasterInfo.master("server-g1c")); g2.serverStarted(GlobalMasterInfo.master("server-g2c")); - g1.schema().propertyKey("id").asInt().create(); - g2.schema().propertyKey("id").asText().create(); + g1.schema().propertyKey("id").asInt().checkExist(false).create(); + g2.schema().propertyKey("id").asText().checkExist(false).create(); Assert.assertThrows(ExistedException.class, () -> { g2.schema().copyFrom(g1.schema()); diff --git a/hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/KvPageScanner.java b/hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/KvPageScanner.java index 0b7f277f3..1f8956f6d 100644 --- a/hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/KvPageScanner.java +++ b/hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/KvPageScanner.java @@ -195,9 +195,9 @@ class KvPageScanner implements KvCloseableIterator, HgPageSize, HgSeekAble { return false; } // QUESTION: After `this.iterator.hasNext()` evaluates to false, - // no further attempts are made to reconstruct the iterator. - if (this.iterator != null) { - return this.iterator.hasNext(); + // no further attempts should make to reconstruct the iterator. + if (this.iterator != null && this.iterator.hasNext()) { + return true; } long start = 0; boolean debugEnabled = log.isDebugEnabled(); diff --git a/pom.xml b/pom.xml index 7442ff196..b887e511e 100644 --- a/pom.xml +++ b/pom.xml @@ -177,10 +177,14 @@ .repository/** **/.flattened-pom.xml - **/rocksdb-*/** + **/rocksdb*/** **/hbase-*/** **/apache-cassandra-*/** **/pid + **/tmp/** + + **/src/main/java/org/apache/hugegraph/pd/grpc/** + **/src/main/java/org/apache/hugegraph/store/grpc/** true