This is an automated email from the ASF dual-hosted git repository.
vgalaxies pushed a commit to branch pd-store
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
The following commit(s) were added to refs/heads/pd-store by this push:
new 46cb612eb fix(pd-store): partially fix hstore backend core tests
failure (#2424)
46cb612eb is described below
commit 46cb612eb565fcc6da08947f4816a58ecb5912e2
Author: V_Galaxy <[email protected]>
AuthorDate: Mon Jan 29 22:49:48 2024 +0800
fix(pd-store): partially fix hstore backend core tests failure (#2424)
Some tests that are currently failing (not addressed in this PR):
1. Tests related to **olap** in `VertexCoreTest`: Not adapted yet.
2. Tests related to **paging** in `VertexCoreTest` and `EdgeCoreTest`:
Inconsistency in the definition of `position` between RocksDB scan iterator and
Hstore.
3. Some `RamTableTest` test cases: The ramtable feature is not supported by
the hstore backend.
---
.../backend/serializer/BinaryBackendEntry.java | 1 +
.../backend/serializer/BinarySerializer.java | 24 ++++++++++++++--------
.../hugegraph/backend/tx/SchemaTransactionV2.java | 24 +++++++++++++++++++++-
.../org/apache/hugegraph/core/EdgeCoreTest.java | 4 ++--
.../org/apache/hugegraph/core/VertexCoreTest.java | 4 ++--
5 files changed, 44 insertions(+), 13 deletions(-)
diff --git
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java
index 9deba24d7..c4c5156f0 100644
---
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java
+++
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java
@@ -48,6 +48,7 @@ public class BinaryBackendEntry implements BackendEntry {
this(type, BytesBuffer.wrap(bytes).parseId(type, enablePartition));
}
+ // FIXME: `enablePartition` is unused here
public BinaryBackendEntry(HugeType type, byte[] bytes, boolean
enablePartition, boolean isOlap) {
this(type, BytesBuffer.wrap(bytes).parseOlapId(type, isOlap));
}
diff --git
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java
index 0a4c9461a..740764dc3 100644
---
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java
+++
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java
@@ -689,8 +689,10 @@ public class BinarySerializer extends AbstractSerializer {
if (cq.paging() && !cq.page().isEmpty()) {
includeStart = true;
byte[] position = PageState.fromString(cq.page()).position();
- E.checkArgument(Bytes.compare(position, startId.asBytes()) >= 0,
- "Invalid page out of lower bound");
+ // FIXME: Due to the inconsistency in the definition of `position`
of RocksDB
+ // scan iterator and Hstore, temporarily remove the following
check.
+ // E.checkArgument(Bytes.compare(position, startId.asBytes()) >= 0,
+ // "Invalid page out of lower bound");
startId = new BinaryId(position, null);
}
if (range.keyMax() == null) {
@@ -800,8 +802,10 @@ public class BinarySerializer extends AbstractSerializer {
if (start == null) {
return new IdPrefixQuery(query, id);
}
- E.checkArgument(Bytes.compare(start.asBytes(), id.asBytes()) >= 0,
- "Invalid page out of lower bound");
+ // FIXME: Due to the inconsistency in the definition of `position`
of RocksDB
+ // scan iterator and Hstore, temporarily remove the following
check.
+ // E.checkArgument(Bytes.compare(start.asBytes(), id.asBytes()) >=
0,
+ // "Invalid page out of lower bound");
return new IdPrefixQuery(query, start, id);
}
@@ -830,8 +834,10 @@ public class BinarySerializer extends AbstractSerializer {
if (start == null) {
start = min;
} else {
- E.checkArgument(Bytes.compare(start.asBytes(), min.asBytes()) >= 0,
- "Invalid page out of lower bound");
+ // FIXME: Due to the inconsistency in the definition of `position`
of RocksDB
+ // scan iterator and Hstore, temporarily remove the following
check.
+ // E.checkArgument(Bytes.compare(start.asBytes(), min.asBytes())
>= 0,
+ // "Invalid page out of lower bound");
}
if (keyMax == null) {
@@ -924,8 +930,10 @@ public class BinarySerializer extends AbstractSerializer {
* the page to id and use it as the starting row for this query
*/
byte[] position = PageState.fromString(query.page()).position();
- E.checkArgument(Bytes.compare(position, prefix.asBytes()) >= 0,
- "Invalid page out of lower bound");
+ // FIXME: Due to the inconsistency in the definition of `position`
of RocksDB
+ // scan iterator and Hstore, temporarily remove the following
check.
+ // E.checkArgument(Bytes.compare(position, prefix.asBytes()) >= 0,
+ // "Invalid page out of lower bound");
BinaryId start = new BinaryId(position, null);
newQuery = new IdPrefixQuery(query, start, prefix);
} else {
diff --git
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java
index 408195f82..c199cfa12 100644
---
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java
+++
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java
@@ -288,7 +288,7 @@ public class SchemaTransactionV2 implements
ISchemaTransaction {
*/
LOG.debug("SchemaTransaction remove edge label '{}'", id);
EdgeLabel schema = this.getEdgeLabel(id);
- // TODO: uncomment later - el
+ // TODO: uncomment later - sub edge labels
//if (schema.edgeLabelType().parent()) {
// List<EdgeLabel> edgeLabels = this.getEdgeLabels();
// for (EdgeLabel edgeLabel : edgeLabels) {
@@ -375,7 +375,29 @@ public class SchemaTransactionV2 implements
ISchemaTransaction {
@Override
public void removeIndexLabelFromBaseLabel(IndexLabel indexLabel) {
+ HugeType baseType = indexLabel.baseType();
+ Id baseValue = indexLabel.baseValue();
+ SchemaLabel baseLabel;
+ if (baseType == HugeType.VERTEX_LABEL) {
+ baseLabel = this.getVertexLabel(baseValue);
+ } else {
+ assert baseType == HugeType.EDGE_LABEL;
+ baseLabel = this.getEdgeLabel(baseValue);
+ }
+ if (baseLabel == null) {
+ LOG.info("The base label '{}' of index label '{}' " +
+ "may be deleted before", baseValue, indexLabel);
+ return;
+ }
+ if (baseLabel.equals(VertexLabel.OLAP_VL)) {
+ return;
+ }
+
+ this.updateSchema(baseLabel, schema -> {
+ // NOTE: Do schema update in the lock block
+ baseLabel.removeIndexLabel(indexLabel.id());
+ });
}
protected void updateSchema(SchemaElement schema,
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 02be8a8ec..ef25b2303 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
@@ -517,7 +517,7 @@ public class EdgeCoreTest extends BaseCoreTest {
Assert.assertContains("Zero bytes may not occur in string " +
"parameters", e.getCause().getMessage());
});
- } else if (backend.equals("rocksdb") || backend.equals("hbase")) {
+ } else if (ImmutableSet.of("rocksdb", "hbase",
"hstore").contains(backend)) {
Assert.assertThrows(IllegalArgumentException.class, () -> {
james.addEdge("write", book, "time", "2017-5-27\u0000");
graph.tx().commit();
@@ -5822,7 +5822,7 @@ public class EdgeCoreTest extends BaseCoreTest {
String backend = graph.backend();
Set<String> nonZeroBackends = ImmutableSet.of("postgresql",
- "rocksdb", "hbase");
+ "rocksdb", "hbase",
"hstore");
if (nonZeroBackends.contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
louise.addEdge("strike", sean, "id", 4,
diff --git
a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexCoreTest.java
b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexCoreTest.java
index f6ed6b3d0..ddcbd0510 100644
---
a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexCoreTest.java
+++
b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexCoreTest.java
@@ -6254,7 +6254,7 @@ public class VertexCoreTest extends BaseCoreTest {
String backend = graph.backend();
Set<String> nonZeroBackends = ImmutableSet.of("postgresql",
- "rocksdb", "hbase");
+ "rocksdb", "hbase",
"hstore");
if (nonZeroBackends.contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
graph.addVertex(T.label, "person", "name", "0",
@@ -9071,7 +9071,7 @@ public class VertexCoreTest extends BaseCoreTest {
Assert.assertEquals(0, vertices.size());
String backend = graph.backend();
- if (ImmutableSet.of("rocksdb", "hbase").contains(backend)) {
+ if (ImmutableSet.of("rocksdb", "hbase", "hstore").contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
graph.addVertex(T.label, "person", "name", "0",
"city", "xyz\u0000efg", "age", 0);