Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Fix bucket selector aggregation writeable name. #776

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading