List of usage examples for org.apache.lucene.util BytesRef BytesRef
public BytesRef(CharSequence text)
From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java
License:Apache License
@Test public void testPartitionIdentOfNonPartition() throws Exception { // expression should return NULL on non partitioned tables Reference refInfo = refInfo("sys.shards.partition_ident", DataTypes.STRING, RowGranularity.SHARD); NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo); assertEquals(new BytesRef(""), shardExpression.value()); }
From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java
License:Apache License
@Test public void testSchemaName() throws Exception { Reference refInfo = refInfo("sys.shards.schema_name", DataTypes.STRING, RowGranularity.SHARD); NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo); assertEquals(new BytesRef("doc"), shardExpression.value()); }
From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java
License:Apache License
@Test public void testCustomSchemaName() throws Exception { indexName = "my_schema.wikipedia_de"; prepare();//w w w. j av a 2 s.c om Reference refInfo = refInfo("sys.shards.schema_name", DataTypes.STRING, RowGranularity.SHARD); NestableInput<BytesRef> shardExpression = (NestableInput<BytesRef>) resolver.getImplementation(refInfo); assertEquals(new BytesRef("my_schema"), shardExpression.value()); // reset indexName indexName = "wikipedia_de"; }
From source file:io.crate.expression.reference.sys.SysShardsExpressionsTest.java
License:Apache License
@Test public void testTableNameOfCustomSchema() throws Exception { // expression should return the real table name indexName = "my_schema.wikipedia_de"; prepare();/*from ww w .java2s. 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.scalar.arithmetic.MapFunctionTest.java
License:Apache License
@Test public void testEvaluation() throws Exception { Map<String, Object> m = new HashMap<>(); m.put("foo", 10L); // minimum args assertEvaluate("_map('foo', 10)", m); // variable args m.put("bar", new BytesRef("some")); assertEvaluate("_map('foo', 10, 'bar', 'some')", m); }
From source file:io.crate.expression.scalar.ArrayUniqueFunctionTest.java
License:Apache License
@Test public void testOneArgument() throws Exception { assertEvaluate("array_unique(['foo', 'bar', 'baz', 'baz'])", new BytesRef[] { new BytesRef("foo"), new BytesRef("bar"), new BytesRef("baz") }); }
From source file:io.crate.expression.scalar.cast.CastFunctionTest.java
License:Apache License
@Test public void testCasts() throws Exception { assertEvaluate("cast(10.4 as string)", new BytesRef("10.4")); assertEvaluate("cast(null as string)", null); assertEvaluate("cast(10.4 as long)", 10L); assertEvaluate("to_long_array([10.2, 12.3])", new Long[] { 10L, 12L }); assertEvaluate("to_double_table([10, 12])", new Double[] { 10.0, 12.0 }); Map<String, Object> object = new HashMap<>(); object.put("x", 10); assertEvaluate("'{\"x\": 10}'::object", object); assertEvaluate("cast(name as object)", object, Literal.of("{\"x\": 10}")); assertEvaluate("cast(['2017-01-01','2017-12-31'] as array(timestamp))", new Long[] { 1483228800000L, 1514678400000L }); }
From source file:io.crate.expression.scalar.cast.CastFunctionTest.java
License:Apache License
@Test public void testDoubleColonOperatorCast() { assertEvaluate("10.4::string", new BytesRef("10.4")); assertEvaluate("[1, 2, 0]::array(boolean)", new Boolean[] { true, true, false }); assertEvaluate("(1+3)/2::string", new BytesRef("2")); assertEvaluate("'10'::long + 5", 15L); assertEvaluate("-4::string", new BytesRef("-4")); assertEvaluate("'-4'::long", -4L); assertEvaluate("-4::string || ' apples'", new BytesRef("-4 apples")); assertEvaluate("'-4'::long + 10", 6L); }
From source file:io.crate.expression.scalar.DateFormatFunctionTest.java
License:Apache License
@Test public void testEvaluateDefault() throws Exception { assertEvaluate("date_format(timestamp)", new BytesRef("2015-06-10T07:03:00.004000Z"), Literal.of(DataTypes.TIMESTAMP, DataTypes.TIMESTAMP.value("2015-06-10T09:03:00.004+02"))); }
From source file:io.crate.expression.scalar.DateFormatFunctionTest.java
License:Apache License
@Test public void testEvaluateDefaultTimezone() throws Exception { assertEvaluate("date_format(time_format, timestamp)", new BytesRef("Fri Jan 1 1st 01 1 000000 00 12 12 00 001 0 12 January 01 AM 12:00:00 AM " + "00 00 00:00:00 00 00 52 53 Friday 5 2054 2054 2055 55"), Literal.of("%a %b %c %D %d %e %f %H %h %I %i %j %k %l %M %m %p %r " + "%S %s %T %U %u %V %v %W %w %X %x %Y %y"), Literal.of(DataTypes.TIMESTAMP, DataTypes.TIMESTAMP.value("2055-01-01"))); }