System.err.println("ZorbaMapper: Received Key: " + key.toString() + " Received Value: " + value.toString());
//log.info("Received Key: " + key.toString() + " Received Value: " + value.toString());
Item i = xData.parseDocument(value.toString());
// bind key
xquery.setVariableAsDocument(XadoopUtil.XADOOP_KEY, "key.xml", "<key>"+key.toString()+"</key>");
// bind value
xquery.setVariableAsDocument(XadoopUtil.XADOOP_VALUE, "value.xml", "<frame>"+value.toString()+"</frame>");
System.err.println("ZorbaMapper: binding value: " + value);
//log.info("binding value: " + value.toString());
// execute query and get iterator
Iterator iter = xquery.iterator();
iter.open();
//loop over all items.
Item item = new Item();
Text keyData = new Text();
keyData.set("zero");
Text valueData = new Text();
while (iter.next(item)) {
String itemStr = item.serialize();
itemStr = itemStr.substring(39,itemStr.length());
if (itemStr.startsWith("<key>")) {
keyData.set(itemStr);
} else {
valueData.set(itemStr);
// TODO could be debug
System.err.println("ZorbaMapper: Emmitting:" + keyData.toString() + "," + valueData.toString());
//log.info("Emmitting:" + keyData.toString() + "," + valueData.toString());
try {
// Context not null
if (context != null) {
// this collects the key value pairs - hopefully
context.write(keyData, valueData);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// clean up
iter.close();
iter.destroy();
iter.delete();
item.delete();
xquery.destroy();
xquery.delete();
zorba.shutdown();
InMemoryStore.shutdown(store);