use of org.teiid.query.function.JSONFunctionMethods.JSONBuilder in project teiid by teiid.
the class Evaluator method evaluateJSONObject.
private Object evaluateJSONObject(List<?> tuple, JSONObject function, JSONBuilder builder) throws ExpressionEvaluationException, BlockedException, TeiidComponentException, FunctionExecutionException {
List<DerivedColumn> args = function.getArgs();
Evaluator.NameValuePair<Object>[] nameValuePairs = getNameValuePairs(tuple, args, false, false);
boolean returnValue = false;
try {
if (builder == null) {
returnValue = true;
// preevaluate subqueries to prevent blocked exceptions
for (SubqueryContainer<?> container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(function)) {
evaluateSubquery(container, tuple);
}
builder = new JSONBuilder(context.getBufferManager());
}
builder.start(false);
for (NameValuePair<Object> nameValuePair : nameValuePairs) {
addValue(tuple, builder, nameValuePair.name, nameValuePair.value);
}
builder.end(false);
if (returnValue) {
ClobType result = builder.close(context);
builder = null;
return result;
}
return null;
} catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e);
} finally {
if (returnValue && builder != null) {
builder.remove();
}
}
}
use of org.teiid.query.function.JSONFunctionMethods.JSONBuilder in project teiid by teiid.
the class JSONArrayAgg method addInputDirect.
/**
* @throws TeiidProcessingException
* @throws TeiidComponentException
* @see org.teiid.query.function.aggregate.AggregateFunction#addInputDirect(List, CommandContext, CommandContext)
*/
public void addInputDirect(Object input, List<?> tuple, CommandContext commandContext) throws TeiidComponentException, TeiidProcessingException {
if (concat == null) {
concat = new JSONBuilder(commandContext.getBufferManager());
concat.start(true);
}
concat.addValue(input);
}
use of org.teiid.query.function.JSONFunctionMethods.JSONBuilder in project teiid by teiid.
the class Evaluator method jsonArray.
public static ClobType jsonArray(CommandContext context, Function f, Object[] vals, JSONBuilder builder, Evaluator eval, List<?> tuple) throws TeiidProcessingException, BlockedException, TeiidComponentException {
boolean returnValue = false;
try {
if (builder == null) {
returnValue = true;
if (eval != null) {
// preevaluate subqueries to prevent blocked exceptions
for (SubqueryContainer<?> container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(f)) {
eval.evaluateSubquery(container, tuple);
}
}
builder = new JSONBuilder(context.getBufferManager());
}
builder.start(true);
for (Object object : vals) {
if (eval != null) {
eval.addValue(tuple, builder, null, object);
} else {
builder.addValue(object);
}
}
builder.end(true);
if (returnValue) {
ClobType result = builder.close(context);
builder = null;
return result;
}
return null;
} finally {
if (returnValue && builder != null) {
builder.remove();
}
}
}
Aggregations