use of org.sirix.node.interfaces.ValueNode in project sirix by sirixdb.
the class CASIndexListener method listen.
@Override
public void listen(final ChangeType type, final ImmutableNode node, final long pathNodeKey) throws SirixIOException {
if (node instanceof ValueNode) {
final ValueNode valueNode = ((ValueNode) node);
mPathSummaryReader.moveTo(pathNodeKey);
try {
switch(type) {
case INSERT:
if (mPathSummaryReader.getPCRsForPaths(mPaths).contains(pathNodeKey)) {
insert(valueNode, pathNodeKey);
}
break;
case DELETE:
if (mPathSummaryReader.getPCRsForPaths(mPaths).contains(pathNodeKey)) {
mAVLTreeWriter.remove(new CASValue(new Str(valueNode.getValue()), mType, pathNodeKey), node.getNodeKey());
}
break;
default:
}
} catch (final PathException e) {
throw new SirixIOException(e);
}
}
}
use of org.sirix.node.interfaces.ValueNode in project sirix by sirixdb.
the class XPathParser method parsePITest.
/**
* Parses the the rule PITest according to the following production rule:
* <p>
* [58] PITest ::= <"processing-instruction" "("> (NCName | StringLiteral)? ")" .
* </p>
*
* @return filter
*/
private Filter parsePITest() {
consume("processing-instruction", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new PIFilter(getTransaction());
if (!is(TokenType.CLOSE_BR, true)) {
String stringLiteral;
if (isQuote()) {
final byte[] param = ((ValueNode) getTransaction().getItemList().getItem(parseStringLiteral()).get()).getRawValue();
stringLiteral = Arrays.toString(param);
} else {
stringLiteral = parseNCName();
}
consume(TokenType.CLOSE_BR, true);
filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), stringLiteral));
}
return filter;
}
use of org.sirix.node.interfaces.ValueNode in project sirix by sirixdb.
the class XdmNodeWriterTrxImpl method adaptSubtreeForMove.
/**
* Adapt subtree regarding the index-structures.
*
* @param toMove node which is moved (either before the move, or after the move)
* @param type the type of change (either deleted from the old position or inserted into the new
* position)
* @throws SirixIOException if an I/O exception occurs
*/
private void adaptSubtreeForMove(final Node node, final ChangeType type) throws SirixIOException {
assert type != null;
final long beforeNodeKey = getNode().getNodeKey();
moveTo(node.getNodeKey());
final Axis axis = new DescendantAxis(this, IncludeSelf.YES);
while (axis.hasNext()) {
axis.next();
for (int i = 0, attCount = getAttributeCount(); i < attCount; i++) {
moveToAttribute(i);
final ImmutableAttribute att = (ImmutableAttribute) getNode();
mIndexController.notifyChange(type, att, att.getPathNodeKey());
moveToParent();
}
for (int i = 0, nspCount = getNamespaceCount(); i < nspCount; i++) {
moveToAttribute(i);
final ImmutableNamespace nsp = (ImmutableNamespace) getNode();
mIndexController.notifyChange(type, nsp, nsp.getPathNodeKey());
moveToParent();
}
long pathNodeKey = -1;
if (getNode() instanceof ValueNode && getNode().getParentKey() != Fixed.DOCUMENT_NODE_KEY.getStandardProperty()) {
final long nodeKey = getNode().getNodeKey();
pathNodeKey = moveToParent().get().getNameNode().getPathNodeKey();
moveTo(nodeKey);
} else if (getNode() instanceof NameNode) {
pathNodeKey = getNameNode().getPathNodeKey();
}
mIndexController.notifyChange(type, getNode(), pathNodeKey);
}
moveTo(beforeNodeKey);
}
use of org.sirix.node.interfaces.ValueNode in project sirix by sirixdb.
the class XdmNodeWriterTrxImpl method setValue.
@Override
public XdmNodeWriteTrx setValue(final String value) throws SirixException {
checkNotNull(value);
acquireLock();
try {
if (getCurrentNode() instanceof ValueNode) {
checkAccessAndCommit();
// XDM).
if (value.isEmpty()) {
remove();
return this;
}
// Remove old value from indexes.
mIndexController.notifyChange(ChangeType.DELETE, getNode(), getPathNodeKey());
final long oldHash = mNodeReader.getCurrentNode().hashCode();
final byte[] byteVal = getBytes(value);
final ValueNode node = (ValueNode) getPageTransaction().prepareEntryForModification(mNodeReader.getCurrentNode().getNodeKey(), PageKind.RECORDPAGE, -1, Optional.<UnorderedKeyValuePage>empty());
node.setValue(byteVal);
mNodeReader.setCurrentNode(node);
adaptHashedWithUpdate(oldHash);
// Index new value.
mIndexController.notifyChange(ChangeType.INSERT, getNode(), getPathNodeKey());
return this;
} else {
throw new SirixUsageException("setValue(String) is not allowed if current node is not an IValNode implementation!");
}
} finally {
unLock();
}
}
Aggregations