Search in sources :

Example 6 with SirixIOException

use of org.sirix.exception.SirixIOException in project sirix by sirixdb.

the class BerkeleyWriter method close.

@Override
public void close() throws SirixIOException {
    try {
        setLastNodePage(mNodepagekey);
        mTxn.commit();
    } catch (final DatabaseException exc) {
        throw new SirixIOException(exc);
    }
}
Also used : DatabaseException(com.sleepycat.je.DatabaseException) SirixIOException(org.sirix.exception.SirixIOException)

Example 7 with SirixIOException

use of org.sirix.exception.SirixIOException in project sirix by sirixdb.

the class BerkeleyWriter method getLastNodePage.

/**
 * Getting the last nodePage from the persistent storage.
 *
 * @throws SirixIOException If can't get last Node page
 * @return the last nodepage-key
 */
private long getLastNodePage() throws SirixIOException {
    final DatabaseEntry keyEntry = new DatabaseEntry();
    final DatabaseEntry valueEntry = new DatabaseEntry();
    TupleBinding.getPrimitiveBinding(Long.class).objectToEntry(-2l, keyEntry);
    try {
        final OperationStatus status = mDatabase.get(mTxn, keyEntry, valueEntry, LockMode.DEFAULT);
        return status == OperationStatus.SUCCESS ? BerkeleyStorage.DATAINFO_VAL_B.entryToObject(valueEntry) : 0L;
    } catch (final DatabaseException exc) {
        throw new SirixIOException(exc);
    }
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseException(com.sleepycat.je.DatabaseException) SirixIOException(org.sirix.exception.SirixIOException)

Example 8 with SirixIOException

use of org.sirix.exception.SirixIOException in project sirix by sirixdb.

the class BerkeleyWriter method write.

@Override
public Writer write(final PageReference pageReference) throws SirixIOException {
    final Page page = pageReference.getPage();
    final DatabaseEntry valueEntry = new DatabaseEntry();
    final DatabaseEntry keyEntry = new DatabaseEntry();
    mNodepagekey++;
    mPageBinding.objectToEntry(page, valueEntry);
    TupleBinding.getPrimitiveBinding(Long.class).objectToEntry(mNodepagekey, keyEntry);
    final OperationStatus status = mDatabase.put(mTxn, keyEntry, valueEntry);
    if (status != OperationStatus.SUCCESS) {
        throw new SirixIOException(new StringBuilder("Write of ").append(pageReference.toString()).append(" failed!").toString());
    }
    pageReference.setKey(mNodepagekey);
    return this;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) Page(org.sirix.page.interfaces.Page) DatabaseEntry(com.sleepycat.je.DatabaseEntry) SirixIOException(org.sirix.exception.SirixIOException)

Example 9 with SirixIOException

use of org.sirix.exception.SirixIOException in project sirix by sirixdb.

the class FileReader method read.

@Override
public Page read(@Nonnull final PageReference reference, @Nullable final PageReadTrx pageReadTrx) throws SirixIOException {
    try {
        // Read page from file.
        switch(mType) {
            case DATA:
                mFile.seek(reference.getKey());
                break;
            case TRANSACTION_INTENT_LOG:
                mFile.seek(reference.getPersistentLogKey());
                break;
        }
        final int dataLength = mFile.readInt();
        reference.setLength(dataLength + FileReader.OTHER_BEACON);
        final byte[] page = new byte[dataLength];
        mFile.read(page);
        // Perform byte operations.
        final DataInputStream input = new DataInputStream(mByteHandler.deserialize(new ByteArrayInputStream(page)));
        // Return reader required to instantiate and deserialize page.
        return PagePersistenter.deserializePage(input, pageReadTrx, mType);
    } catch (final IOException e) {
        throw new SirixIOException(e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) SirixIOException(org.sirix.exception.SirixIOException) DataInputStream(java.io.DataInputStream) SirixIOException(org.sirix.exception.SirixIOException)

Example 10 with SirixIOException

use of org.sirix.exception.SirixIOException in project sirix by sirixdb.

the class FileReader method readUberPageReference.

@Override
public PageReference readUberPageReference() throws SirixIOException {
    final PageReference uberPageReference = new PageReference();
    try {
        // Read primary beacon.
        mFile.seek(0);
        uberPageReference.setKey(mFile.readLong());
        final UberPage page = (UberPage) read(uberPageReference, null);
        uberPageReference.setPage(page);
        return uberPageReference;
    } catch (final IOException e) {
        throw new SirixIOException(e);
    }
}
Also used : PageReference(org.sirix.page.PageReference) UberPage(org.sirix.page.UberPage) IOException(java.io.IOException) SirixIOException(org.sirix.exception.SirixIOException) SirixIOException(org.sirix.exception.SirixIOException)

Aggregations

SirixIOException (org.sirix.exception.SirixIOException)42 IOException (java.io.IOException)14 DatabaseException (com.sleepycat.je.DatabaseException)9 DatabaseEntry (com.sleepycat.je.DatabaseEntry)7 UberPage (org.sirix.page.UberPage)6 OperationStatus (com.sleepycat.je.OperationStatus)5 Path (java.nio.file.Path)5 QNm (org.brackit.xquery.atomic.QNm)5 PageReference (org.sirix.page.PageReference)5 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)5 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)4 ExecutionException (java.util.concurrent.ExecutionException)4 Str (org.brackit.xquery.atomic.Str)4 Page (org.sirix.page.interfaces.Page)4 UncheckedIOException (java.io.UncheckedIOException)3 HashSet (java.util.HashSet)3 QueryException (org.brackit.xquery.QueryException)3 Item (org.brackit.xquery.xdm.Item)3 Iter (org.brackit.xquery.xdm.Iter)3 IndexController (org.sirix.access.IndexController)3