Search in sources :

Example 6 with Reference

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

the class SysNodesExpressionsOnHandlerTest method testRestUrl.

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

Example 7 with Reference

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

the class SysNodesExpressionsOnHandlerTest method testLoad.

@Test
public void testLoad() throws Exception {
    Reference refInfo = refInfo("sys.nodes.load", DataTypes.OBJECT, RowGranularity.NODE);
    collectExpression = resolver.getImplementation(refInfo);
    collectExpression.setNextRow(CONTEXT);
    Map<String, Object> v = (Map<String, Object>) collectExpression.value();
    assertThat(v.get("1"), is(1D));
    assertThat(v.get("5"), is(5D));
    assertThat(v.get("15"), is(15D));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 8 with Reference

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

the class SysNodesExpressionsWithDefaultExtendedStatsTest method testLoad.

@Test
public void testLoad() throws Exception {
    prepare(true);
    Reference refInfo = refInfo("sys.nodes.load", DataTypes.OBJECT, RowGranularity.NODE);
    io.crate.operation.reference.NestedObjectExpression load = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
    Map<String, Object> loadValue = load.value();
    assertThat((Double) loadValue.get("1"), is(-1.0d));
    assertThat((Double) loadValue.get("5"), is(-1.0d));
    assertThat((Double) loadValue.get("15"), is(-1.0d));
}
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 9 with Reference

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

the class SysNodesExpressionsWithDefaultExtendedStatsTest method testFs.

@Test
public void testFs() throws Exception {
    prepare(true);
    Reference refInfo = refInfo("sys.nodes.fs", DataTypes.STRING, RowGranularity.NODE);
    io.crate.operation.reference.NestedObjectExpression fs = (io.crate.operation.reference.NestedObjectExpression) resolver.getChildImplementation(refInfo.ident().columnIdent().name());
    Map<String, Object> v = fs.value();
    //noinspection unchecked
    assertThat(mapToSortedString((Map<String, Object>) v.get("total")), is("available=-1, bytes_read=-1, bytes_written=-1, reads=-1, size=-1, used=-1, writes=-1"));
    Object[] disks = (Object[]) v.get("disks");
    assertThat(disks.length, is(0));
    Object[] data = (Object[]) v.get("data");
    assertThat(data.length, is(0));
}
Also used : Reference(io.crate.metadata.Reference) TestingHelpers.mapToSortedString(io.crate.testing.TestingHelpers.mapToSortedString) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) HashMap(java.util.HashMap) Map(java.util.Map) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 10 with Reference

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

the class SysNodesExpressionsWithDefaultExtendedStatsTest method testFsDataOnNonDataNode.

@Test
public void testFsDataOnNonDataNode() throws Exception {
    prepare(false);
    Reference refInfo = refInfo("sys.nodes.fs", DataTypes.STRING, RowGranularity.NODE, "data");
    ColumnIdent columnIdent = refInfo.ident().columnIdent();
    NestedObjectExpression fs = (NestedObjectExpression) resolver.getChildImplementation(columnIdent.name());
    assertThat(((Object[]) fs.getChildImplementation(columnIdent.path().get(0)).value()).length, is(0));
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) Reference(io.crate.metadata.Reference) NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) 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