Skip to content

Commit

Permalink
Fixed writeable name. Added constructor for stream input.
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <[email protected]>
  • Loading branch information
AWSHurneyt committed Jan 24, 2025
1 parent cb9d38b commit b8976c8
Showing 1 changed file with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
package org.opensearch.commons.alerting.aggregation.bucketselectorext

import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.core.xcontent.ToXContent
import org.opensearch.core.xcontent.XContentBuilder
import org.opensearch.search.aggregations.InternalAggregation
import java.io.IOException
import java.util.Objects

open class BucketSelectorIndices(
name: String?,
private var parentBucketPath: String,
var bucketIndices: List<Int?>,
metaData: Map<String?, Any?>?
) : InternalAggregation(name, metaData) {
open class BucketSelectorIndices : InternalAggregation {
private var parentBucketPath: String
var bucketIndices: List<Int?>

constructor(
name: String?,
parentBucketPath: String,
bucketIndices: List<Int?>,
metaData: Map<String?, Any?>?
) : super(name, metaData) {
this.parentBucketPath = parentBucketPath
this.bucketIndices = bucketIndices
}

/**
* Read from a stream.
*/
@Throws(IOException::class)
constructor(sin: StreamInput) : super(sin) {
parentBucketPath = sin.readString()
bucketIndices = sin.readIntArray().asList()
}

@Throws(IOException::class)
override fun doWriteTo(out: StreamOutput) {
Expand All @@ -21,7 +38,7 @@ open class BucketSelectorIndices(
}

override fun getWriteableName(): String {
return name
return BucketSelectorExtAggregationBuilder.NAME.preferredName
}

override fun reduce(aggregations: List<InternalAggregation>, reduceContext: ReduceContext): BucketSelectorIndices {
Expand Down

0 comments on commit b8976c8

Please sign in to comment.