use of io.crate.metadata.ReferenceImplementation in project crate by crate.
the class SysNodesExpressionsTest method testName.
@Test
public void testName() throws Exception {
Reference refInfo = refInfo("sys.nodes.name", DataTypes.STRING, RowGranularity.NODE);
@SuppressWarnings("unchecked") ReferenceImplementation<BytesRef> name = (ReferenceImplementation<BytesRef>) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
assertEquals(new BytesRef("node 1"), name.value());
}
use of io.crate.metadata.ReferenceImplementation in project crate by crate.
the class SysObjectArrayReference method value.
@Override
public Object[] value() {
List<NestedObjectExpression> childImplementations = getChildImplementations();
Object[] values = new Object[childImplementations.size()];
int i = 0;
for (NestedObjectExpression expression : childImplementations) {
Map<String, Object> map = Maps.transformValues(expression.getChildImplementations(), new Function<ReferenceImplementation, Object>() {
@Nullable
@Override
public Object apply(@Nullable ReferenceImplementation input) {
Object value = input.value();
if (value != null && value instanceof BytesRef) {
return ((BytesRef) value).utf8ToString();
} else {
return value;
}
}
});
values[i++] = map;
}
return values;
}
use of io.crate.metadata.ReferenceImplementation in project crate by crate.
the class NodeSysReferenceResolver method getCachedImplementation.
private ReferenceImplementation getCachedImplementation(String name) {
ReferenceImplementation impl = expressionCache.get(name);
if (impl == null) {
impl = nodeSysExpression.getChildImplementation(name);
expressionCache.put(name, impl);
}
return impl;
}
Aggregations