use of org.apache.lucene.util.BytesRef in project crate by crate.
the class PartitionedTableIntegrationTest method testAlterTableResetPartitionedTable.
@Test
public void testAlterTableResetPartitionedTable() throws Exception {
execute("create table quotes (id integer, quote string, date timestamp) " + "partitioned by(date) clustered into 3 shards with (number_of_replicas='1-all')");
ensureYellow();
execute("insert into quotes (id, quote, date) values (?, ?, ?), (?, ?, ?)", new Object[] { 1, "Don't panic", 1395874800000L, 2, "Now panic", 1395961200000L });
assertThat(response.rowCount(), is(2L));
ensureYellow();
refresh();
execute("alter table quotes reset (number_of_replicas)");
ensureYellow();
String templateName = PartitionName.templateName(null, "quotes");
GetIndexTemplatesResponse templatesResponse = client().admin().indices().prepareGetTemplates(templateName).execute().actionGet();
Settings templateSettings = templatesResponse.getIndexTemplates().get(0).getSettings();
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0), is(1));
assertThat(templateSettings.get(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS), is("false"));
List<String> partitions = ImmutableList.of(new PartitionName("quotes", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName(), new PartitionName("quotes", Collections.singletonList(new BytesRef("1395961200000"))).asIndexName());
Thread.sleep(1000);
GetSettingsResponse settingsResponse = client().admin().indices().prepareGetSettings(partitions.get(0), partitions.get(1)).execute().get();
for (String index : partitions) {
assertThat(settingsResponse.getSetting(index, IndexMetaData.SETTING_NUMBER_OF_REPLICAS), is("1"));
assertThat(settingsResponse.getSetting(index, IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS), is("false"));
}
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class ClientMessages method sendBindMessage.
static void sendBindMessage(ChannelBuffer buffer, String portalName, String statementName, List<Object> params) {
buffer.writeByte('B');
byte[] portalBytes = portalName.getBytes(StandardCharsets.UTF_8);
byte[] statementBytes = statementName.getBytes(StandardCharsets.UTF_8);
int beforeLengthWriterIndex = buffer.writerIndex();
buffer.writeInt(0);
writeCString(buffer, portalBytes);
writeCString(buffer, statementBytes);
// formatCode use 0 to default to text for all
buffer.writeShort(0);
buffer.writeShort(params.size());
int paramsLength = 0;
for (Object param : params) {
BytesRef value = DataTypes.STRING.value(param);
buffer.writeInt(value.length + 1);
buffer.writeBytes(value.bytes, value.offset, value.length);
buffer.writeByte(0);
paramsLength += 4 + value.length + 1;
}
// numResultFormatCodes - 0 to default to text for all
buffer.writeShort(0);
buffer.setInt(beforeLengthWriterIndex, 4 + portalBytes.length + 1 + statementBytes.length + 1 + // numFormatCodes
2 + // numParams
2 + paramsLength + // numResultColumnFormatCodes
2);
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class BytesRefUtils method setToStringArray.
private static String[] setToStringArray(Set<BytesRef> values) {
String[] strings = new String[values.size()];
int idx = 0;
for (BytesRef value : values) {
strings[idx] = value == null ? null : value.utf8ToString();
idx++;
}
return strings;
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class MatchQueryBuilderTest method testSimpleSingleMatchTwoTerms.
@Test
public void testSimpleSingleMatchTwoTerms() throws Exception {
Map<String, Object> fields = MapBuilder.<String, Object>newMapBuilder().put("col1", null).map();
MatchQueryBuilder builder = new MatchQueryBuilder(mockMapperService(), null, Collections.emptyMap());
Query query = builder.query(fields, new BytesRef("foo bar"));
assertThat(query, instanceOf(BooleanQuery.class));
}
use of org.apache.lucene.util.BytesRef in project crate by crate.
the class MatchQueryBuilderTest method testTwoFieldsSingleTerm.
@Test
public void testTwoFieldsSingleTerm() throws Exception {
MatchQueryBuilder builder = new io.crate.lucene.match.MultiMatchQueryBuilder(mockMapperService(), null, Collections.emptyMap());
Map<String, Object> fields = MapBuilder.<String, Object>newMapBuilder().put("col1", null).put("col2", null).map();
Query query = builder.query(fields, new BytesRef("foo"));
assertThat(query, instanceOf(DisjunctionMaxQuery.class));
}
Aggregations