Search in sources :

Example 36 with SirixIOException

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

the class XMarkBenchQueries method getResult.

/**
 * Return the result by query number and factor
 *
 * @param queryNr XMark query number.
 * @param factor Factor of XML size.
 * @return result Query by number and factor.
 */
public String getResult(final int queryNr, final String factor) {
    final StringBuilder sb = new StringBuilder();
    sb.append("R");
    sb.append(Integer.toString(queryNr));
    sb.append("_Fac");
    String fac = null;
    if (factor.equals("0.01")) {
        fac = "001";
    } else if (factor.equals("0.1")) {
        fac = "01";
    } else if (factor.equals("1.0")) {
        fac = "1";
    } else if (factor.equals("10.0")) {
        fac = "10";
    } else {
        try {
            throw new SirixIOException("XMark Benchmarking result factor does not exist!");
        } catch (final SirixIOException mExp) {
            mExp.printStackTrace();
        }
    }
    sb.append(fac);
    String resultValue = null;
    try {
        final Field privateStringField = XMarkBenchQueries.class.getDeclaredField(sb.toString());
        privateStringField.setAccessible(true);
        resultValue = (String) privateStringField.get(this);
    } catch (final Exception mExp) {
        mExp.printStackTrace();
    }
    return resultValue;
}
Also used : Field(java.lang.reflect.Field) SirixIOException(org.sirix.exception.SirixIOException) SirixIOException(org.sirix.exception.SirixIOException)

Example 37 with SirixIOException

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

the class SortWiki method run.

@Override
public int run(final String[] args) throws IOException, ClassNotFoundException, InterruptedException {
    final Job job = new Job(getConf());
    job.setJarByClass(this.getClass());
    job.setJobName(this.getClass().getName());
    // Map output.
    job.setMapOutputKeyClass(DateWritable.class);
    job.setMapOutputValueClass(Text.class);
    // Reduce output.
    job.setOutputKeyClass(DateWritable.class);
    job.setOutputValueClass(Text.class);
    job.setMapperClass(XMLMap.class);
    job.setReducerClass(XMLReduce.class);
    job.setInputFormatClass(XMLInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);
    final Configuration config = job.getConfiguration();
    config.set("timestamp", "timestamp");
    config.set("page", "page");
    config.set("record_element_name", "revision");
    config.set("namespace_prefix", "");
    config.set("namespace_URI", "http://www.mediawiki.org/xml/export-0.4/");
    config.set("root", "mediawiki");
    // Debug settings.
    config.set("mapred.job.tracker", "local");
    config.set("fs.default.name", "local");
    // First delete target directory.
    try {
        Files.recursiveRemove(new File(args[1]).toPath());
    } catch (final SirixIOException e) {
        LOGWRAPPER.error(e.getMessage(), e);
    }
    FileInputFormat.setInputPaths(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    final boolean success = job.waitForCompletion(true);
    return success ? 0 : 1;
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Job(org.apache.hadoop.mapreduce.Job) File(java.io.File) SirixIOException(org.sirix.exception.SirixIOException)

Example 38 with SirixIOException

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

the class PageReadTrxImpl method dereferenceIndirectPageReference.

/**
 * Dereference indirect page reference.
 *
 * @param reference reference to dereference
 * @return dereferenced page
 *
 * @throws SirixIOException if something odd happens within the creation process
 * @throws NullPointerException if {@code reference} is {@code null}
 */
@Override
public IndirectPage dereferenceIndirectPageReference(final PageReference reference) {
    try {
        IndirectPage page = null;
        if (mTrxIntentLog != null) {
            // Try to get it from the transaction log if it's present.
            final PageContainer cont = mTrxIntentLog.get(reference);
            page = cont == null ? null : (IndirectPage) cont.getComplete();
        }
        if (page == null) {
            // Then try to get the in-memory reference.
            page = (IndirectPage) reference.getPage();
        }
        if (page == null && (reference.getKey() != Constants.NULL_ID_LONG || reference.getLogKey() != Constants.NULL_ID_INT || reference.getPersistentLogKey() != Constants.NULL_ID_LONG)) {
            // Then try to get it from the page cache which might read it from the persistent storage
            // on a cache miss.
            page = (IndirectPage) mPageCache.get(reference);
        }
        return page;
    } catch (final ExecutionException | UncheckedExecutionException e) {
        throw new SirixIOException(e.getCause());
    }
}
Also used : PageContainer(org.sirix.cache.PageContainer) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) SirixIOException(org.sirix.exception.SirixIOException) IndirectPage(org.sirix.page.IndirectPage)

Example 39 with SirixIOException

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

the class PageReadTrxImpl method getRecord.

@Override
public Optional<Record> getRecord(final long nodeKey, final PageKind pageKind, @Nonnegative final int index) {
    checkNotNull(pageKind);
    assertNotClosed();
    if (nodeKey == Fixed.NULL_NODE_KEY.getStandardProperty()) {
        return Optional.empty();
    }
    final long recordPageKey = pageKey(nodeKey);
    final PageContainer cont;
    try {
        switch(pageKind) {
            case RECORDPAGE:
            case PATHSUMMARYPAGE:
            case PATHPAGE:
            case CASPAGE:
            case NAMEPAGE:
                cont = mNodeCache.get(new IndexLogKey(pageKind, recordPageKey, index));
                break;
            default:
                throw new IllegalStateException();
        }
    } catch (final ExecutionException | UncheckedExecutionException e) {
        throw new SirixIOException(e.getCause());
    }
    if (PageContainer.emptyInstance().equals(cont)) {
        return Optional.empty();
    }
    final Record retVal = ((UnorderedKeyValuePage) cont.getComplete()).getValue(nodeKey);
    return checkItemIfDeleted(retVal);
}
Also used : PageContainer(org.sirix.cache.PageContainer) IndexLogKey(org.sirix.cache.IndexLogKey) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Record(org.sirix.node.interfaces.Record) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) SirixIOException(org.sirix.exception.SirixIOException)

Example 40 with SirixIOException

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

the class PageWriteTrxImpl method prepareEntryForModification.

@Override
public Record prepareEntryForModification(@Nonnegative final Long recordKey, final PageKind pageKind, final int index, final Optional<UnorderedKeyValuePage> keyValuePage) throws SirixIOException {
    mPageRtx.assertNotClosed();
    checkNotNull(recordKey);
    checkArgument(recordKey >= 0, "recordKey must be >= 0!");
    checkNotNull(pageKind);
    checkNotNull(keyValuePage);
    final long recordPageKey = mPageRtx.pageKey(recordKey);
    final PageContainer cont = prepareRecordPage(recordPageKey, index, pageKind);
    Record record = ((UnorderedKeyValuePage) cont.getModified()).getValue(recordKey);
    if (record == null) {
        final Record oldRecord = ((UnorderedKeyValuePage) cont.getComplete()).getValue(recordKey);
        if (oldRecord == null) {
            throw new SirixIOException("Cannot retrieve record from cache!");
        }
        record = oldRecord;
        ((UnorderedKeyValuePage) cont.getModified()).setEntry(record.getNodeKey(), record);
    }
    return record;
}
Also used : PageContainer(org.sirix.cache.PageContainer) Record(org.sirix.node.interfaces.Record) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) 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