Example usage for org.apache.lucene.util BytesRef BytesRef

List of usage examples for org.apache.lucene.util BytesRef BytesRef

Introduction

In this page you can find the example usage for org.apache.lucene.util BytesRef BytesRef.

Prototype

public BytesRef(CharSequence text) 

Source Link

Document

Initialize the byte[] from the UTF8 bytes for the provided String.

Usage

From source file:io.crate.expression.reference.sys.shard.ShardRelocatingNodeExpression.java

License:Apache License

@Override
public BytesRef value() {
    String relocatingNodeId = indexShard.routingEntry().relocatingNodeId();
    if (relocatingNodeId != null) {
        return new BytesRef(relocatingNodeId);
    }/*from  w w  w.ja  va2  s .  co  m*/
    return null;
}

From source file:io.crate.expression.reference.sys.shard.ShardRoutingStateExpression.java

License:Apache License

@Override
public BytesRef value() {
    return new BytesRef(indexShard.routingEntry().state().name());
}

From source file:io.crate.expression.reference.sys.shard.ShardStateExpression.java

License:Apache License

@Override
public BytesRef value() {
    return new BytesRef(indexShard.state().toString());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testState() throws Exception {
    Reference refInfo = refInfo("sys.shards.state", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("STARTED"), shardExpression.value());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testRoutingState() throws Exception {
    Reference refInfo = refInfo("sys.shards.routing_state", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("RELOCATING"), shardExpression.value());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testRelocatingNode() throws Exception {
    Reference refInfo = refInfo("sys.shards.relocating_node", DataTypes.STRING, RowGranularity.CLUSTER);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("node_X"), shardExpression.value());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testTableName() throws Exception {
    Reference refInfo = refInfo("sys.shards.table_name", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("wikipedia_de"), shardExpression.value());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testMinLuceneVersion() throws Exception {
    Reference refInfo = refInfo("sys.shards.min_lucene_version", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef(Version.LATEST.toString()), shardExpression.value());

    doThrow(new AlreadyClosedException("Already closed")).when(indexShard).minimumCompatibleVersion();
    assertThat(shardExpression.value(), nullValue());
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testTableNameOfPartition() throws Exception {
    // expression should return the real table name
    indexName = IndexParts.PARTITIONED_TABLE_PART + "wikipedia_de._1";
    prepare();//from   w  w  w .j  av a 2s  . c  o m
    Reference refInfo = refInfo("sys.shards.table_name", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("wikipedia_de"), shardExpression.value());

    // reset indexName
    indexName = "wikipedia_de";
}

From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java

License:Apache License

@Test
public void testPartitionIdent() throws Exception {
    indexName = IndexParts.PARTITIONED_TABLE_PART + "wikipedia_de._1";
    prepare();/*from w w w. j a va 2 s .  c om*/
    Reference refInfo = refInfo("sys.shards.partition_ident", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo);
    assertEquals(new BytesRef("_1"), shardExpression.value());

    // reset indexName
    indexName = "wikipedia_de";
}