use of org.sirix.page.UnorderedKeyValuePage in project sirix by sirixdb.
the class XdmNodeWriterTrxImpl method rollback.
@Override
public XdmNodeWriteTrx rollback() {
acquireLock();
try {
mNodeReader.assertNotClosed();
// Reset modification counter.
mModificationCount = 0L;
// Close current page transaction.
final long trxID = getId();
final int revision = getRevisionNumber();
final int revNumber = getPageTransaction().getUberPage().isBootstrap() ? 0 : revision - 1;
final UberPage uberPage = getPageTransaction().rollback();
// Remember succesfully committed uber page in resource manager.
mNodeReader.mResourceManager.setLastCommittedUberPage(uberPage);
mNodeReader.getPageTransaction().clearCaches();
mNodeReader.getPageTransaction().closeCaches();
mNodeReader.mResourceManager.closeNodePageWriteTransaction(getId());
mNodeReader.setPageReadTransaction(null);
removeCommitFile();
final PageWriteTrx<Long, Record, UnorderedKeyValuePage> trx = mNodeReader.mResourceManager.createPageWriteTransaction(trxID, revNumber, revNumber, Abort.YES);
mNodeReader.setPageReadTransaction(trx);
mNodeReader.mResourceManager.setNodePageWriteTransaction(getId(), trx);
mNodeFactory = null;
mNodeFactory = new NodeFactoryImpl(trx);
reInstantiateIndexes();
return this;
} finally {
unLock();
}
}
use of org.sirix.page.UnorderedKeyValuePage in project sirix by sirixdb.
the class NodeFactoryImpl method createPathNode.
@Override
public PathNode createPathNode(@Nonnegative final long parentKey, @Nonnegative final long leftSibKey, final long rightSibKey, final long hash, @Nonnull final QNm name, @Nonnull final Kind kind, @Nonnegative final int level) throws SirixIOException {
final int uriKey = NamePageHash.generateHashForString(name.getNamespaceURI());
final int prefixKey = name.getPrefix() != null && !name.getPrefix().isEmpty() ? NamePageHash.generateHashForString(name.getPrefix()) : -1;
final int localName = name.getLocalName() != null && !name.getLocalName().isEmpty() ? NamePageHash.generateHashForString(name.getLocalName()) : -1;
final long revision = mPageWriteTrx.getRevisionNumber();
final NodeDelegate nodeDel = new NodeDelegate(((PathSummaryPage) mPageWriteTrx.getActualRevisionRootPage().getPathSummaryPageReference().getPage()).getMaxNodeKey(0) + 1, parentKey, 0, revision, Optional.<SirixDeweyID>empty());
final StructNodeDelegate structDel = new StructNodeDelegate(nodeDel, Fixed.NULL_NODE_KEY.getStandardProperty(), rightSibKey, leftSibKey, 0, 0);
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, uriKey, prefixKey, localName, 0);
return (PathNode) mPageWriteTrx.createEntry(nodeDel.getNodeKey(), new PathNode(nodeDel, structDel, nameDel, kind, 1, level), PageKind.PATHSUMMARYPAGE, 0, Optional.<UnorderedKeyValuePage>empty());
}
use of org.sirix.page.UnorderedKeyValuePage in project sirix by sirixdb.
the class NodeFactoryImpl method createNamespaceNode.
@Override
public NamespaceNode createNamespaceNode(@Nonnegative final long parentKey, final QNm name, @Nonnegative final long pathNodeKey, final Optional<SirixDeweyID> id) throws SirixIOException {
final long revision = mPageWriteTrx.getRevisionNumber();
final NodeDelegate nodeDel = new NodeDelegate(mPageWriteTrx.getActualRevisionRootPage().getMaxNodeKey() + 1, parentKey, 0, revision, id);
final int uriKey = mPageWriteTrx.createNameKey(name.getNamespaceURI(), Kind.NAMESPACE);
final int prefixKey = name.getPrefix() != null && !name.getPrefix().isEmpty() ? mPageWriteTrx.createNameKey(name.getPrefix(), Kind.NAMESPACE) : -1;
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, uriKey, prefixKey, -1, pathNodeKey);
return (NamespaceNode) mPageWriteTrx.createEntry(nodeDel.getNodeKey(), new NamespaceNode(nodeDel, nameDel, name), PageKind.RECORDPAGE, -1, Optional.<UnorderedKeyValuePage>empty());
}
use of org.sirix.page.UnorderedKeyValuePage in project sirix by sirixdb.
the class NodeFactoryImpl method createTextNode.
@Override
public TextNode createTextNode(@Nonnegative final long parentKey, @Nonnegative final long leftSibKey, @Nonnegative final long rightSibKey, @Nonnull final byte[] value, final boolean isCompressed, final Optional<SirixDeweyID> id) throws SirixIOException {
final long revision = mPageWriteTrx.getRevisionNumber();
final NodeDelegate nodeDel = new NodeDelegate(mPageWriteTrx.getActualRevisionRootPage().getMaxNodeKey() + 1, parentKey, 0, revision, id);
final boolean compression = isCompressed && value.length > 10;
final byte[] compressedValue = compression ? Compression.compress(value, Deflater.HUFFMAN_ONLY) : value;
final ValNodeDelegate valDel = new ValNodeDelegate(nodeDel, compressedValue, compression);
final StructNodeDelegate structDel = new StructNodeDelegate(nodeDel, Fixed.NULL_NODE_KEY.getStandardProperty(), rightSibKey, leftSibKey, 0, 0);
return (TextNode) mPageWriteTrx.createEntry(nodeDel.getNodeKey(), new TextNode(valDel, structDel), PageKind.RECORDPAGE, -1, Optional.<UnorderedKeyValuePage>empty());
}
use of org.sirix.page.UnorderedKeyValuePage in project sirix by sirixdb.
the class NodeFactoryImpl method createPINode.
@Override
public PINode createPINode(@Nonnegative final long parentKey, @Nonnegative final long leftSibKey, @Nonnegative final long rightSibKey, final QNm target, final byte[] content, final boolean isCompressed, @Nonnegative final long pathNodeKey, final Optional<SirixDeweyID> id) throws SirixIOException {
final long revision = mPageWriteTrx.getRevisionNumber();
final int prefixKey = target.getPrefix() != null && !target.getPrefix().isEmpty() ? mPageWriteTrx.createNameKey(target.getPrefix(), Kind.PROCESSING_INSTRUCTION) : -1;
final int localNameKey = mPageWriteTrx.createNameKey(target.getLocalName(), Kind.PROCESSING_INSTRUCTION);
final int uriKey = mPageWriteTrx.createNameKey(target.getNamespaceURI(), Kind.NAMESPACE);
final NodeDelegate nodeDel = new NodeDelegate(mPageWriteTrx.getActualRevisionRootPage().getMaxNodeKey() + 1, parentKey, 0, revision, id);
final StructNodeDelegate structDel = new StructNodeDelegate(nodeDel, Fixed.NULL_NODE_KEY.getStandardProperty(), rightSibKey, leftSibKey, 0, 0);
final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, uriKey, prefixKey, localNameKey, pathNodeKey);
final ValNodeDelegate valDel = new ValNodeDelegate(nodeDel, content, false);
return (PINode) mPageWriteTrx.createEntry(nodeDel.getNodeKey(), new PINode(structDel, nameDel, valDel, mPageWriteTrx), PageKind.RECORDPAGE, -1, Optional.<UnorderedKeyValuePage>empty());
}
Aggregations