org.carrot2.input.aggregator
Class AggregatorInputComponent

java.lang.Object
  extended by org.carrot2.core.LocalComponentBase
      extended by org.carrot2.core.LocalInputComponentBase
          extended by org.carrot2.input.aggregator.AggregatorInputComponent
All Implemented Interfaces:
RawDocumentsProducer, LocalComponent, LocalInputComponent, ResultsCollector

public class AggregatorInputComponent
extends LocalInputComponentBase
implements ResultsCollector, RawDocumentsProducer

This is an input component that aggregates results from a number of other input components. In the constructor you can specify an array of factories of input components to be aggregated. Optionally, you can set the maximum amount of time the aggregator component will wait for all the individual inputs to deliver the results. For a usage example, see AggregatorInputExample.

Limitations:

This component was donated to the Carrot2 project by deepVertical.

Author:
Stanislaw Osinski
See Also:
AggregatorInputExample

Field Summary
static int DEFAULT_INPUT_TIMEOUT
          The default input timeout (in miliseconds, 10 seconds).
 
Fields inherited from class org.carrot2.core.LocalInputComponentBase
next
 
Fields inherited from interface org.carrot2.core.clustering.RawDocumentsProducer
PARAM_ORIGINAL_RAW_CLUSTERS, PROPERTY_CATID
 
Fields inherited from interface org.carrot2.core.LocalInputComponent
PARAM_QUERY, PARAM_REQUESTED_RESULTS, PARAM_START_AT, PARAM_TOTAL_MATCHING_DOCUMENTS
 
Constructor Summary
AggregatorInputComponent(AggregatorInput[] inputs)
          Creates the aggregator input component.
AggregatorInputComponent(AggregatorInput[] inputs, int timeout)
          Creates the aggregator input component.
 
Method Summary
 void addResults(List results, String inputId)
           
 void endProcessing()
          The default implementation invokes endProcessing() method on the successor component.
 void flushResources()
          The default implementation invokes flushResources() method on the successor component.
 Set getComponentCapabilities()
          Provides an implementation that has no capabilities (an empty set).
 String getName()
          The default implementation returning null.
 Set getRequiredSuccessorCapabilities()
          Provides an implementation that requires no capabilities of the successor component.
 void init(LocalControllerContext context)
          Provides an empty implementation.
 void processingErrorOccurred()
          The default implementation invokes processingErrorOccurred() method on the successor component.
 void setNext(LocalComponent next)
          The default implementation sets the LocalInputComponentBase.next field and verifies the contract in LocalFilterComponent.setNext(LocalComponent)
 void setQuery(String query)
          Sets the query for the current request.
 void startProcessing(RequestContext requestContext)
          The default implementation invokes protected LocalInputComponentBase.validate() method first to verify preconditions.
 
Methods inherited from class org.carrot2.core.LocalInputComponentBase
getRequestedResults, validate
 
Methods inherited from class org.carrot2.core.LocalComponentBase
getDescription, getIntFromRequestContext, getProperty, getRequiredPredecessorCapabilities, setProperty, toSet, toSet, toSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.carrot2.core.LocalComponent
getDescription, getRequiredPredecessorCapabilities, setProperty
 

Field Detail

DEFAULT_INPUT_TIMEOUT

public static final int DEFAULT_INPUT_TIMEOUT
The default input timeout (in miliseconds, 10 seconds).

See Also:
Constant Field Values
Constructor Detail

AggregatorInputComponent

public AggregatorInputComponent(AggregatorInput[] inputs)
Creates the aggregator input component.

Parameters:
inputs - an array of AggregatorInputs describing the document sources to be aggregated

AggregatorInputComponent

public AggregatorInputComponent(AggregatorInput[] inputs,
                                int timeout)
Creates the aggregator input component.

Parameters:
inputs - an array of AggregatorInputs describing the document sources to be aggregated
timeout - the maximum amount of time the aggregator component will wait for all the individual inputs to deliver the results
Method Detail

getComponentCapabilities

public Set getComponentCapabilities()
Description copied from class: LocalComponentBase
Provides an implementation that has no capabilities (an empty set).

Specified by:
getComponentCapabilities in interface LocalComponent
Overrides:
getComponentCapabilities in class LocalComponentBase
Returns:
A Setobject with capabilities. The object returned may be empty, but should never be null.

getRequiredSuccessorCapabilities

public Set getRequiredSuccessorCapabilities()
Description copied from class: LocalComponentBase
Provides an implementation that requires no capabilities of the successor component.

Specified by:
getRequiredSuccessorCapabilities in interface LocalComponent
Overrides:
getRequiredSuccessorCapabilities in class LocalComponentBase
Returns:
A Setobject with capabilities. The object returned may be empty, but should never be null.

setNext

public void setNext(LocalComponent next)
Description copied from class: LocalInputComponentBase
The default implementation sets the LocalInputComponentBase.next field and verifies the contract in LocalFilterComponent.setNext(LocalComponent)

Specified by:
setNext in interface LocalInputComponent
Overrides:
setNext in class LocalInputComponentBase
Parameters:
next - A reference to an instance of LocalComponent that is the successor component in a processing chain assembled for the execution of a single query.

endProcessing

public void endProcessing()
                   throws ProcessingException
Description copied from class: LocalInputComponentBase
The default implementation invokes endProcessing() method on the successor component.

Specified by:
endProcessing in interface LocalComponent
Overrides:
endProcessing in class LocalInputComponentBase
Throws:
ProcessingException - Thrown if the component encountered a problem in processing the query. May also be thrown from a chained successor component. It is allowed to throw an exception and not invoke endProcessing() method on subsequent components. In such case, all components will receive a LocalComponent.processingErrorOccurred()call.

flushResources

public void flushResources()
Description copied from class: LocalInputComponentBase
The default implementation invokes flushResources() method on the successor component.

Specified by:
flushResources in interface LocalComponent
Overrides:
flushResources in class LocalInputComponentBase

processingErrorOccurred

public void processingErrorOccurred()
Description copied from class: LocalInputComponentBase
The default implementation invokes processingErrorOccurred() method on the successor component.

Specified by:
processingErrorOccurred in interface LocalComponent
Overrides:
processingErrorOccurred in class LocalInputComponentBase

startProcessing

public void startProcessing(RequestContext requestContext)
                     throws ProcessingException
Description copied from class: LocalInputComponentBase
The default implementation invokes protected LocalInputComponentBase.validate() method first to verify preconditions. Then it invokes startProcessing(requestContext) method on the successor component.

Specified by:
startProcessing in interface LocalComponent
Overrides:
startProcessing in class LocalInputComponentBase
Parameters:
requestContext - A RequestContextinterface instance passed by the container processing the query. The context may be used to retrieve parameters associated with the query (see RequestContext.getRequestParameters() method).
Throws:
ProcessingException - Thrown if the component encountered a problem in processing the query. May also be thrown from a chained successor component.

addResults

public void addResults(List results,
                       String inputId)
Specified by:
addResults in interface ResultsCollector

init

public void init(LocalControllerContext context)
          throws InstantiationException
Description copied from class: LocalComponentBase
Provides an empty implementation.

Specified by:
init in interface LocalComponent
Overrides:
init in class LocalComponentBase
Parameters:
context - A controller context instance.
Throws:
InstantiationException - Thrown if the component is unable to properly initialize and should not be used to process queries.
See Also:
LocalComponent.init(LocalControllerContext)

setQuery

public void setQuery(String query)
Description copied from interface: LocalInputComponent
Sets the query for the current request. The format of the query depends on the component used.

Specified by:
setQuery in interface LocalInputComponent
Parameters:
query - A String with the query.

getName

public String getName()
Description copied from class: LocalComponentBase
The default implementation returning null. In concrete implementations override this method to provide the appropriate name.

Specified by:
getName in interface LocalComponent
Overrides:
getName in class LocalComponentBase
Returns:
null name


Copyright (c) Dawid Weiss, Stanislaw Osinski