PartitionDefinition.Slice slice = new PartitionDefinition.Slice(i, numPartitions); partitions.add(new PartitionDefinition(settings, resolvedMapping, index, shardId, slice, locations));
@Override public int compareTo(PartitionDefinition o) { int cmp = index.compareTo(o.index); if (cmp != 0) { return cmp; } cmp = shardId - o.shardId; if (cmp != 0) { return cmp; } if (slice != null) { return slice.compareTo(o.slice); } return -1; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PartitionDefinition that = (PartitionDefinition) o; if (shardId != that.shardId) return false; if (!index.equals(that.index)) return false; return slice != null ? slice.equals(that.slice) : that.slice == null; }
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(); } }
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(); } }
@Override public int compareTo(PartitionDefinition o) { int cmp = index.compareTo(o.index); if (cmp != 0) { return cmp; } cmp = shardId - o.shardId; if (cmp != 0) { return cmp; } if (slice != null) { return slice.compareTo(o.slice); } return -1; }
@Override public int compareTo(PartitionDefinition o) { int cmp = index.compareTo(o.index); if (cmp != 0) { return cmp; } cmp = shardId - o.shardId; if (cmp != 0) { return cmp; } if (slice != null) { return slice.compareTo(o.slice); } return -1; }
@Override public int compareTo(PartitionDefinition o) { int cmp = index.compareTo(o.index); if (cmp != 0) { return cmp; } cmp = shardId - o.shardId; if (cmp != 0) { return cmp; } if (slice != null) { return slice.compareTo(o.slice); } return -1; }
@Override public int hashCode() { int result = index.hashCode(); result = 31 * result + shardId; result = 31 * result + (slice != null ? slice.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PartitionDefinition that = (PartitionDefinition) o; if (shardId != that.shardId) return false; if (!index.equals(that.index)) return false; return slice != null ? slice.equals(that.slice) : that.slice == null; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PartitionDefinition that = (PartitionDefinition) o; if (shardId != that.shardId) return false; if (!index.equals(that.index)) return false; return slice != null ? slice.equals(that.slice) : that.slice == null; }
@Override public int hashCode() { int result = index.hashCode(); result = 31 * result + shardId; result = 31 * result + (slice != null ? slice.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PartitionDefinition that = (PartitionDefinition) o; if (shardId != that.shardId) return false; if (!index.equals(that.index)) return false; return slice != null ? slice.equals(that.slice) : that.slice == null; }
@Override public int hashCode() { int result = index.hashCode(); result = 31 * result + shardId; result = 31 * result + (slice != null ? slice.hashCode() : 0); return result; }
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); }