org.graylog.plugins.views.search.searchtypes.pivot.PivotSpecHandler Maven / Gradle / Ivy
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog.plugins.views.search.searchtypes.pivot;
import org.graylog.plugins.views.search.engine.GeneratedQueryContext;
import org.graylog.plugins.views.search.engine.SearchTypeHandler;
import javax.annotation.Nonnull;
import java.util.Optional;
/**
* Implementations of this class contribute handlers for buckets and series to concrete implementations of {@link Pivot the pivot search type}.
* @param the type of bucket or series spec this handler deals with
* @param implementation specific type for building up the aggregation when generating a backend query
* @param the backend specific type holding the overall result from the backend
* @param the backend specific type holding the partial result for the generated aggregation
* @param the backend specific type of the surrounding pivot search type handler
* @param an opaque context object to pass around information between query generation and result handling
*/
public interface PivotSpecHandler {
@SuppressWarnings("unchecked")
@Nonnull
default Optional createAggregation(String name, PivotSpec pivotSpec, SearchTypeHandler searchTypeHandler, GeneratedQueryContext queryContext) {
return doCreateAggregation(name, (SPEC_TYPE) pivotSpec, (SEARCHTYPE_HANDLER) searchTypeHandler, (QUERY_CONTEXT) queryContext);
}
@Nonnull
Optional doCreateAggregation(String name, SPEC_TYPE pivotSpec, SEARCHTYPE_HANDLER searchTypeHandler, QUERY_CONTEXT queryContext);
@SuppressWarnings("unchecked")
default Object handleResult(PivotSpec pivotSpec, Object queryResult, Object aggregationResult, SearchTypeHandler searchTypeHandler, GeneratedQueryContext queryContext) {
return doHandleResult((SPEC_TYPE) pivotSpec, (QUERY_RESULT) queryResult, (AGGREGATION_RESULT) aggregationResult, (SEARCHTYPE_HANDLER) searchTypeHandler, (QUERY_CONTEXT) queryContext);
}
Object doHandleResult(SPEC_TYPE pivotSpec, QUERY_RESULT queryResult, AGGREGATION_RESULT result, SEARCHTYPE_HANDLER searchTypeHandler, QUERY_CONTEXT queryContext);
}