List of usage examples for org.apache.lucene.util BytesRef BytesRef
public BytesRef(CharSequence text)
From source file:io.crate.DataTypeTest.java
License:Apache License
@Test public void testStreaming() throws Exception { BytesRef b1 = new BytesRef("hello"); BytesStreamOutput out = new BytesStreamOutput(); Streamer streamer = DataTypes.STRING.streamer(); streamer.writeValueTo(out, b1);/* w w w . j av a 2 s. com*/ BytesStreamInput in = new BytesStreamInput(out.bytes()); BytesRef b2 = (BytesRef) streamer.readValueFrom(in); assertEquals(b1, b2); }
From source file:io.crate.execution.dml.upsert.ShardUpsertRequestTest.java
License:Apache License
@Test public void testStreaming() throws Exception { ShardId shardId = new ShardId("test", UUIDs.randomBase64UUID(), 1); String[] assignmentColumns = new String[] { "id", "name" }; UUID jobId = UUID.randomUUID(); Reference[] missingAssignmentColumns = new Reference[] { ID_REF, NAME_REF }; ShardUpsertRequest request = new ShardUpsertRequest.Builder(false, false, assignmentColumns, missingAssignmentColumns, jobId, false).newRequest(shardId, "42"); request.validateConstraints(false);//w ww .j a v a 2s . c o m request.add(123, new ShardUpsertRequest.Item("99", null, new Object[] { 99, new BytesRef("Marvin") }, null)); request.add(5, new ShardUpsertRequest.Item("42", new Symbol[] { Literal.of(42), Literal.of("Deep Thought") }, null, 2L)); BytesStreamOutput out = new BytesStreamOutput(); request.writeTo(out); StreamInput in = out.bytes().streamInput(); ShardUpsertRequest request2 = new ShardUpsertRequest(); request2.readFrom(in); assertThat(request, equalTo(request2)); }
From source file:io.crate.execution.dml.upsert.TransportShardUpsertActionTest.java
License:Apache License
@Test public void testProcessGeneratedColumnsWithSubscript() throws Exception { Map<String, Object> updatedColumns = MapBuilder.<String, Object>newMapBuilder() .put("user.name", new BytesRef("zoo")).map(); transportShardUpsertAction.processGeneratedColumns(generatedColumnTableInfo, updatedColumns, Collections.emptyMap(), true, null); assertThat(updatedColumns.size(), is(2)); assertThat((BytesRef) updatedColumns.get("name"), is(new BytesRef("zoobar"))); }
From source file:io.crate.execution.dml.upsert.TransportShardUpsertActionTest.java
License:Apache License
@Test public void testProcessGeneratedColumnsWithSubscriptParentUpdated() throws Exception { Map<String, Object> updatedColumns = MapBuilder.<String, Object>newMapBuilder() .put("user", MapBuilder.<String, Object>newMapBuilder().put("name", new BytesRef("zoo")).map()) .map();/* w w w.j a v a 2 s .c o m*/ transportShardUpsertAction.processGeneratedColumns(generatedColumnTableInfo, updatedColumns, Collections.emptyMap(), true, null); assertThat(updatedColumns.size(), is(2)); assertThat((BytesRef) updatedColumns.get("name"), is(new BytesRef("zoobar"))); }
From source file:io.crate.execution.dml.upsert.TransportShardUpsertActionTest.java
License:Apache License
@Test public void testProcessGeneratedColumnsWithSubscriptParentUpdatedValueMissing() throws Exception { Map<String, Object> updatedColumns = MapBuilder.<String, Object>newMapBuilder() .put("user", MapBuilder.<String, Object>newMapBuilder().put("age", 35).map()).map(); transportShardUpsertAction.processGeneratedColumns(generatedColumnTableInfo, updatedColumns, Collections.emptyMap(), true, null); assertThat(updatedColumns.size(), is(2)); assertThat((BytesRef) updatedColumns.get("name"), is(new BytesRef("bar"))); }
From source file:io.crate.execution.engine.aggregation.GroupingBytesRefCollectorBenchmark.java
License:Apache License
@Setup public void createGroupingCollector() { Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector() .getInstance(Functions.class); groupByMinCollector = createGroupByMinBytesRefCollector(functions); List<BytesRef> keys = new ArrayList<>(Locale.getISOCountries().length); for (String s : Locale.getISOCountries()) { keys.add(new BytesRef(s)); }/* ww w. j a v a 2 s . co m*/ rows = new ArrayList<>(20_000_000); for (int i = 0; i < 20_000_000; i++) { rows.add(new Row1(keys.get(i % keys.size()))); } }
From source file:io.crate.execution.engine.aggregation.impl.ArbitraryAggregationTest.java
License:Apache License
@Test public void testString() throws Exception { Object[][] data = new Object[][] { { new BytesRef("Youri") }, { new BytesRef("Ruben") } }; Object[][] result = executeAggregation(DataTypes.STRING, data); assertThat(result[0][0], isOneOf(data[0][0], data[1][0])); }
From source file:io.crate.execution.engine.aggregation.impl.CollectSetAggregationTest.java
License:Apache License
@Test public void testString() throws Exception { Object[][] result = executeAggregation(DataTypes.STRING, new Object[][] { { new BytesRef("Youri") }, { new BytesRef("Ruben") }, { new BytesRef("Ruben") } }); assertThat(result[0][0], instanceOf(Set.class)); assertEquals(2, ((Set) result[0][0]).size()); assertTrue(((Set) result[0][0]).contains(new BytesRef("Youri"))); }
From source file:io.crate.execution.engine.aggregation.impl.CollectSetAggregationTest.java
License:Apache License
@Test public void testNullValue() throws Exception { Object[][] result = executeAggregation(DataTypes.STRING, new Object[][] { { new BytesRef("Youri") }, { new BytesRef("Ruben") }, { null } }); // null values currently ignored assertThat(result[0][0], instanceOf(Set.class)); assertEquals(2, ((Set) result[0][0]).size()); assertFalse(((Set) result[0][0]).contains(null)); }
From source file:io.crate.execution.engine.aggregation.impl.MaximumAggregationTest.java
License:Apache License
@Test public void testString() throws Exception { Object[][] result = executeAggregation(DataTypes.STRING, new Object[][] { { new BytesRef("Youri") }, { new BytesRef("Ruben") } }); assertEquals(new BytesRef("Youri"), result[0][0]); }