Class Compose
java.lang.Object
com.semedy.reasoner.builtin.aggregation.Compose
- All Implemented Interfaces:
Aggregation
,Builtin
Aggregating composer builtin. For example:
p(John). p(Mike). r: people(?all) :- p(?p), compose('all',?p,?all).
Will return
all(John, Mike)
when queried. You can also specify an existing composite as the first argument, in which case the arguments will be appended, e.g.
p(John). p(Mike). r: people(?all) :- p(?p), compose(all('first guy'),?p,?all).
Will return
all('first guy', John, Mike)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
frees up allocated resourcesclone the builtinboolean
aggregation delivers only one result at argument position.void
evaluate
(BuiltinReceiver receiver) Evaluate the aggregation.void
call back function.String[]
get descriptions for the different argumentsint
getArity()
get the arity of the builtinget a description for the builtingetName()
get the name of the builtingetType()
get the type of the builtinlong
the weight of the builtin.void
initialize the builtinvoid
input
(long[] input) feed aggregation with input tupleboolean
isEvaluable
(BitSet grounds, BitSet variableInstantiations, Object[] args) is builtin evaluable with a certain instantiation of variablesboolean
is it a builtin for internal use onlyobjectGeneratingArguments
(BitSet grounds, BitSet variableInstantiations, Object[] args) In which argument position are new objects createdboolean
does the builtin read the symbol tablevoid
setProperties
(Properties prp) set the sytem propertiesvoid
setSymbolTable
(SymbolTable symbolTable) set the symbol tablevoid
start feeding the aggregation with input.void
stop()
stop feeding the aggregation with inputboolean
does the builtin write into the symbol table
-
Constructor Details
-
Compose
public Compose()
-
-
Method Details
-
setProperties
Description copied from interface:Builtin
set the sytem properties- Specified by:
setProperties
in interfaceBuiltin
- Parameters:
prp
- , properties
-
isEvaluable
public boolean isEvaluable(BitSet grounds, BitSet variableInstantiations, Object[] args) throws BuiltinException Description copied from interface:Builtin
is builtin evaluable with a certain instantiation of variables- Specified by:
isEvaluable
in interfaceBuiltin
- Parameters:
grounds
- , which arguments are groundvariableInstantiations
- , which variables are instantiatedargs
- , the arguments- Returns:
- was it evaluable
- Throws:
BuiltinException
-
init
Description copied from interface:Builtin
initialize the builtin- Specified by:
init
in interfaceBuiltin
- Parameters:
args
- , the builtin arguments- Throws:
InterruptedException
BuiltinException
-
evaluationFinished
Description copied from interface:Builtin
call back function. Is called when the whole evaluation has been finished- Specified by:
evaluationFinished
in interfaceBuiltin
- Throws:
BuiltinException
InterruptedException
-
setSymbolTable
Description copied from interface:Builtin
set the symbol table- Specified by:
setSymbolTable
in interfaceBuiltin
- Parameters:
symbolTable
- , the symbol table
-
getWeight
Description copied from interface:Builtin
the weight of the builtin. Determines when the builtin is executed in a rule -
objectGeneratingArguments
public BitSet objectGeneratingArguments(BitSet grounds, BitSet variableInstantiations, Object[] args) throws BuiltinException Description copied from interface:Builtin
In which argument position are new objects created- Specified by:
objectGeneratingArguments
in interfaceBuiltin
- Parameters:
grounds
- , ground argument positionsvariableInstantiations
- , instantiated variablesargs
- , arguments of the literal- Returns:
- each bit indicates the argument position where new objects are created
- Throws:
BuiltinException
-
getName
Description copied from interface:Builtin
get the name of the builtin -
getArity
public int getArity()Description copied from interface:Builtin
get the arity of the builtin -
getType
Description copied from interface:Builtin
get the type of the builtin -
isInternal
public boolean isInternal()Description copied from interface:Builtin
is it a builtin for internal use only- Specified by:
isInternal
in interfaceBuiltin
- Returns:
-
getArgumentDescriptions
Description copied from interface:Builtin
get descriptions for the different arguments- Specified by:
getArgumentDescriptions
in interfaceBuiltin
- Returns:
- a description of the arguments of the built-in
-
getDescription
Description copied from interface:Builtin
get a description for the builtin- Specified by:
getDescription
in interfaceBuiltin
- Returns:
- a description of the built-in
-
readsSymbolTable
public boolean readsSymbolTable()Description copied from interface:Builtin
does the builtin read the symbol table- Specified by:
readsSymbolTable
in interfaceBuiltin
- Returns:
- true if it reads the symbol table
-
writesSymbolTable
public boolean writesSymbolTable()Description copied from interface:Builtin
does the builtin write into the symbol table- Specified by:
writesSymbolTable
in interfaceBuiltin
- Returns:
- true if it writes to the symbol table
-
start
Description copied from interface:Aggregation
start feeding the aggregation with input. Grounds indicates which arguments are ground- Specified by:
start
in interfaceAggregation
- Parameters:
grounds
- , which arguments must be instantiated- Throws:
InterruptedException
ReasoningException
-
input
Description copied from interface:Aggregation
feed aggregation with input tuple- Specified by:
input
in interfaceAggregation
- Parameters:
input
- , the coded input tuple- Throws:
InterruptedException
ReasoningException
-
stop
Description copied from interface:Aggregation
stop feeding the aggregation with input- Specified by:
stop
in interfaceAggregation
- Throws:
InterruptedException
ReasoningException
-
evaluate
public void evaluate(BuiltinReceiver receiver) throws InterruptedException, SemReasonerException, IOException Description copied from interface:Aggregation
Evaluate the aggregation.
For every result tuple the method "send" in receiver is called- Specified by:
evaluate
in interfaceAggregation
- Parameters:
receiver
- , the receiver getting the results- Throws:
InterruptedException
SemReasonerException
IOException
-
cloneBuiltin
Description copied from interface:Builtin
clone the builtin- Specified by:
cloneBuiltin
in interfaceBuiltin
- Returns:
- the cloned built-in
-
deliversOneResultOnly
public boolean deliversOneResultOnly()Description copied from interface:Aggregation
aggregation delivers only one result at argument position.
For instance count delivers one result at argument position 1.- Specified by:
deliversOneResultOnly
in interfaceAggregation
- Returns:
- true if it delivers one result only
-
clear
public void clear()Description copied from interface:Builtin
frees up allocated resources
-