use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class FirstAxisTest method testAxis.
@Test
public void testAxis() throws SirixException {
final XdmNodeReadTrx firstRtx = holder.getResourceManager().beginNodeReadTrx(1);
new IteratorTester<XdmNodeReadTrx>(ITERATIONS, IteratorFeature.UNMODIFIABLE, ImmutableList.of(firstRtx), null) {
@Override
protected Iterator<XdmNodeReadTrx> newTargetIterator() {
return new FirstAxis(holder.getReader());
}
}.test();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class LastAxisTest method testAxis.
@Test
public void testAxis() throws SirixException {
final XdmNodeReadTrx firstRtx = holder.getResourceManager().beginNodeReadTrx(1);
final XdmNodeReadTrx thirdRtx = holder.getReader();
new IteratorTester<XdmNodeReadTrx>(ITERATIONS, IteratorFeature.UNMODIFIABLE, ImmutableList.of(thirdRtx), null) {
@Override
protected Iterator<XdmNodeReadTrx> newTargetIterator() {
return new LastAxis(firstRtx);
}
}.test();
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class XMLShredderTest method testShreddingLargeText.
@Test
public void testShreddingLargeText() throws Exception {
final Database database = TestHelper.getDatabase(PATHS.PATH2.getFile());
final ResourceManager manager = database.getResourceManager(new ResourceManagerConfiguration.Builder(TestHelper.RESOURCE).build());
final XdmNodeWriteTrx wtx = manager.beginNodeWriteTrx();
final XMLShredder shredder = new XMLShredder.Builder(wtx, XMLShredder.createFileReader(XML3), Insert.ASFIRSTCHILD).commitAfterwards().build();
shredder.call();
wtx.close();
final XdmNodeReadTrx rtx = manager.beginNodeReadTrx();
assertTrue(rtx.moveToFirstChild().hasMoved());
assertTrue(rtx.moveToFirstChild().hasMoved());
final StringBuilder tnkBuilder = new StringBuilder();
do {
tnkBuilder.append(rtx.getValue());
} while (rtx.moveToRightSibling().hasMoved());
final String tnkString = tnkBuilder.toString();
rtx.close();
manager.close();
final XMLEventReader validater = XMLShredder.createFileReader(XML3);
final StringBuilder xmlBuilder = new StringBuilder();
while (validater.hasNext()) {
final XMLEvent event = validater.nextEvent();
switch(event.getEventType()) {
case XMLStreamConstants.CHARACTERS:
final String text = event.asCharacters().getData().trim();
if (text.length() > 0) {
xmlBuilder.append(text);
}
break;
}
}
assertEquals(xmlBuilder.toString(), tnkString);
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class XdmResourceManager method close.
@Override
public synchronized void close() {
if (!mClosed) {
// Close all open node transactions.
for (XdmNodeReadTrx rtx : mNodeReaderMap.values()) {
if (rtx instanceof XdmNodeWriteTrx) {
((XdmNodeWriteTrx) rtx).rollback();
}
rtx.close();
rtx = null;
}
// Close all open node page transactions.
for (PageReadTrx rtx : mNodePageTrxMap.values()) {
rtx.close();
rtx = null;
}
// Close all open page transactions.
for (PageReadTrx rtx : mPageTrxMap.values()) {
rtx.close();
rtx = null;
}
// Immediately release all ressources.
mLastCommittedUberPage = null;
mNodeReaderMap.clear();
mPageTrxMap.clear();
mNodePageTrxMap.clear();
mResourceStore.closeResource(mResourceConfig.getResource());
mFac.close();
mClosed = true;
}
}
use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.
the class NonStructuralWrapperAxis method nextKey.
@Override
protected long nextKey() {
final XdmNodeReadTrx trx = mParentAxis.getTrx();
if (mParentAxis.isSelfIncluded() == IncludeSelf.NO || !mFirst) {
final long nodeKey = nonStructural(trx);
if (nodeKey != Fixed.NULL_NODE_KEY.getStandardProperty()) {
return nodeKey;
}
}
if (mParentAxis.hasNext()) {
long key = mParentAxis.next();
mFirst = false;
mNspIndex = 0;
mAttIndex = 0;
return key;
}
return done();
}
Aggregations