if (query.startsWith("?")) {
uriQuery.putAll(initUriQuery(query));
}
else if (query.startsWith("{")) {
// TODO: add early, basic JSON validation
bodyQuery = new BytesArray(query);
}
else {
try {
// must be a resource
InputStream in = settings.loadResource(query);
// peek the stream
int first = in.read();
if (Integer.valueOf('?').equals(first)) {
uriQuery.putAll(initUriQuery(IOUtils.asString(in)));
}
else {
bodyQuery = new BytesArray(1024);
bodyQuery.add(first);
IOUtils.asBytes(bodyQuery, in);
}
} catch (IOException ex) {
throw new EsHadoopIllegalArgumentException(String.format("Cannot determine specified query - doesn't appear to be URI or JSON based and location [%s] cannot be opened", query));