use of io.crate.metadata.Reference in project crate by crate.
the class LuceneReferenceResolverTest method testGetImplementationWithColumnsOfTypeCollection.
@Test
public void testGetImplementationWithColumnsOfTypeCollection() {
Reference arrayRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, DataTypes.DOUBLE_ARRAY);
assertThat(luceneReferenceResolver.getImplementation(arrayRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
Reference setRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, new SetType(DataTypes.DOUBLE));
assertThat(luceneReferenceResolver.getImplementation(setRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsTest method testVersion.
@Test
public void testVersion() throws Exception {
Reference refInfo = refInfo("sys.nodes.version", DataTypes.OBJECT, RowGranularity.NODE);
io.crate.operation.reference.NestedObjectExpression version = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
Map<String, Object> v = version.value();
assertEquals(Version.CURRENT.number(), v.get("number"));
assertEquals(Build.CURRENT.hash(), v.get("build_hash"));
assertEquals(Version.CURRENT.snapshot, v.get("build_snapshot"));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsTest method testProcess.
@Test
public void testProcess() throws Exception {
Reference refInfo = refInfo("sys.nodes.process", DataTypes.OBJECT, RowGranularity.NODE);
io.crate.operation.reference.NestedObjectExpression processRef = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
Map<String, Object> v = processRef.value();
assertEquals(42L, (long) v.get("open_file_descriptors"));
assertEquals(1000L, (long) v.get("max_open_file_descriptors"));
Map<String, Object> cpuObj = new HashMap<>(4);
cpuObj.put("percent", (short) 50);
cpuObj.put("system", 1000L);
cpuObj.put("user", 500L);
assertEquals(cpuObj, v.get("cpu"));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsTest method testCpu.
@Test
public void testCpu() throws Exception {
Reference refInfo = refInfo("sys.nodes.os", DataTypes.OBJECT, RowGranularity.NODE);
io.crate.operation.reference.NestedObjectExpression os = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
Map<String, Object> v = os.value();
assertEquals(3600000L, v.get("uptime"));
Map<String, Short> cpuObj = new HashMap<>(5);
cpuObj.put("system", (short) 0);
cpuObj.put("user", (short) 4);
cpuObj.put("idle", (short) 94);
cpuObj.put("used", (short) 4);
cpuObj.put("stolen", (short) 10);
assertEquals(cpuObj, v.get("cpu"));
}
use of io.crate.metadata.Reference in project crate by crate.
the class SysNodesExpressionsTest method testNetworkTCP.
@Test
public void testNetworkTCP() throws Exception {
Reference refInfo = refInfo("sys.nodes.network", DataTypes.OBJECT, RowGranularity.NODE, "tcp");
ColumnIdent columnIdent = refInfo.ident().columnIdent();
io.crate.operation.reference.NestedObjectExpression network = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(columnIdent.name());
NestedObjectExpression tcpRef = (NestedObjectExpression) network.getChildImplementation(columnIdent.path().get(0));
Map<String, Object> tcpStats = tcpRef.value();
assertThat(tcpStats, instanceOf(Map.class));
assertThat(mapToSortedString(tcpStats), is("connections={accepted=42, curr_established=42, dropped=42, embryonic_dropped=42, initiated=42}, " + "packets={errors_received=42, received=42, retransmitted=42, rst_sent=42, sent=42}"));
}
Aggregations