Package io.activej.aggregation
Class Aggregation
java.lang.Object
io.activej.aggregation.Aggregation
- All Implemented Interfaces:
IAggregation,io.activej.common.initializer.WithInitializer<Aggregation>,io.activej.eventloop.jmx.EventloopJmxBean,io.activej.eventloop.jmx.EventloopJmxBeanWithStats
public class Aggregation
extends Object
implements IAggregation, io.activej.common.initializer.WithInitializer<Aggregation>, io.activej.eventloop.jmx.EventloopJmxBeanWithStats
Represents an aggregation, which aggregates data using custom reducer and preaggregator.
Provides methods for loading and querying data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final Durationstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescription<K extends Comparable,I, O, A>
StreamReducers.Reducer<K,I, O, A> aggregationReducer(Class<I> inputClass, Class<O> outputClass, List<String> keys, List<String> measures, DefiningClassLoader classLoader) io.activej.promise.Promise<AggregationDiff>consolidate(List<AggregationChunk> chunks) io.activej.promise.Promise<AggregationDiff>io.activej.promise.Promise<AggregationDiff>consolidateHotSegment(Set<Object> lockedChunkIds) io.activej.promise.Promise<AggregationDiff>io.activej.promise.Promise<AggregationDiff>consolidateMinKey(Set<Object> lockedChunkIds) <T,C, K extends Comparable>
StreamConsumerWithResult<T,AggregationDiff> Provides aStreamConsumerfor streaming data to this aggregation.static Aggregationcreate(io.activej.eventloop.Eventloop eventloop, Executor executor, DefiningClassLoader classLoader, AggregationChunkStorage aggregationChunkStorage, io.activej.csp.process.frames.FrameFormat frameFormat, @NotNull AggregationStructure structure) Instantiates an aggregation with the specified structure, that runs in a given event loop, uses the specified class loader for creating dynamic classes, saves data and metadata to given storages.doubleestimateCost(AggregationQuery query) static StringgetChunkIds(Iterable<AggregationChunk> chunks) intgetChunksForConsolidation(Set<Object> lockedChunkIds, boolean hotSegment) int@Nullable Integerint@Nullable Integer@NotNull io.activej.eventloop.EventloopgetKeys()intintintgetState()getStats()boolean<T> StreamSupplier<T>query(AggregationQuery query, Class<T> outputClass) <T> StreamSupplier<T>query(AggregationQuery query, Class<T> outputClass, DefiningClassLoader queryClassLoader) Returns aStreamSupplierof the records retrieved from aggregation for the specified query.voidsetChunkSize(int chunkSize) voidsetIgnoreChunkReadingExceptions(boolean ignoreChunkReadingExceptions) voidsetMaxChunksToConsolidate(int maxChunksToConsolidate) voidsetMaxIncrementalReloadPeriod(Duration maxIncrementalReloadPeriod) voidsetSorterItemsInMemory(int sorterItemsInMemory) voidsetState(AggregationState state) toString()withChunkSize(int chunkSize) withIgnoreChunkReadingExceptions(boolean ignoreChunkReadingExceptions) withMaxChunksToConsolidate(int maxChunksToConsolidate) withMaxIncrementalReloadPeriod(Duration maxIncrementalReloadPeriod) withReducerBufferSize(int reducerBufferSize) withSorterItemsInMemory(int sorterItemsInMemory) withStats(AggregationStats stats) withTemporarySortDir(Path temporarySortDir) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.activej.eventloop.jmx.EventloopJmxBeanWithStats
getSmoothingWindow, resetStats, setSmoothingWindowMethods inherited from interface io.activej.common.initializer.WithInitializer
withInitializer
-
Field Details
-
DEFAULT_CHUNK_SIZE
public static final int DEFAULT_CHUNK_SIZE- See Also:
-
DEFAULT_REDUCER_BUFFER_SIZE
public static final int DEFAULT_REDUCER_BUFFER_SIZE- See Also:
-
DEFAULT_SORTER_ITEMS_IN_MEMORY
public static final int DEFAULT_SORTER_ITEMS_IN_MEMORY- See Also:
-
DEFAULT_MAX_INCREMENTAL_RELOAD_PERIOD
-
DEFAULT_MAX_CHUNKS_TO_CONSOLIDATE
public static final int DEFAULT_MAX_CHUNKS_TO_CONSOLIDATE- See Also:
-
-
Method Details
-
create
public static Aggregation create(io.activej.eventloop.Eventloop eventloop, Executor executor, DefiningClassLoader classLoader, AggregationChunkStorage aggregationChunkStorage, io.activej.csp.process.frames.FrameFormat frameFormat, @NotNull @NotNull AggregationStructure structure) Instantiates an aggregation with the specified structure, that runs in a given event loop, uses the specified class loader for creating dynamic classes, saves data and metadata to given storages. Maximum size of chunk is 1,000,000 bytes. No more than 1,000,000 records stay in memory while sorting. Maximum duration of consolidation attempt is 30 minutes. Consolidated chunks become available for removal in 10 minutes from consolidation.- Parameters:
eventloop- event loop, in which the aggregation is to runexecutor- executor, that is used for asynchronous work with filesclassLoader- class loader for defining dynamic classesaggregationChunkStorage- storage for data chunksframeFormat- frame format in which data is to be stored
-
withChunkSize
-
withReducerBufferSize
-
withSorterItemsInMemory
-
withMaxIncrementalReloadPeriod
-
withIgnoreChunkReadingExceptions
-
withMaxChunksToConsolidate
-
withTemporarySortDir
-
withStats
-
getStructure
-
getState
-
setState
-
detachState
-
getKeys
-
getMeasures
-
getKeyTypes
-
getMeasureTypes
-
getPartitioningKey
-
aggregationReducer
public <K extends Comparable,I, StreamReducers.Reducer<K,O, A> I, aggregationReducerO, A> (Class<I> inputClass, Class<O> outputClass, List<String> keys, List<String> measures, DefiningClassLoader classLoader) -
consume
public <T,C, StreamConsumerWithResult<T,K extends Comparable> AggregationDiff> consume(Class<T> inputClass, Map<String, String> keyFields, Map<String, String> measureFields) Provides aStreamConsumerfor streaming data to this aggregation.- Type Parameters:
T- data records type- Parameters:
inputClass- class of input records- Returns:
- consumer for streaming data to aggregation
-
consume
-
estimateCost
-
query
-
query
public <T> StreamSupplier<T> query(AggregationQuery query, Class<T> outputClass, DefiningClassLoader queryClassLoader) Returns aStreamSupplierof the records retrieved from aggregation for the specified query.- Specified by:
queryin interfaceIAggregation- Type Parameters:
T- type of output objects- Parameters:
query- queryoutputClass- class of output records- Returns:
- supplier that streams query results
-
getNumberOfOverlappingChunks
public int getNumberOfOverlappingChunks() -
consolidateMinKey
-
consolidateMinKey
-
consolidateHotSegment
-
consolidateHotSegment
public io.activej.promise.Promise<AggregationDiff> consolidateHotSegment(Set<Object> lockedChunkIds) -
consolidate
-
getChunksForConsolidation
public List<AggregationChunk> getChunksForConsolidation(Set<Object> lockedChunkIds, boolean hotSegment) -
getChunkIds
-
getMaxIncrementalReloadPeriod
-
setMaxIncrementalReloadPeriod
-
getChunkSize
public int getChunkSize() -
setChunkSize
public void setChunkSize(int chunkSize) -
getSorterItemsInMemory
public int getSorterItemsInMemory() -
setSorterItemsInMemory
public void setSorterItemsInMemory(int sorterItemsInMemory) -
isIgnoreChunkReadingExceptions
public boolean isIgnoreChunkReadingExceptions() -
setIgnoreChunkReadingExceptions
public void setIgnoreChunkReadingExceptions(boolean ignoreChunkReadingExceptions) -
getMaxChunksToConsolidate
public int getMaxChunksToConsolidate() -
setMaxChunksToConsolidate
public void setMaxChunksToConsolidate(int maxChunksToConsolidate) -
getConsolidationSeconds
-
getConsolidationLastTimeSeconds
-
getConsolidations
public int getConsolidations() -
getConsolidationLastError
-
getChunks
public int getChunks() -
getStats
-
getEventloop
@NotNull public @NotNull io.activej.eventloop.Eventloop getEventloop()- Specified by:
getEventloopin interfaceio.activej.eventloop.jmx.EventloopJmxBean
-
toString
-