-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix bug traverseByLabel() not set page every loop #805
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,11 @@ | |
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.apache.tinkerpop.gremlin.process.traversal.P; | ||
import org.apache.tinkerpop.gremlin.structure.Edge; | ||
import org.apache.tinkerpop.gremlin.structure.T; | ||
import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
import org.junit.Assume; | ||
import org.junit.Test; | ||
|
||
import com.baidu.hugegraph.HugeException; | ||
|
@@ -433,7 +435,7 @@ public void testAddEdgeLabelWithEnableLabelIndex() { | |
} | ||
|
||
@Test | ||
public void testAddEdgeLabelWithDisableeLabelIndex() { | ||
public void testAddEdgeLabelWithDisableLabelIndex() { | ||
super.initPropertyKeys(); | ||
HugeGraph graph = graph(); | ||
SchemaManager schema = graph.schema(); | ||
|
@@ -873,6 +875,65 @@ public void testRemoveEdgeLabelWithEdgeAndSecondaryIndex() { | |
}); | ||
} | ||
|
||
@Test | ||
public void testRebuildIndexOfEdgeLabelWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add case graph().traversal().E().hasLabel(xx) |
||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().E().hasLabel("read").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
e.getMessage().endsWith("it disables label index")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use assertContains() instead and rebase on apache/incubator-hugegraph-commons#43 |
||
}); | ||
|
||
// Query by property index is ok | ||
List<Edge> edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")) | ||
.toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
|
||
graph().schema().edgeLabel("read").rebuildIndex(); | ||
|
||
edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")).toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
} | ||
|
||
@Test | ||
public void testRemoveEdgeLabelWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().E().hasLabel("read").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use assertContains() instead and rebase on apache/incubator-hugegraph-commons#43 |
||
e.getMessage().endsWith("it disables label index")); | ||
}); | ||
|
||
// Query by property index is ok | ||
List<Edge> edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")) | ||
.toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
|
||
graph().schema().edgeLabel("read").remove(); | ||
|
||
Assert.assertThrows(NoIndexException.class, () -> | ||
graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")).toList() | ||
); | ||
} | ||
|
||
@Test | ||
public void testAddEdgeLabelWithUserdata() { | ||
super.initPropertyKeys(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1401,6 +1401,121 @@ public void testRebuildIndexLabelOfEdge() { | |
Assert.assertNotNull(edge); | ||
} | ||
|
||
@Test | ||
public void testRebuildIndexOfVertexWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add case graph().traversal().V().hasLabel(xx) |
||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().V().hasLabel("reader").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
e.getMessage().endsWith("it disables label index")); | ||
}); | ||
|
||
// Query by property index is ok | ||
List<Vertex> vertices = graph().traversal().V() | ||
.has("city", "Shanghai").toList(); | ||
Assert.assertEquals(10, vertices.size()); | ||
|
||
graph().schema().indexLabel("readerByCity").rebuild(); | ||
|
||
vertices = graph().traversal().V() | ||
.has("city", "Shanghai").toList(); | ||
Assert.assertEquals(10, vertices.size()); | ||
} | ||
|
||
@Test | ||
public void testRebuildIndexOfEdgeWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().E().hasLabel("read").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
e.getMessage().endsWith("it disables label index")); | ||
}); | ||
|
||
// Query by property index is ok | ||
List<Edge> edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")) | ||
.toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
|
||
graph().schema().indexLabel("readByDate").rebuild(); | ||
|
||
edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")).toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
} | ||
|
||
@Test | ||
public void testRemoveIndexLabelOfVertexWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().V().hasLabel("reader").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
e.getMessage().endsWith("it disables label index")); | ||
}); | ||
|
||
// Query by property index is ok | ||
List<Vertex> vertices = graph().traversal().V() | ||
.has("city", "Shanghai").toList(); | ||
Assert.assertEquals(10, vertices.size()); | ||
|
||
graph().schema().indexLabel("readerByCity").remove(); | ||
|
||
Assert.assertThrows(NoIndexException.class, () -> | ||
graph().traversal().V().has("city", "Shanghai").toList() | ||
); | ||
} | ||
|
||
@Test | ||
public void testRemoveIndexLabelOfEdgeWithoutLabelIndex() { | ||
Assume.assumeFalse("Support query by label", | ||
storeFeatures().supportsQueryByLabel()); | ||
|
||
initDataWithoutLabelIndex(); | ||
|
||
// Not support query by label | ||
Assert.assertThrows(NoIndexException.class, () -> { | ||
graph().traversal().E().hasLabel("read").toList(); | ||
}, e -> { | ||
Assert.assertTrue( | ||
e.getMessage().startsWith("Don't accept query by label") && | ||
e.getMessage().endsWith("it disables label index")); | ||
}); | ||
|
||
// Query by property index is ok | ||
List<Edge> edges = graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")) | ||
.toList(); | ||
Assert.assertEquals(20, edges.size()); | ||
|
||
graph().schema().indexLabel("readByDate").remove(); | ||
|
||
Assert.assertThrows(NoIndexException.class, () -> | ||
graph().traversal().E() | ||
.has("date", P.lt("2019-12-30 13:00:00")).toList() | ||
); | ||
} | ||
|
||
@Test | ||
public void testAddIndexLabelWithUserdata() { | ||
super.initPropertyKeys(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.commit();