use of io.crate.expression.NestableInput in project crate by crate.
the class SysShardsExpressionsTest method testRecoveryShardField.
@Test
public void testRecoveryShardField() throws Exception {
Reference refInfo = refInfo("sys.shards.recovery", DataTypes.UNTYPED_OBJECT, RowGranularity.SHARD);
NestableInput<Map<String, Object>> ref = (NestableInput<Map<String, Object>>) resolver.getImplementation(refInfo);
Map<String, Object> recovery = ref.value();
assertEquals(RecoveryState.Stage.DONE.name(), recovery.get("stage"));
assertEquals(10_000L, recovery.get("total_time"));
Map<String, Object> expectedFiles = new HashMap<String, Object>() {
{
put("used", 2);
put("reused", 1);
put("recovered", 1);
put("percent", 0.0f);
}
};
assertEquals(expectedFiles, recovery.get("files"));
Map<String, Object> expectedBytes = new HashMap<String, Object>() {
{
put("used", 2_048L);
put("reused", 1_024L);
put("recovered", 1_024L);
put("percent", 0.0f);
}
};
assertEquals(expectedBytes, recovery.get("size"));
}
use of io.crate.expression.NestableInput in project crate by crate.
the class SysShardsExpressionsTest method testRoutingState.
@Test
public void testRoutingState() throws Exception {
Reference refInfo = refInfo("sys.shards.routing_state", DataTypes.STRING, RowGranularity.SHARD);
NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
assertEquals("RELOCATING", shardExpression.value());
}
use of io.crate.expression.NestableInput in project crate by crate.
the class SysShardsExpressionsTest method testTableNameOfPartition.
@Test
public void testTableNameOfPartition() throws Exception {
// expression should return the real table name
indexName = IndexParts.toIndexName("doc", "wikipedia_de", "foo");
prepare();
Reference refInfo = refInfo("sys.shards.table_name", DataTypes.STRING, RowGranularity.SHARD);
NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
assertEquals("wikipedia_de", shardExpression.value());
// reset indexName
indexName = "wikipedia_de";
}
use of io.crate.expression.NestableInput in project crate by crate.
the class SysShardsExpressionsTest method testShardSizeExpressionWhenIndexShardHasBeenClosed.
@Test
public void testShardSizeExpressionWhenIndexShardHasBeenClosed() {
IndexShard mock = mockIndexShard();
when(mock.storeStats()).thenThrow(new AlreadyClosedException("shard already closed"));
ShardReferenceResolver resolver = new ShardReferenceResolver(schemas, new ShardRowContext(mock, clusterService));
Reference refInfo = refInfo("sys.shards.size", DataTypes.LONG, RowGranularity.SHARD);
NestableInput<Long> shardSizeExpression = (NestableInput<Long>) resolver.getImplementation(refInfo);
assertThat(shardSizeExpression.value(), is(0L));
}
use of io.crate.expression.NestableInput in project crate by crate.
the class SysShardsExpressionsTest method testCustomSchemaName.
@Test
public void testCustomSchemaName() throws Exception {
indexName = "my_schema.wikipedia_de";
prepare();
Reference refInfo = refInfo("sys.shards.schema_name", DataTypes.STRING, RowGranularity.SHARD);
NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
assertEquals("my_schema", shardExpression.value());
// reset indexName
indexName = "wikipedia_de";
}
Aggregations