Skip to content

Commit

Permalink
cleanup PR
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed May 11, 2023
1 parent 66f3a96 commit f71b607
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@

import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.common.util.LongObjectPagedHashMap;
import org.opensearch.core.common.io.stream.BaseWriteable;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.search.aggregations.InternalAggregation;
import org.opensearch.search.aggregations.InternalAggregations;
Expand Down Expand Up @@ -70,15 +68,15 @@ protected BaseGeoGrid(String name, int requiredSize, List<BaseGeoGridBucket> buc
this.buckets = buckets;
}

protected abstract BaseWriteable.Reader<StreamInput, B> getBucketReader();
protected abstract Reader<B> getBucketReader();

/**
* Read from a stream.
*/
public BaseGeoGrid(StreamInput in) throws IOException {
super(in);
requiredSize = readSize(in);
buckets = (List<BaseGeoGridBucket>) in.readList((Writeable.Reader<B>) getBucketReader());
buckets = (List<BaseGeoGridBucket>) in.readList(getBucketReader());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected InternalGeoHashGridBucket createBucket(long hashAsLong, long docCount,
}

@Override
protected Reader getBucketReader() {
protected Reader<InternalGeoHashGridBucket> getBucketReader() {
return InternalGeoHashGridBucket::new;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected InternalGeoTileGridBucket createBucket(long hashAsLong, long docCount,
}

@Override
protected Reader getBucketReader() {
protected Reader<InternalGeoTileGridBucket> getBucketReader() {
return InternalGeoTileGridBucket::new;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import org.opensearch.common.geo.GeoPoint;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.BaseStreamInput;
import org.opensearch.geometry.utils.Geohash;
import org.opensearch.search.aggregations.InternalAggregations;

Expand All @@ -52,8 +51,8 @@ class InternalGeoHashGridBucket extends BaseGeoGridBucket<InternalGeoHashGridBuc
/**
* Read from a stream.
*/
InternalGeoHashGridBucket(BaseStreamInput in) throws IOException {
super((StreamInput) in);
InternalGeoHashGridBucket(StreamInput in) throws IOException {
super(in);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.opensearch.common.geo.GeoPoint;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.BaseStreamInput;
import org.opensearch.search.aggregations.InternalAggregations;
import org.opensearch.search.aggregations.bucket.GeoTileUtils;

Expand All @@ -53,8 +52,8 @@ class InternalGeoTileGridBucket extends BaseGeoGridBucket<InternalGeoTileGridBuc
/**
* Read from a stream.
*/
InternalGeoTileGridBucket(BaseStreamInput in) throws IOException {
super((StreamInput) in);
InternalGeoTileGridBucket(StreamInput in) throws IOException {
super(in);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ public <C extends NamedWriteable> C readOptionalNamedWriteable(Class<C> category
* @return the list of objects
* @throws IOException if an I/O exception occurs reading the list
*/
public <T> List<T> readList(final Writeable.Reader<T> reader) throws IOException {
public <T> List<T> readList(final BaseWriteable.Reader<StreamInput, T> reader) throws IOException {
return readCollection(reader, ArrayList::new, Collections.emptyList());
}

Expand Down Expand Up @@ -1207,8 +1207,11 @@ public <T> Set<T> readSet(Writeable.Reader<T> reader) throws IOException {
/**
* Reads a collection of objects
*/
private <T, C extends Collection<? super T>> C readCollection(Writeable.Reader<T> reader, IntFunction<C> constructor, C empty)
throws IOException {
private <T, C extends Collection<? super T>> C readCollection(
BaseWriteable.Reader<StreamInput, T> reader,
IntFunction<C> constructor,
C empty
) throws IOException {
int count = readArraySize();
if (count == 0) {
return empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ public void writeOptionalZoneId(@Nullable ZoneId timeZone) throws IOException {

/**
* Writes a collection to this stream. The corresponding collection can be read from a stream input using
* {@link StreamInput#readList(Writeable.Reader)}.
* {@link StreamInput#readList(BaseWriteable.Reader)}.
*
* @param collection the collection to write to this stream
* @throws IOException if an I/O exception occurs writing the collection
Expand Down Expand Up @@ -1207,7 +1207,7 @@ public <T> void writeCollection(final Collection<T> collection, final Writer<T>

/**
* Writes a collection of a strings. The corresponding collection can be read from a stream input using
* {@link StreamInput#readList(Writeable.Reader)}.
* {@link StreamInput#readList(BaseWriteable.Reader)}.
*
* @param collection the collection of strings
* @throws IOException if an I/O exception occurs writing the collection
Expand All @@ -1218,7 +1218,7 @@ public void writeStringCollection(final Collection<String> collection) throws IO

/**
* Writes an optional collection of a strings. The corresponding collection can be read from a stream input using
* {@link StreamInput#readList(Writeable.Reader)}.
* {@link StreamInput#readList(BaseWriteable.Reader)}.
*
* @param collection the collection of strings
* @throws IOException if an I/O exception occurs writing the collection
Expand Down

0 comments on commit f71b607

Please sign in to comment.