use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class PathSummaryTest method testSetQNmFirstHelper.
private void testSetQNmFirstHelper(final PathSummaryReader pSummary) throws SirixException {
final Axis axis = new DescendantAxis(pSummary);
PathSummaryReader summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ELEMENT, summary.getPathKind());
assertEquals(1L, summary.getNodeKey());
assertEquals(7L, summary.getFirstChildKey());
assertEquals(-1L, summary.getLeftSiblingKey());
assertEquals(-1L, summary.getRightSiblingKey());
assertEquals(new QNm("ns", "p", "a"), axis.getTrx().getName());
assertEquals(1, summary.getLevel());
assertEquals(4, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ELEMENT, summary.getPathKind());
assertEquals(7L, summary.getNodeKey());
assertEquals(9L, summary.getFirstChildKey());
assertEquals(-1L, summary.getLeftSiblingKey());
assertEquals(4L, summary.getRightSiblingKey());
assertEquals(new QNm("foo"), axis.getTrx().getName());
assertEquals(2, summary.getLevel());
assertEquals(2, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ELEMENT, summary.getPathKind());
assertEquals(9L, summary.getNodeKey());
assertEquals(-1L, summary.getFirstChildKey());
assertEquals(-1L, summary.getLeftSiblingKey());
assertEquals(8L, summary.getRightSiblingKey());
assertEquals(new QNm("c"), axis.getTrx().getName());
assertEquals(3, summary.getLevel());
assertEquals(0, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ATTRIBUTE, summary.getPathKind());
assertEquals(8L, summary.getNodeKey());
assertEquals(9L, summary.getLeftSiblingKey());
assertEquals(-1L, summary.getRightSiblingKey());
assertEquals(-1L, summary.getFirstChildKey());
assertEquals(new QNm("ns", "p", "x"), axis.getTrx().getName());
assertEquals(3, summary.getLevel());
assertEquals(0, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ELEMENT, summary.getPathKind());
assertEquals(4L, summary.getNodeKey());
assertEquals(7L, summary.getLeftSiblingKey());
assertEquals(3L, summary.getRightSiblingKey());
assertEquals(5L, summary.getFirstChildKey());
assertEquals(new QNm("b"), axis.getTrx().getName());
assertEquals(2, summary.getLevel());
assertEquals(1, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ELEMENT, summary.getPathKind());
assertEquals(5L, summary.getNodeKey());
assertEquals(-1L, summary.getLeftSiblingKey());
assertEquals(-1L, summary.getRightSiblingKey());
assertEquals(-1L, summary.getFirstChildKey());
assertEquals(new QNm("c"), axis.getTrx().getName());
assertEquals(3, summary.getLevel());
assertEquals(0, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.ATTRIBUTE, summary.getPathKind());
assertEquals(3L, summary.getNodeKey());
assertEquals(4L, summary.getLeftSiblingKey());
assertEquals(2L, summary.getRightSiblingKey());
assertEquals(-1L, summary.getFirstChildKey());
assertEquals(new QNm("i"), axis.getTrx().getName());
assertEquals(2, summary.getLevel());
assertEquals(0, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary != null);
assertEquals(Kind.NAMESPACE, summary.getPathKind());
assertEquals(2L, summary.getNodeKey());
assertEquals(3L, summary.getLeftSiblingKey());
assertEquals(-1L, summary.getRightSiblingKey());
assertEquals(-1L, summary.getFirstChildKey());
assertEquals(new QNm("ns", "p", ""), axis.getTrx().getName());
assertEquals(2, summary.getLevel());
assertEquals(0, summary.getChildCount());
assertEquals(1, summary.getReferences());
summary = next(axis);
assertTrue(summary == null);
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testSeriellNew.
/**
* Test seriell.
*/
// @Bench
@Test
public void testSeriellNew() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final Axis axis = new NestedAxis(new NestedAxis(new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "regions")), new FilterAxis(new ChildAxis(holder.getReader()), new NameFilter(holder.getReader(), "africa"))), new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "location")));
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(false, axis.hasNext());
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testPartConcurrentDescAxis1.
/**
* Test concurrent.
*
* @throws SirixXPathException
*/
// @Bench
@Test
public void testPartConcurrentDescAxis1() throws Exception {
/* query: //regions/africa//location */
final int resultNumber = 55;
final XdmNodeReadTrx firstConcurrRtx = holder.getResourceManager().beginNodeReadTrx();
final Axis axis = new NestedAxis(new NestedAxis(new ConcurrentAxis(firstConcurrRtx, new FilterAxis(new DescendantAxis(holder.getReader(), IncludeSelf.YES), new NameFilter(holder.getReader(), "regions"))), new FilterAxis(new ChildAxis(firstConcurrRtx), new NameFilter(firstConcurrRtx, "africa"))), new FilterAxis(new DescendantAxis(firstConcurrRtx, IncludeSelf.YES), new NameFilter(firstConcurrRtx, "location")));
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(false, axis.hasNext());
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class FilterAxisTest method testValueAxisTest.
@Test
public void testValueAxisTest() throws SirixException {
final XdmNodeReadTrx rtx = holder.getReader();
rtx.moveToDocumentRoot();
AbsAxisTest.testIAxisConventions(new FilterAxis(new DescendantAxis(rtx), new ValueFilter(rtx, "foo")), new long[] { 6L });
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class FilterAxisTest method testNameAxisTest.
@Test
public void testNameAxisTest() throws SirixException {
final XdmNodeReadTrx rtx = holder.getReader();
rtx.moveToDocumentRoot();
AbsAxisTest.testIAxisConventions(new FilterAxis(new DescendantAxis(rtx), new NameFilter(rtx, "b")), new long[] { 5L, 9L });
}
Aggregations