use of org.sirix.exception.SirixRuntimeException in project sirix by sirixdb.
the class CASIndexBuilder method process.
private VisitResult process(final ImmutableNode node) {
try {
if (node.getKind() == Kind.TEXT) {
mRtx.moveTo(node.getParentKey());
}
final long PCR = mRtx.isDocumentRoot() ? 0 : mRtx.getNameNode().getPathNodeKey();
if (mPaths.isEmpty() || mPathSummaryReader.getPCRsForPaths(mPaths).contains(PCR)) {
final Str strValue = new Str(((ImmutableValueNode) node).getValue());
boolean isOfType = false;
try {
if (mType != Type.STR)
AtomicUtil.toType(strValue, mType);
isOfType = true;
} catch (final SirixRuntimeException e) {
}
if (isOfType) {
final CASValue value = new CASValue(strValue, mType, PCR);
final Optional<NodeReferences> textReferences = mAVLTreeWriter.get(value, SearchMode.EQUAL);
if (textReferences.isPresent()) {
setNodeReferences(node, textReferences.get(), value);
} else {
setNodeReferences(node, new NodeReferences(), value);
}
}
}
mRtx.moveTo(node.getNodeKey());
} catch (final PathException | SirixIOException e) {
LOGGER.error(e.getMessage(), e);
}
return VisitResultType.CONTINUE;
}
use of org.sirix.exception.SirixRuntimeException in project sirix by sirixdb.
the class CASIndexListener method insert.
private void insert(final ValueNode node, final long pathNodeKey) throws SirixIOException {
final Str strValue = new Str(node.getValue());
boolean isOfType = false;
try {
AtomicUtil.toType(strValue, mType);
isOfType = true;
} catch (final SirixRuntimeException e) {
}
if (isOfType) {
final CASValue indexValue = new CASValue(strValue, mType, pathNodeKey);
final Optional<NodeReferences> textReferences = mAVLTreeWriter.get(indexValue, SearchMode.EQUAL);
if (textReferences.isPresent()) {
setNodeReferences(node, textReferences.get(), indexValue);
} else {
setNodeReferences(node, new NodeReferences(), indexValue);
}
}
}
use of org.sirix.exception.SirixRuntimeException in project sirix by sirixdb.
the class DBStore method create.
@Override
public TemporalCollection<?> create(final String name) throws DocumentException {
final DatabaseConfiguration dbConf = new DatabaseConfiguration(mLocation.resolve(name));
try {
if (Databases.createDatabase(dbConf)) {
throw new DocumentException("Document with name %s exists!", name);
}
final Database database = Databases.openDatabase(dbConf.getFile());
mDatabases.add(database);
final DBCollection collection = new DBCollection(name, database);
mCollections.put(database, collection);
return collection;
} catch (final SirixRuntimeException e) {
throw new DocumentException(e.getCause());
}
}
use of org.sirix.exception.SirixRuntimeException in project sirix by sirixdb.
the class DBStore method lookup.
@Override
public TemporalCollection<?> lookup(final String name) throws DocumentException {
final DatabaseConfiguration dbConf = new DatabaseConfiguration(mLocation.resolve(name));
if (Databases.existsDatabase(dbConf)) {
try {
final Database database = Databases.openDatabase(dbConf.getFile());
final Optional<Database> storedCollection = mDatabases.stream().findFirst().filter((Database db) -> db.equals(database));
if (storedCollection.isPresent()) {
return mCollections.get(storedCollection.get());
}
mDatabases.add(database);
final DBCollection collection = new DBCollection(name, database);
mCollections.put(database, collection);
return collection;
} catch (final SirixRuntimeException e) {
throw new DocumentException(e.getCause());
}
}
return null;
}
use of org.sirix.exception.SirixRuntimeException in project sirix by sirixdb.
the class IndexController method serialize.
/**
* Serialize to an {@link OutputStream}.
*
* @param out the {@link OutputStream} to serialize to
* @throws SirixRuntimeException if an exception occurs during serialization
*/
public void serialize(final OutputStream out) {
try {
final SubtreePrinter serializer = new SubtreePrinter(new PrintStream(checkNotNull(out)));
serializer.print(mIndexes.materialize());
serializer.end();
} catch (final DocumentException e) {
throw new SirixRuntimeException(e);
}
}
Aggregations