use of org.apache.rya.accumulo.mr.merge.util.CopyRule in project incubator-rya by apache.
the class BaseRuleMapper method setup.
@Override
protected void setup(final Context context) throws IOException, InterruptedException {
final Configuration conf = context.getConfiguration();
split = (RangeInputSplit) context.getInputSplit();
final Range range = split.getRange();
// Determine the table and table layout we're scanning
parentTableName = split.getTableName();
parentTablePrefix = conf.get(MRUtils.TABLE_PREFIX_PROPERTY);
for (final TABLE_LAYOUT layout : TABLE_LAYOUT.values()) {
final String tableName = RdfCloudTripleStoreUtils.layoutPrefixToTable(layout, parentTablePrefix);
if (tableName.equals(parentTableName)) {
parentLayout = layout;
}
}
conf.set(MergeTool.TABLE_NAME_PROP, parentTableName);
// Set up connections and parent/child table information, if necessary
super.setup(context);
// If we're working at the statement level, get the relevant rules and conditions:
if (parentLayout != null) {
AccumuloQueryRuleset ruleset;
try {
ruleset = new AccumuloQueryRuleset(new AccumuloRdfConfiguration(conf));
} catch (final QueryRulesetException e) {
throw new IOException("Error parsing the input query", e);
}
final List<CopyRule> rules = ruleset.getRules(parentLayout, range);
for (final CopyRule rule : rules) {
log.info("Mapper applies to rule:");
for (final String line : rule.toString().split("\n")) {
log.info("\t" + line);
}
}
// this input split will receive, so if any condition is true we'll want to copy the statement.
for (final CopyRule rule : rules) {
// (even if there are redundant rules with conditions)
if (rule.getCondition() == null) {
condition = null;
break;
} else // If there is a set of conditions, matching it means we should accept the statement.
if (condition == null) {
condition = rule.getCondition();
} else // If there are more than one rules that match, satisfying any conditions means we should accept.
{
condition = new Or(condition, rule.getCondition());
}
}
// Set up the strategy to evaluate those conditions
strategy = new ParallelEvaluationStrategyImpl(null, null, null, childAccumuloRdfConfiguration);
// Log info about the split and combined condition
log.info("Table: " + parentTableName);
log.info("Range:");
log.info("\tfrom " + keyToString(range.getStartKey(), Integer.MAX_VALUE));
log.info("\tto " + keyToString(range.getEndKey(), Integer.MAX_VALUE));
if (condition == null) {
log.info("Condition: none");
} else {
log.info("Condition:");
for (final String line : condition.toString().split("\n")) {
log.info("\t" + line);
}
}
} else {
log.info("(Copying all rows from " + parentTableName + " directly.)");
}
}
Aggregations