public PartitionDefinition(DataInput in) throws IOException { this.index = in.readUTF(); this.shardId = in.readInt(); if (in.readBoolean()) { this.slice = new Slice(in.readInt(), in.readInt()); } else { this.slice = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedSettings = StringUtils.asUTFString(utf); } else { this.serializedSettings = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedMapping = StringUtils.asUTFString(utf); } else { this.serializedMapping = null; } int length = in.readInt(); locations = new String[length]; for (int i = 0; i < length; i++) { locations[i] = in.readUTF(); } }
PartitionDefinition.Slice slice = new PartitionDefinition.Slice(i, numPartitions); partitions.add(new PartitionDefinition(settings, resolvedMapping, index, shardId, slice, locations));
public PartitionDefinition(DataInput in) throws IOException { this.index = in.readUTF(); this.shardId = in.readInt(); if (in.readBoolean()) { this.slice = new Slice(in.readInt(), in.readInt()); } else { this.slice = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedSettings = StringUtils.asUTFString(utf); } else { this.serializedSettings = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedMapping = StringUtils.asUTFString(utf); } else { this.serializedMapping = null; } int length = in.readInt(); locations = new String[length]; for (int i = 0; i < length; i++) { locations[i] = in.readUTF(); } }
int numPartitions = (int) Math.max(1, numDocs / maxDocsPerPartition); for (int i = 0; i < numPartitions; i++) { PartitionDefinition.Slice slice = new PartitionDefinition.Slice(i, numPartitions); partitions.add(new PartitionDefinition(settings, resolvedMapping, index, shardId, slice, locations));
int numPartitions = (int) Math.max(1, numDocs / maxDocsPerPartition); for (int i = 0; i < numPartitions; i++) { PartitionDefinition.Slice slice = new PartitionDefinition.Slice(i, numPartitions); partitions.add(new PartitionDefinition(settings, resolvedMapping, index, shardId, slice, locations));
int numPartitions = (int) Math.max(1, numDocs / maxDocsPerPartition); for (int i = 0; i < numPartitions; i++) { PartitionDefinition.Slice slice = new PartitionDefinition.Slice(i, numPartitions); partitions.add(new PartitionDefinition(settings, resolvedMapping, index, shardId, slice, locations));
public PartitionDefinition(DataInput in) throws IOException { this.index = in.readUTF(); this.shardId = in.readInt(); if (in.readBoolean()) { this.slice = new Slice(in.readInt(), in.readInt()); } else { this.slice = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedSettings = StringUtils.asUTFString(utf); } else { this.serializedSettings = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedMapping = StringUtils.asUTFString(utf); } else { this.serializedMapping = null; } int length = in.readInt(); locations = new String[length]; for (int i = 0; i < length; i++) { locations[i] = in.readUTF(); } }
public PartitionDefinition(DataInput in) throws IOException { this.index = in.readUTF(); this.shardId = in.readInt(); if (in.readBoolean()) { this.slice = new Slice(in.readInt(), in.readInt()); } else { this.slice = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedSettings = StringUtils.asUTFString(utf); } else { this.serializedSettings = null; } if (in.readBoolean()) { int length = in.readInt(); byte[] utf = new byte[length]; in.readFully(utf); this.serializedMapping = StringUtils.asUTFString(utf); } else { this.serializedMapping = null; } int length = in.readInt(); locations = new String[length]; for (int i = 0; i < length; i++) { locations[i] = in.readUTF(); } }
@Test public void testSerializableWithSlice() throws IOException, ClassNotFoundException { Mapping mapping = getTestMapping(); PropertiesSettings settings = new PropertiesSettings(); settings.setProperty("setting1", "value1"); settings.setProperty("setting2", "value2"); PartitionDefinition expected = new PartitionDefinition(settings, mapping, "bar", 37, new PartitionDefinition.Slice(13, 35), new String[] {"localhost:9200", "otherhost:9200"}); BytesArray bytes = writeSerializablePartition(expected); PartitionDefinition def = readSerializablePartition(bytes); assertPartitionEquals(expected, def); }
@Test public void testWritableWithSlice() throws IOException { Mapping mapping = getTestMapping(); PropertiesSettings settings = new PropertiesSettings(); settings.setProperty("setting1", "value1"); settings.setProperty("setting2", "value2"); PartitionDefinition expected = new PartitionDefinition(settings, mapping, "foo", 12, new PartitionDefinition.Slice(10, 27), new String[] {"localhost:9200", "otherhost:9200"}); BytesArray bytes = writeWritablePartition(expected); PartitionDefinition def = readWritablePartition(bytes); assertPartitionEquals(expected, def); }