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;
}
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;
}
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());
}
}
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);
}
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;
}
Aggregations