From 27f098714832e80bbf28bcce20740ae5bbdfbc9d Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Sun, 28 Apr 2019 15:20:36 +0800 Subject: [PATCH 1/3] fix: edges cache is not cleared when clearing backend Change-Id: I8208caa89b7b4e2985798676b4c607180c85d38e --- .../java/com/baidu/hugegraph/HugeGraph.java | 7 ++ .../backend/cache/CachedGraphTransaction.java | 74 +++++++++++++++++++ .../cache/CachedSchemaTransaction.java | 9 ++- .../backend/tx/GraphTransaction.java | 2 +- 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java index 7e096e68db..8471574150 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java @@ -104,6 +104,7 @@ public class HugeGraph implements GremlinGraph { private final HugeConfig configuration; private final EventHub schemaEventHub; + private final EventHub graphEventHub; private final EventHub indexEventHub; private final RateLimiter rateLimiter; private final TaskManager taskManager; @@ -119,6 +120,7 @@ public HugeGraph(HugeConfig configuration) { this.configuration = configuration; this.schemaEventHub = new EventHub("schema"); + this.graphEventHub = new EventHub("graph"); this.indexEventHub = new EventHub("index"); final int limit = configuration.get(CoreOptions.RATE_LIMIT); @@ -137,6 +139,7 @@ public HugeGraph(HugeConfig configuration) { try { this.storeProvider = this.loadStoreProvider(); } catch (BackendException e) { + LockUtil.destroy(this.name); String message = "Failed to init backend store"; LOG.error("{}: {}", message, e.getMessage()); throw new HugeException(message); @@ -182,6 +185,10 @@ public EventHub schemaEventHub() { return this.schemaEventHub; } + public EventHub graphEventHub() { + return this.graphEventHub; + } + public EventHub indexEventHub() { return this.indexEventHub; } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java index 695675a9a6..2e8e81344d 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedGraphTransaction.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Set; import com.baidu.hugegraph.HugeGraph; import com.baidu.hugegraph.backend.cache.CachedBackendStore.QueryId; @@ -34,11 +35,15 @@ import com.baidu.hugegraph.backend.tx.GraphTransaction; import com.baidu.hugegraph.config.CoreOptions; import com.baidu.hugegraph.config.HugeConfig; +import com.baidu.hugegraph.event.EventHub; +import com.baidu.hugegraph.event.EventListener; import com.baidu.hugegraph.schema.IndexLabel; import com.baidu.hugegraph.structure.HugeEdge; import com.baidu.hugegraph.structure.HugeVertex; import com.baidu.hugegraph.type.HugeType; +import com.baidu.hugegraph.util.Events; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; public final class CachedGraphTransaction extends GraphTransaction { @@ -47,6 +52,9 @@ public final class CachedGraphTransaction extends GraphTransaction { private final Cache verticesCache; private final Cache edgesCache; + private EventListener storeEventListener; + private EventListener cacheEventListener; + public CachedGraphTransaction(HugeGraph graph, BackendStore store) { super(graph, store); @@ -59,6 +67,17 @@ public CachedGraphTransaction(HugeGraph graph, BackendStore store) { capacity = conf.get(CoreOptions.EDGE_CACHE_CAPACITY); expire = conf.get(CoreOptions.EDGE_CACHE_EXPIRE); this.edgesCache = this.cache("edge", capacity, expire); + + this.listenChanges(); + } + + @Override + public void close() { + try { + super.close(); + } finally { + this.unlistenChanges(); + } } private Cache cache(String prefix, int capacity, long expire) { @@ -68,6 +87,61 @@ private Cache cache(String prefix, int capacity, long expire) { return cache; } + private void listenChanges() { + // Listen store event: "store.init", "store.clear", ... + Set storeEvents = ImmutableSet.of(Events.STORE_INIT, + Events.STORE_CLEAR, + Events.STORE_TRUNCATE); + this.storeEventListener = event -> { + if (storeEvents.contains(event.name())) { + LOG.debug("Graph {} clear graph cache on event '{}'", + this.graph(), event.name()); + this.verticesCache.clear(); + this.edgesCache.clear(); + return true; + } + return false; + }; + this.store().provider().listen(this.storeEventListener); + + // Listen cache event: "cache"(invalid cache item) + this.cacheEventListener = event -> { + LOG.debug("Graph {} received graph cache event: {}", + this.graph(), event); + event.checkArgs(String.class, Id.class); + Object[] args = event.args(); + if (args[0].equals("invalid")) { + Id id = (Id) args[1]; + if (this.verticesCache.get(id) != null) { + // Invalidate vertex cache + this.verticesCache.invalidate(id); + } else if (this.edgesCache.get(id) != null) { + // Invalidate edge cache + this.edgesCache.invalidate(id); + } + return true; + } else if (args[0].equals("clear")) { + this.verticesCache.clear(); + this.edgesCache.clear(); + return true; + } + return false; + }; + EventHub schemaEventHub = this.graph().graphEventHub(); + if (!schemaEventHub.containsListener(Events.CACHE)) { + schemaEventHub.listen(Events.CACHE, this.cacheEventListener); + } + } + + private void unlistenChanges() { + // Unlisten store event + this.store().provider().unlisten(this.storeEventListener); + + // Unlisten cache event + EventHub graphEventHub = this.graph().graphEventHub(); + graphEventHub.unlisten(Events.CACHE, this.cacheEventListener); + } + @Override protected Iterator queryVerticesFromBackend(Query query) { if (!query.ids().isEmpty() && query.conditions().isEmpty()) { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index 357f6b8f5f..759b2c0940 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -85,7 +85,7 @@ private void listenChanges() { Events.STORE_TRUNCATE); this.storeEventListener = event -> { if (storeEvents.contains(event.name())) { - LOG.debug("Graph {} clear cache on event '{}'", + LOG.debug("Graph {} clear schema cache on event '{}'", this.graph(), event.name()); this.idCache.clear(); this.nameCache.clear(); @@ -98,7 +98,7 @@ private void listenChanges() { // Listen cache event: "cache"(invalid cache item) this.cacheEventListener = event -> { - LOG.debug("Graph {} received cache event: {}", + LOG.debug("Graph {} received schema cache event: {}", this.graph(), event); event.checkArgs(String.class, Id.class); Object[] args = event.args(); @@ -116,6 +116,11 @@ private void listenChanges() { this.nameCache.invalidate(prefixedName); } return true; + } else if (args[0].equals("clear")) { + this.idCache.clear(); + this.nameCache.clear(); + this.cachedTypes.clear(); + return true; } return false; }; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java index 62e063caa3..3e50207240 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java @@ -558,7 +558,7 @@ public void removeEdge(HugeEdge edge) { } public Iterator queryEdgesByVertex(Id id) { - return queryEdges(constructEdgesQuery(id, Directions.BOTH)); + return this.queryEdges(constructEdgesQuery(id, Directions.BOTH)); } public Iterator queryEdges(Object... edgeIds) { From 37b02a3b3e37a92f31e63f3b8ae05c8a568811cc Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Mon, 29 Apr 2019 14:40:22 +0800 Subject: [PATCH 2/3] add test cases Change-Id: If2b514a55689d686fac41c8d0fd10da3c2ecab8a --- hugegraph-core/pom.xml | 2 +- .../cache/CachedSchemaTransaction.java | 2 +- .../hugegraph/backend/cache/RamCache.java | 9 + .../com/baidu/hugegraph/testutil/Utils.java | 28 --- .../FakeObject.java => FakeObjects.java} | 24 ++- .../baidu/hugegraph/unit/UnitTestSuite.java | 4 + .../cache/CachedGraphTransactionTest.java | 123 +++++++++++ .../cache/CachedSchemaTransactionTest.java | 197 ++++++++++++++++++ .../hugegraph/unit/cache/RamCacheTest.java | 68 +++++- .../hugegraph/unit/core/CassandraTest.java | 30 +-- .../unit/core/ConditionQueryFlattenTest.java | 42 ++++ .../hugegraph/unit/core/JsonUtilTest.java | 13 +- .../unit/rocksdb/BaseRocksDBUnitTest.java | 9 +- 13 files changed, 484 insertions(+), 67 deletions(-) rename hugegraph-test/src/main/java/com/baidu/hugegraph/unit/{core/FakeObject.java => FakeObjects.java} (82%) create mode 100644 hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedGraphTransactionTest.java create mode 100644 hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedSchemaTransactionTest.java diff --git a/hugegraph-core/pom.xml b/hugegraph-core/pom.xml index b192b4819b..3311aad162 100644 --- a/hugegraph-core/pom.xml +++ b/hugegraph-core/pom.xml @@ -19,7 +19,7 @@ com.baidu.hugegraph hugegraph-common - 1.6.0 + 1.6.2 diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java index 759b2c0940..db7d32ab4e 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/CachedSchemaTransaction.java @@ -243,7 +243,7 @@ protected List getAllSchema(HugeType type) { } else { List results = super.getAllSchema(type); long free = this.idCache.capacity() - this.idCache.size(); - if (results.size() < free) { + if (results.size() <= free) { // Update cache for (T schema : results) { Id prefixedId = generateId(schema.type(), schema.id()); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java index 02dac63271..92d6a9b41a 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java @@ -173,6 +173,9 @@ private final void write(Id id, Object value) { @Watched(prefix = "ramcache") private final void remove(Id id) { + if (id == null) { + return; + } assert id != null; final Lock lock = this.keyLock.lock(id); @@ -193,6 +196,9 @@ private final void remove(Id id) { @Watched(prefix = "ramcache") @Override public Object get(Id id) { + if (id == null) { + return null; + } Object value = null; if (this.map.size() <= this.halfCapacity || this.map.containsKey(id)) { // Maybe the id removed by other threads and returned null value @@ -218,6 +224,9 @@ public Object get(Id id) { @Watched(prefix = "ramcache") @Override public Object getOrFetch(Id id, Function fetcher) { + if (id == null) { + return null; + } Object value = null; if (this.map.size() <= this.halfCapacity || this.map.containsKey(id)) { // Maybe the id removed by other threads and returned null value diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/testutil/Utils.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/testutil/Utils.java index 1d2fda1959..a3342dbde2 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/testutil/Utils.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/testutil/Utils.java @@ -19,8 +19,6 @@ package com.baidu.hugegraph.testutil; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.Date; import java.util.List; @@ -33,7 +31,6 @@ import com.baidu.hugegraph.testutil.FakeObjects.FakeEdge; import com.baidu.hugegraph.testutil.FakeObjects.FakeVertex; import com.baidu.hugegraph.util.DateUtil; -import com.baidu.hugegraph.util.E; public class Utils { @@ -83,29 +80,4 @@ public static boolean contains(List edges, FakeEdge fakeEdge) { public static Date date(String rawDate) { return DateUtil.parse(rawDate); } - - public static T invokeStatic(Class clazz, String methodName, - Object... args) { - Class[] classes = new Class[args.length]; - int i = 0; - for (Object arg : args) { - E.checkArgument(arg != null, "The argument can't be null"); - classes[i++] = arg.getClass(); - } - try { - Method method = clazz.getDeclaredMethod(methodName, classes); - method.setAccessible(true); - @SuppressWarnings("unchecked") - T result = (T) method.invoke(null, args); - return result; - } catch (NoSuchMethodException e) { - throw new RuntimeException(String.format( - "Can't find method '%s' of class '%s'", - methodName, clazz), e); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(String.format( - "Can't invoke method '%s' of class '%s'", - methodName, clazz), e); - } - } } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/FakeObject.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java similarity index 82% rename from hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/FakeObject.java rename to hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java index 39dda5cb7f..0a8554e7a1 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/FakeObject.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java @@ -17,12 +17,17 @@ * under the License. */ -package com.baidu.hugegraph.unit.core; +package com.baidu.hugegraph.unit; +import java.util.Collections; + +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.PropertiesConfiguration; import org.mockito.Mockito; import com.baidu.hugegraph.HugeGraph; import com.baidu.hugegraph.backend.id.Id; +import com.baidu.hugegraph.config.HugeConfig; import com.baidu.hugegraph.schema.EdgeLabel; import com.baidu.hugegraph.schema.IndexLabel; import com.baidu.hugegraph.schema.PropertyKey; @@ -34,12 +39,25 @@ import com.baidu.hugegraph.type.define.IdStrategy; import com.baidu.hugegraph.type.define.IndexType; -public final class FakeObject { +public final class FakeObjects { private final HugeGraph graph; - public FakeObject() { + public FakeObjects() { this.graph = Mockito.mock(HugeGraph.class); + Mockito.doReturn(newConfig()).when(this.graph).configuration(); + ; + } + + public FakeObjects(String name) { + this(); + Mockito.doReturn(name).when(this.graph).name(); + } + + public static HugeConfig newConfig() { + Configuration conf = Mockito.mock(PropertiesConfiguration.class); + Mockito.when(conf.getKeys()).thenReturn(Collections.emptyIterator()); + return new HugeConfig(conf); } public HugeGraph graph() { diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java index 98d0297fbe..a8b373e0fa 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java @@ -23,6 +23,8 @@ import org.junit.runners.Suite; import com.baidu.hugegraph.unit.cache.CacheManagerTest; +import com.baidu.hugegraph.unit.cache.CachedGraphTransactionTest; +import com.baidu.hugegraph.unit.cache.CachedSchemaTransactionTest; import com.baidu.hugegraph.unit.cache.RamCacheTest; import com.baidu.hugegraph.unit.core.AnalyzerTest; import com.baidu.hugegraph.unit.core.BackendMutationTest; @@ -37,6 +39,8 @@ @RunWith(Suite.class) @Suite.SuiteClasses({ RamCacheTest.class, + CachedSchemaTransactionTest.class, + CachedGraphTransactionTest.class, CacheManagerTest.class, VersionTest.class, diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedGraphTransactionTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedGraphTransactionTest.java new file mode 100644 index 0000000000..87ad3f88a2 --- /dev/null +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedGraphTransactionTest.java @@ -0,0 +1,123 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * 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 com.baidu.hugegraph.unit.cache; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.baidu.hugegraph.HugeGraph; +import com.baidu.hugegraph.backend.cache.CachedGraphTransaction; +import com.baidu.hugegraph.backend.id.Id; +import com.baidu.hugegraph.backend.id.IdGenerator; +import com.baidu.hugegraph.schema.VertexLabel; +import com.baidu.hugegraph.structure.HugeVertex; +import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.testutil.Whitebox; +import com.baidu.hugegraph.type.define.IdStrategy; +import com.baidu.hugegraph.unit.BaseUnitTest; +import com.baidu.hugegraph.unit.FakeObjects; +import com.baidu.hugegraph.util.Events; + +public class CachedGraphTransactionTest extends BaseUnitTest { + + private CachedGraphTransaction cache; + + @Before + public void setup() { + HugeGraph graph = new HugeGraph(FakeObjects.newConfig()); + this.cache = new CachedGraphTransaction(graph, graph.loadGraphStore()); + } + + @After + public void teardown() throws Exception { + this.cache().graph().clearBackend(); + this.cache().graph().close(); + } + + private CachedGraphTransaction cache() { + Assert.assertNotNull(this.cache); + return this.cache; + } + + private HugeVertex newVertex(Id id) { + HugeGraph graph = this.cache().graph(); + graph.schema().vertexLabel("person") + .idStrategy(IdStrategy.CUSTOMIZE_NUMBER) + .checkExist(false) + .create(); + VertexLabel vl = graph.vertexLabel("person"); + return new HugeVertex(graph, id, vl); + } + + @Test + public void testEventClear() throws Exception { + CachedGraphTransaction cache = this.cache(); + + cache.addVertex(this.newVertex(IdGenerator.of(1))); + cache.addVertex(this.newVertex(IdGenerator.of(2))); + cache.commit(); + + Assert.assertTrue(cache.queryVertices(IdGenerator.of(1)).hasNext()); + Assert.assertTrue(cache.queryVertices(IdGenerator.of(2)).hasNext()); + Assert.assertEquals(2L, + Whitebox.invoke(cache, "verticesCache", "size")); + + cache.graph().graphEventHub() + .notify(Events.CACHE, "clear", null).get(); + + Assert.assertEquals(0L, + Whitebox.invoke(cache, "verticesCache", "size")); + + Assert.assertTrue(cache.queryVertices(IdGenerator.of(1)).hasNext()); + Assert.assertEquals(1L, + Whitebox.invoke(cache, "verticesCache", "size")); + Assert.assertTrue(cache.queryVertices(IdGenerator.of(2)).hasNext()); + Assert.assertEquals(2L, + Whitebox.invoke(cache, "verticesCache", "size")); + } + + @Test + public void testEventInvalid() throws Exception { + + CachedGraphTransaction cache = this.cache(); + + cache.addVertex(this.newVertex(IdGenerator.of(1))); + cache.addVertex(this.newVertex(IdGenerator.of(2))); + cache.commit(); + + Assert.assertTrue(cache.queryVertices(IdGenerator.of(1)).hasNext()); + Assert.assertTrue(cache.queryVertices(IdGenerator.of(2)).hasNext()); + Assert.assertEquals(2L, + Whitebox.invoke(cache, "verticesCache", "size")); + + cache.graph().graphEventHub() + .notify(Events.CACHE, "invalid", IdGenerator.of(1)).get(); + + Assert.assertEquals(1L, + Whitebox.invoke(cache, "verticesCache", "size")); + Assert.assertTrue(cache.queryVertices(IdGenerator.of(2)).hasNext()); + Assert.assertEquals(1L, + Whitebox.invoke(cache, "verticesCache", "size")); + Assert.assertTrue(cache.queryVertices(IdGenerator.of(1)).hasNext()); + Assert.assertEquals(2L, + Whitebox.invoke(cache, "verticesCache", "size")); + } +} diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedSchemaTransactionTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedSchemaTransactionTest.java new file mode 100644 index 0000000000..404a274c88 --- /dev/null +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/CachedSchemaTransactionTest.java @@ -0,0 +1,197 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * 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 com.baidu.hugegraph.unit.cache; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.baidu.hugegraph.HugeGraph; +import com.baidu.hugegraph.backend.cache.CachedSchemaTransaction; +import com.baidu.hugegraph.backend.id.Id; +import com.baidu.hugegraph.backend.id.IdGenerator; +import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.testutil.Whitebox; +import com.baidu.hugegraph.type.HugeType; +import com.baidu.hugegraph.unit.BaseUnitTest; +import com.baidu.hugegraph.unit.FakeObjects; +import com.baidu.hugegraph.util.Events; +import com.google.common.collect.ImmutableMap; + +public class CachedSchemaTransactionTest extends BaseUnitTest { + + private CachedSchemaTransaction cache; + + @Before + public void setup() { + HugeGraph graph = new HugeGraph(FakeObjects.newConfig()); + this.cache = new CachedSchemaTransaction(graph, graph.loadSchemaStore()); + } + + @After + public void teardown() throws Exception { + this.cache().graph().clearBackend(); + this.cache().graph().close(); + } + + private CachedSchemaTransaction cache() { + Assert.assertNotNull(this.cache); + return this.cache; + } + + @Test + public void testEventClear() throws Exception { + CachedSchemaTransaction cache = this.cache(); + + FakeObjects objects = new FakeObjects("unit-test"); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(1), + "fake-pk-1")); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(2), + "fake-pk-2")); + + Assert.assertEquals(2L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(2L, Whitebox.invoke(cache, "nameCache", "size")); + + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + + Assert.assertEquals("fake-pk-2", + cache.getPropertyKey(IdGenerator.of(2)).name()); + Assert.assertEquals(IdGenerator.of(2), + cache.getPropertyKey("fake-pk-2").id()); + + cache.graph().schemaEventHub() + .notify(Events.CACHE, "clear", null).get(); + + Assert.assertEquals(0L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(0L, Whitebox.invoke(cache, "nameCache", "size")); + + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + + Assert.assertEquals("fake-pk-2", + cache.getPropertyKey(IdGenerator.of(2)).name()); + Assert.assertEquals(IdGenerator.of(2), + cache.getPropertyKey("fake-pk-2").id()); + + Assert.assertEquals(2L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(2L, Whitebox.invoke(cache, "nameCache", "size")); + } + + @Test + public void testEventInvalid() throws Exception { + CachedSchemaTransaction cache = this.cache(); + + FakeObjects objects = new FakeObjects("unit-test"); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(1), + "fake-pk-1")); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(2), + "fake-pk-2")); + + Assert.assertEquals(2L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(2L, Whitebox.invoke(cache, "nameCache", "size")); + + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + + Assert.assertEquals("fake-pk-2", + cache.getPropertyKey(IdGenerator.of(2)).name()); + Assert.assertEquals(IdGenerator.of(2), + cache.getPropertyKey("fake-pk-2").id()); + + Id key = Whitebox.invokeStatic(CachedSchemaTransaction.class, + new Class[]{HugeType.class, Id.class}, + "generateId", HugeType.PROPERTY_KEY, + IdGenerator.of(1)); + cache.graph().schemaEventHub() + .notify(Events.CACHE, "invalid", key).get(); + + Assert.assertEquals(1L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(1L, Whitebox.invoke(cache, "nameCache", "size")); + + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + + Assert.assertEquals("fake-pk-2", + cache.getPropertyKey(IdGenerator.of(2)).name()); + Assert.assertEquals(IdGenerator.of(2), + cache.getPropertyKey("fake-pk-2").id()); + + Assert.assertEquals(2L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(2L, Whitebox.invoke(cache, "nameCache", "size")); + } + + @Test + public void testGetSchema() throws Exception { + CachedSchemaTransaction cache = this.cache(); + + FakeObjects objects = new FakeObjects("unit-test"); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(1), + "fake-pk-1")); + + cache.graph().schemaEventHub() + .notify(Events.CACHE, "clear", null).get(); + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + + cache.graph().schemaEventHub() + .notify(Events.CACHE, "clear", null).get(); + Assert.assertEquals(IdGenerator.of(1), + cache.getPropertyKey("fake-pk-1").id()); + Assert.assertEquals("fake-pk-1", + cache.getPropertyKey(IdGenerator.of(1)).name()); + } + + @Test + public void testResetCachedAllIfReachedCapacity() throws Exception { + CachedSchemaTransaction cache = this.cache(); + + Whitebox.setInternalState(cache, "idCache.capacity", 2); + Assert.assertEquals(0L, Whitebox.invoke(cache, "idCache", "size")); + + FakeObjects objects = new FakeObjects("unit-test"); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(1), + "fake-pk-1")); + Assert.assertEquals(1L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(1, cache.getPropertyKeys().size()); + Assert.assertEquals(ImmutableMap.of(HugeType.PROPERTY_KEY, true), + Whitebox.getInternalState(cache, "cachedTypes")); + + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(3), + "fake-pk-2")); + cache.addPropertyKey(objects.newPropertyKey(IdGenerator.of(2), + "fake-pk-3")); + + Assert.assertEquals(2L, Whitebox.invoke(cache, "idCache", "size")); + Assert.assertEquals(3, cache.getPropertyKeys().size()); + Assert.assertEquals(ImmutableMap.of(), + Whitebox.getInternalState(cache, "cachedTypes")); + } +} diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/RamCacheTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/RamCacheTest.java index ae7e99924b..cf24a37e75 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/RamCacheTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/cache/RamCacheTest.java @@ -23,14 +23,16 @@ import java.util.Map; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.baidu.hugegraph.backend.cache.RamCache; import com.baidu.hugegraph.backend.id.Id; import com.baidu.hugegraph.backend.id.IdGenerator; +import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.testutil.Whitebox; import com.baidu.hugegraph.unit.BaseUnitTest; +import com.baidu.hugegraph.util.Bytes; public class RamCacheTest extends BaseUnitTest { @@ -123,8 +125,21 @@ public void testInvalidate() { Id id = IdGenerator.of("1"); cache.update(id, "value-1"); Assert.assertEquals("value-1", cache.get(id)); + Assert.assertEquals(1L, cache.size()); + + Object queue = Whitebox.getInternalState(cache, "queue"); + Assert.assertThrows(RuntimeException.class, () -> { + Whitebox.invoke(queue.getClass(), new Class[]{Object.class}, + "checkNotInQueue", queue, id); + }); + cache.invalidate(id); Assert.assertEquals(null, cache.get(id)); + Assert.assertEquals(0L, cache.size()); + + Assert.assertTrue(Whitebox.invoke(queue.getClass(), + new Class[]{Object.class}, + "checkNotInQueue", queue, id)); } @Test @@ -157,6 +172,10 @@ public void testCapacity() { cache = new RamCache(0); Assert.assertEquals(0, cache.capacity()); + int huge = (int) (200 * Bytes.GB); + cache = new RamCache(huge); + Assert.assertEquals(huge, cache.capacity()); + // The min capacity is 0 cache = new RamCache(-1); Assert.assertEquals(0, cache.capacity()); @@ -182,6 +201,34 @@ public void testSizeWithReachCapacity() { Assert.assertEquals(10, cache.size()); } + @Test + public void testHitsAndMiss() { + RamCache cache = new RamCache(); + Assert.assertEquals(0L, cache.hits()); + Assert.assertEquals(0L, cache.miss()); + + Id id = IdGenerator.of("1"); + cache.update(id, "value-1"); + Assert.assertEquals(0L, cache.hits()); + Assert.assertEquals(0L, cache.miss()); + + cache.get(IdGenerator.of("not-exist")); + Assert.assertEquals(0L, cache.hits()); + Assert.assertEquals(1L, cache.miss()); + + cache.get(IdGenerator.of("1")); + Assert.assertEquals(1L, cache.hits()); + Assert.assertEquals(1L, cache.miss()); + + cache.get(IdGenerator.of("not-exist")); + Assert.assertEquals(1L, cache.hits()); + Assert.assertEquals(2L, cache.miss()); + + cache.get(IdGenerator.of("1")); + Assert.assertEquals(2L, cache.hits()); + Assert.assertEquals(2L, cache.miss()); + } + @Test public void testExpire() { RamCache cache = new RamCache(); @@ -189,8 +236,10 @@ public void testExpire() { cache.update(IdGenerator.of("2"), "value-2"); Assert.assertEquals(2, cache.size()); + Assert.assertEquals(0L, cache.expire()); cache.expire(2); // 2 seconds + Assert.assertEquals(2000L, cache.expire()); waitTillNext(2); cache.tick(); @@ -277,7 +326,7 @@ public void testMutiThreadsUpdateAndCheck() { RamCache cache = new RamCache(); runWithThreads(THREADS_NUM, () -> { - Map map = new HashMap<>(1000); + Map all = new HashMap<>(1000); for (int i = 0; i < 1000; i++) { Id id = IdGenerator.of(Thread.currentThread().getName() + @@ -285,12 +334,19 @@ public void testMutiThreadsUpdateAndCheck() { String value = "value-" + i; cache.update(id, value); - map.put(id, value); + all.put(id, value); } - for (Map.Entry entry : map.entrySet()) { - Assert.assertEquals(entry.getValue(), - cache.get(entry.getKey())); + @SuppressWarnings("unchecked") + Map map = (Map) Whitebox.getInternalState(cache, + "map"); + Object queue = Whitebox.getInternalState(cache, "queue"); + for (Map.Entry entry : all.entrySet()) { + Id key = entry.getKey(); + Assert.assertEquals(entry.getValue(), cache.get(key)); + Assert.assertTrue(Whitebox.invoke(queue.getClass(), + "checkPrevNotInNext", + queue, map.get(key))); } }); Assert.assertEquals(THREADS_NUM * 1000, cache.size()); diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/CassandraTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/CassandraTest.java index c0a5d879d7..2851537c4e 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/CassandraTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/CassandraTest.java @@ -24,7 +24,6 @@ import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.PropertiesConfiguration; import org.junit.After; -import com.baidu.hugegraph.testutil.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -32,7 +31,8 @@ import com.baidu.hugegraph.backend.store.cassandra.CassandraOptions; import com.baidu.hugegraph.backend.store.cassandra.CassandraStore; import com.baidu.hugegraph.config.HugeConfig; -import com.baidu.hugegraph.testutil.Utils; +import com.baidu.hugegraph.testutil.Assert; +import com.baidu.hugegraph.testutil.Whitebox; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -62,9 +62,9 @@ public void testParseRepilcaWithSimpleStrategy() { .thenReturn(ImmutableList.of("5")); HugeConfig config = new HugeConfig(conf); - Map result = Utils.invokeStatic(CassandraStore.class, - "parseReplica", - config); + Map result = Whitebox.invokeStatic(CassandraStore.class, + "parseReplica", + config); Map expected = ImmutableMap.of( "class", "SimpleStrategy", @@ -86,9 +86,9 @@ public void testParseRepilcaWithNetworkTopologyStrategy() { .thenReturn(ImmutableList.of("dc1:2", "dc2:1")); HugeConfig config = new HugeConfig(conf); - Map result = Utils.invokeStatic(CassandraStore.class, - "parseReplica", - config); + Map result = Whitebox.invokeStatic(CassandraStore.class, + "parseReplica", + config); Map expected = ImmutableMap.of( "class", "NetworkTopologyStrategy", @@ -112,7 +112,7 @@ public void testParseRepilcaWithSimpleStrategyAndEmptyReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -131,7 +131,7 @@ public void testParseRepilcaWithSimpleStrategyAndDoubleReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -150,7 +150,7 @@ public void testParseRepilcaWithSimpleStrategyAndStringReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -169,7 +169,7 @@ public void testParseRepilcaWithNetworkTopologyStrategyAndStringReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -188,7 +188,7 @@ public void testParseRepilcaWithNetworkTopologyStrategyWithoutDatacenter() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -207,7 +207,7 @@ public void testParseRepilcaWithNetworkTopologyStrategyAndEmptyReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } @@ -226,7 +226,7 @@ public void testParseRepilcaWithNetworkTopologyStrategyAndDoubleReplica() { HugeConfig config = new HugeConfig(conf); Assert.assertThrows(RuntimeException.class, () -> { - Utils.invokeStatic(CassandraStore.class, "parseReplica", config); + Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config); }); } } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/ConditionQueryFlattenTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/ConditionQueryFlattenTest.java index 9852e824bb..0890c3bede 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/ConditionQueryFlattenTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/ConditionQueryFlattenTest.java @@ -26,6 +26,7 @@ import org.junit.After; import org.junit.Test; +import com.baidu.hugegraph.backend.id.Id; import com.baidu.hugegraph.backend.id.IdGenerator; import com.baidu.hugegraph.backend.query.Condition; import com.baidu.hugegraph.backend.query.ConditionQuery; @@ -33,6 +34,7 @@ import com.baidu.hugegraph.testutil.Assert; import com.baidu.hugegraph.type.HugeType; import com.baidu.hugegraph.unit.BaseUnitTest; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; public class ConditionQueryFlattenTest extends BaseUnitTest { @@ -218,5 +220,45 @@ public void testFlattenWithOrAndTree() { } Assert.assertEquals(expect, actual); } + + + @Test + public void testFlattenWithIn() { + Id key = IdGenerator.of("c1"); + + ConditionQuery query = new ConditionQuery(HugeType.VERTEX); + query.query(Condition.in(key, ImmutableList.of("1", "2", "3"))); + Assert.assertEquals(1, query.conditions().size()); + List queries = ConditionQueryFlatten.flatten(query); + Assert.assertEquals(3, queries.size()); + + Set expect = ImmutableSet.of(Condition.eq(key, "1"), + Condition.eq(key, "2"), + Condition.eq(key, "3")); + Set actual = new HashSet<>(); + for (ConditionQuery q : queries) { + Assert.assertEquals(1, q.conditions().size()); + actual.add(q.conditions().iterator().next()); + } + + Assert.assertEquals(expect, actual); + } + + @Test + public void testFlattenWithNotIn() { + Id key = IdGenerator.of("c1"); + + ConditionQuery query = new ConditionQuery(HugeType.VERTEX); + query.query(Condition.nin(key, ImmutableList.of("1", "2", "3"))); + Assert.assertEquals(1, query.conditions().size()); + List queries = ConditionQueryFlatten.flatten(query); + Assert.assertEquals(1, queries.size()); + + Set expect = ImmutableSet.of(Condition.neq(key, "1"), + Condition.neq(key, "2"), + Condition.neq(key, "3")); + Set actual = queries.iterator().next().conditions(); + Assert.assertEquals(expect, actual); + } } diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/JsonUtilTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/JsonUtilTest.java index 3886906df7..946d0eb9df 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/JsonUtilTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/core/JsonUtilTest.java @@ -50,6 +50,7 @@ import com.baidu.hugegraph.type.define.IdStrategy; import com.baidu.hugegraph.type.define.IndexType; import com.baidu.hugegraph.unit.BaseUnitTest; +import com.baidu.hugegraph.unit.FakeObjects; import com.baidu.hugegraph.util.JsonUtil; import com.google.common.collect.ImmutableMap; @@ -81,7 +82,7 @@ public void testSerializeLongId() { @Test public void testSerializePropertyKey() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); String json = JsonUtil.toJson(name); Assert.assertEquals("{\"id\":1,\"name\":\"name\"," + @@ -100,7 +101,7 @@ public void testSerializePropertyKey() { @Test public void testSerializeVertexLabel() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, @@ -126,7 +127,7 @@ public void testSerializeVertexLabel() { @Test public void testSerializeEdgeLabel() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, @@ -165,7 +166,7 @@ public void testSerializeEdgeLabel() { @Test public void testSerializeIndexLabel() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, @@ -208,7 +209,7 @@ public void testSerializeEdgeId() { @Test public void testSerializeVertexWithNumberId() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, @@ -239,7 +240,7 @@ public void testSerializeVertexWithNumberId() { @Test public void testSerializeEdge() { - FakeObject fakeObject = new FakeObject(); + FakeObjects fakeObject = new FakeObjects(); PropertyKey name = fakeObject.newPropertyKey(IdGenerator.of(1), "name"); PropertyKey age = fakeObject.newPropertyKey(IdGenerator.of(2), "age", DataType.INT, diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/rocksdb/BaseRocksDBUnitTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/rocksdb/BaseRocksDBUnitTest.java index 919e9f2312..0b114af9f2 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/rocksdb/BaseRocksDBUnitTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/rocksdb/BaseRocksDBUnitTest.java @@ -23,21 +23,18 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; -import java.util.Collections; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; -import org.mockito.Mockito; import org.rocksdb.RocksDBException; import com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions; import com.baidu.hugegraph.backend.store.rocksdb.RocksDBStdSessions; import com.baidu.hugegraph.config.HugeConfig; import com.baidu.hugegraph.unit.BaseUnitTest; +import com.baidu.hugegraph.unit.FakeObjects; public class BaseRocksDBUnitTest extends BaseUnitTest { @@ -113,9 +110,7 @@ protected static long l(byte[] bytes) { } private static RocksDBSessions open(String table) throws RocksDBException { - Configuration conf = Mockito.mock(PropertiesConfiguration.class); - Mockito.when(conf.getKeys()).thenReturn(Collections.emptyIterator()); - HugeConfig config = new HugeConfig(conf); + HugeConfig config = FakeObjects.newConfig(); RocksDBSessions rocks = new RocksDBStdSessions(config, DB_PATH, DB_PATH, "db", "store"); rocks.createTable(table); From 8c190464df695d810a38d32e6e7b968dbc4e2bbd Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Wed, 22 May 2019 21:24:04 +0800 Subject: [PATCH 3/3] tiny improve Change-Id: If19605c17b55cee1f8539410aeb473cd3a4a00e2 --- .../src/main/java/com/baidu/hugegraph/unit/FakeObjects.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java index 0a8554e7a1..a727b325c3 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/unit/FakeObjects.java @@ -46,7 +46,6 @@ public final class FakeObjects { public FakeObjects() { this.graph = Mockito.mock(HugeGraph.class); Mockito.doReturn(newConfig()).when(this.graph).configuration(); - ; } public FakeObjects(String name) {