Search in sources :

Example 56 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsTest method testHeap.

@Test
public void testHeap() throws Exception {
    Reference refInfo = refInfo("sys.nodes.heap", DataTypes.STRING, RowGranularity.NODE);
    io.crate.operation.reference.NestedObjectExpression heap = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
    Map<String, Object> v = heap.value();
    assertEquals(123456L, v.get("max"));
    assertEquals(123456L, v.get("used"));
    assertEquals(0L, v.get("free"));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 57 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsTest method testOsInfo.

@Test
public void testOsInfo() throws Exception {
    Reference refInfo = refInfo("sys.nodes.os_info", DataTypes.OBJECT, RowGranularity.NODE);
    io.crate.operation.reference.NestedObjectExpression ref = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
    Map<String, Object> v = ref.value();
    int cores = (int) v.get("available_processors");
    assertEquals(4, cores);
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 58 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsTest method testNestedBytesRefExpressionsString.

@Test
public void testNestedBytesRefExpressionsString() throws Exception {
    Reference refInfo = refInfo("sys.nodes.version", DataTypes.OBJECT, RowGranularity.NODE);
    ColumnIdent versionColIdent = refInfo.ident().columnIdent();
    io.crate.operation.reference.NestedObjectExpression version = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(versionColIdent.name());
    assertThat(version.value().get("number"), instanceOf(String.class));
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 59 with Reference

use of io.crate.metadata.Reference 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());
}
Also used : Reference(io.crate.metadata.Reference) BytesRef(org.apache.lucene.util.BytesRef) ReferenceImplementation(io.crate.metadata.ReferenceImplementation) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 60 with Reference

use of io.crate.metadata.Reference in project crate by crate.

the class SysNodesExpressionsOnHandlerTest method testHostname.

@Test
public void testHostname() throws Exception {
    Reference refInfo = refInfo("sys.nodes.hostname", DataTypes.STRING, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    assertThat(BytesRefs.toBytesRef("crate1.example.com"), is(collectExpression.value()));
}
Also used : Reference(io.crate.metadata.Reference) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Reference (io.crate.metadata.Reference)84 Test (org.junit.Test)57 CrateUnitTest (io.crate.test.integration.CrateUnitTest)55 TestingHelpers.mapToSortedString (io.crate.testing.TestingHelpers.mapToSortedString)27 HashMap (java.util.HashMap)20 Map (java.util.Map)20 NestedObjectExpression (io.crate.operation.reference.NestedObjectExpression)17 ColumnIdent (io.crate.metadata.ColumnIdent)15 Symbol (io.crate.analyze.symbol.Symbol)14 BytesRef (org.apache.lucene.util.BytesRef)11 TableIdent (io.crate.metadata.TableIdent)9 ReferenceIdent (io.crate.metadata.ReferenceIdent)8 InputColumn (io.crate.analyze.symbol.InputColumn)6 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)6 ShardId (org.elasticsearch.index.shard.ShardId)5 Routing (io.crate.metadata.Routing)4 UUID (java.util.UUID)4 OrderBy (io.crate.analyze.OrderBy)3 ShardResponse (io.crate.executor.transport.ShardResponse)3 ShardUpsertRequest (io.crate.executor.transport.ShardUpsertRequest)3