use of org.apache.asterix.external.classad.ExprTree in project asterixdb by apache.
the class ClassAdParser method parseOrderedList.
private void parseOrderedList(AOrderedListType oltype, Value listVal, DataOutput out) throws IOException, AsterixException {
ArrayBackedValueStorage itemBuffer = getTempBuffer();
OrderedListBuilder orderedListBuilder = (OrderedListBuilder) getOrderedListBuilder();
IAType itemType = null;
if (oltype != null) {
itemType = oltype.getItemType();
}
orderedListBuilder.reset(oltype);
for (ExprTree tree : listVal.getListVal().getExprList()) {
itemBuffer.reset();
writeFieldValueToBuffer(itemType, itemBuffer.getDataOutput(), null, tree, null);
orderedListBuilder.addItem(itemBuffer);
}
orderedListBuilder.write(out, true);
}
use of org.apache.asterix.external.classad.ExprTree in project asterixdb by apache.
the class ClassAdToADMTest method testSchemaless.
/**
*
*/
public void testSchemaless() {
try {
ClassAdObjectPool objectPool = new ClassAdObjectPool();
ClassAd pAd = new ClassAd(objectPool);
String[] files = new String[] { "/classad/jobads.txt" };
ClassAdParser parser = new ClassAdParser(objectPool);
CharArrayLexerSource lexerSource = new CharArrayLexerSource();
for (String path : files) {
List<Path> paths = new ArrayList<>();
Map<String, String> config = new HashMap<>();
config.put(ExternalDataConstants.KEY_RECORD_START, "[");
config.put(ExternalDataConstants.KEY_RECORD_END, "]");
paths.add(Paths.get(getClass().getResource(path).toURI()));
FileSystemWatcher watcher = new FileSystemWatcher(paths, null, false);
LocalFSInputStream in = new LocalFSInputStream(watcher);
SemiStructuredRecordReader recordReader = new SemiStructuredRecordReader();
recordReader.configure(in, config);
try {
Value val = new Value(objectPool);
while (recordReader.hasNext()) {
val.reset();
IRawRecord<char[]> record = recordReader.next();
lexerSource.setNewSource(record.get());
parser.setLexerSource(lexerSource);
parser.parseNext(pAd);
Map<CaseInsensitiveString, ExprTree> attrs = pAd.getAttrList();
for (Entry<CaseInsensitiveString, ExprTree> entry : attrs.entrySet()) {
ExprTree tree = entry.getValue();
switch(tree.getKind()) {
case ATTRREF_NODE:
case CLASSAD_NODE:
case EXPR_ENVELOPE:
case EXPR_LIST_NODE:
case FN_CALL_NODE:
case OP_NODE:
break;
case LITERAL_NODE:
break;
default:
System.out.println("Something is wrong");
break;
}
}
}
} finally {
recordReader.close();
}
}
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
}
Aggregations