List of usage examples for org.apache.lucene.util BytesRef BytesRef
public BytesRef(CharSequence text)
From source file:io.crate.analyze.CompoundLiteralTest.java
License:Apache License
@SuppressWarnings("ConstantConditions") @Test/* w w w . j a v a 2 s . c o m*/ public void testObjectConstruction() throws Exception { Symbol s = expressions.asSymbol("{}"); assertThat(s, instanceOf(Literal.class)); Literal l = (Literal) s; assertThat(l.value(), is((Object) new HashMap<String, Object>())); Literal objectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{ident='value'}")); assertThat(objectLiteral.symbolType(), is(SymbolType.LITERAL)); assertThat(objectLiteral.valueType(), is((DataType) ObjectType.INSTANCE)); assertThat(objectLiteral.value(), is((Object) new MapBuilder<String, Object>().put("ident", new BytesRef("value")).map())); Literal multipleObjectLiteral = (Literal) expressions .normalize(expressions.asSymbol("{\"Ident\"=123.4, a={}, ident='string'}")); Map<String, Object> values = (Map<String, Object>) multipleObjectLiteral.value(); assertThat(values, is(new MapBuilder<String, Object>().put("Ident", 123.4d) .put("a", new HashMap<String, Object>()).put("ident", new BytesRef("string")).map())); }
From source file:io.crate.analyze.CompoundLiteralTest.java
License:Apache License
@Test public void testObjectConstructionWithExpressionsAsValues() throws Exception { Literal objectLiteral = (Literal) expressions.normalize(expressions.asSymbol("{name = 1 + 2}")); assertThat(objectLiteral.symbolType(), is(SymbolType.LITERAL)); assertThat(objectLiteral.value(), is(new MapBuilder<String, Object>().put("name", 3L).map())); Literal nestedObjectLiteral = (Literal) expressions .normalize(expressions.asSymbol("{a = {name = concat('foo', 'bar')}}")); @SuppressWarnings("unchecked") Map<String, Object> values = (Map<String, Object>) nestedObjectLiteral.value(); assertThat(values, is(new MapBuilder<String, Object>().put("a", new HashMap<String, Object>() { {/*w w w. j a v a 2s . c o m*/ put("name", new BytesRef("foobar")); } }).map())); }
From source file:io.crate.analyze.CopyAnalyzerTest.java
License:Apache License
@Test public void testCopyFromPartitionedTablePARTITIONKeywordValidArgs() throws Exception { CopyAnalyzedStatement analysis = (CopyAnalyzedStatement) analyze( "copy parted partition (date=1395874800000) from '/some/distant/file.ext'"); String parted = new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).ident(); assertThat(analysis.partitionIdent(), equalTo(parted)); }
From source file:io.crate.analyze.CopyAnalyzerTest.java
License:Apache License
@Test public void testCopyToFileWithPartitionClause() throws Exception { CopyAnalyzedStatement analysis = (CopyAnalyzedStatement) analyze( "copy parted partition (date=1395874800000) to '/blah.txt'"); String parted = new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).ident(); assertThat(analysis.partitionIdent(), is(parted)); }
From source file:io.crate.analyze.CopyAnalyzerTest.java
License:Apache License
@Test public void testCopyToDirectoryithPartitionClause() throws Exception { CopyAnalyzedStatement analysis = (CopyAnalyzedStatement) analyze( "copy parted partition (date=1395874800000) to directory '/tmp'"); assertThat(analysis.directoryUri(), is(true)); String parted = new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).ident(); assertThat(analysis.partitionIdent(), is(parted)); }
From source file:io.crate.analyze.CreateAlterPartitionedTableAnalyzerTest.java
License:Apache License
@Test public void testAlterPartitionedTablePartition() throws Exception { AlterTableAnalyzedStatement analysis = (AlterTableAnalyzedStatement) analyze( "alter table parted partition (date=1395874800000) set (number_of_replicas='0-all')"); assertThat(analysis.partitionName().isPresent(), is(true)); assertThat(analysis.partitionName().get(), is(new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))))); assertThat(analysis.table().tableParameterInfo(), instanceOf(AlterPartitionedTableParameterInfo.class)); AlterPartitionedTableParameterInfo tableSettingsInfo = (AlterPartitionedTableParameterInfo) analysis.table() .tableParameterInfo();/*from www. ja v a 2s.c o m*/ assertThat(tableSettingsInfo.partitionTableSettingsInfo(), instanceOf(TableParameterInfo.class)); assertEquals("0-all", analysis.tableParameter().settings().get(TableParameterInfo.AUTO_EXPAND_REPLICAS)); }
From source file:io.crate.analyze.CreateAlterTableStatementAnalyzerTest.java
License:Apache License
@Test public void testAlterPartitionedTablePartition() throws Exception { AlterTableAnalysis analysis = (AlterTableAnalysis) analyze( "alter table parted partition (date=1395874800000) set (number_of_replicas='0-all')"); assertThat(analysis.partitionName().isPresent(), is(true)); assertThat(analysis.partitionName().get(), is(new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))))); }
From source file:io.crate.analyze.DeleteAnalyzerTest.java
License:Apache License
@Test public void testDeleteWherePartitionedByColumn() throws Exception { DeleteAnalysis.NestedDeleteAnalysis analysis = analyze("delete from parted where date = 1395874800000"); assertThat(analysis.whereClause().hasQuery(), Matchers.is(false)); assertThat(analysis.whereClause().noMatch(), Matchers.is(false)); assertEquals(//from w w w. j a va 2s. co m ImmutableList.of( new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).stringValue()), analysis.whereClause().partitions()); analysis = analyze("delete from parted"); assertThat(analysis.whereClause().hasQuery(), Matchers.is(false)); assertThat(analysis.whereClause().noMatch(), Matchers.is(false)); assertEquals(ImmutableList.<String>of(), analysis.whereClause().partitions()); }
From source file:io.crate.analyze.IdTest.java
License:Apache License
@Test public void testSinglePrimaryKey() throws Exception { String id = generateId(ImmutableList.of(ci("id")), ImmutableList.of(new BytesRef("1")), ci("id")); assertThat(id, is("1")); }
From source file:io.crate.analyze.IdTest.java
License:Apache License
@Test public void testMultiplePrimaryKey() throws Exception { String id = generateId(ImmutableList.of(ci("id"), ci("name")), ImmutableList.of(new BytesRef("1"), new BytesRef("foo")), null); assertThat(id, is("AgExA2Zvbw==")); }