dstruct
Class StatOperator

java.lang.Object
  extended by java.lang.Thread
      extended by dstruct.StatOperator
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable
Direct Known Subclasses:
COREFOperator, CRFOperator, LROperator, TUFFYOperator

public abstract class StatOperator
extends java.lang.Thread
implements java.lang.Cloneable

Abstract class of a statistical operator (e.g., Tuffy, Coref, CRF etc. ). A valid Felix operator should extend this class and implement methods like run(), prepare(), etc.

Author:
Ce Zhang

Nested Class Summary
static class StatOperator.OPType
          Type of StatOperator.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.util.List<DataMovementOperator> allDMOs
          All DataMovementOperators used in this statistical operator.
 java.util.HashSet<FelixClause> allRelevantFelixClause
          Set of clauses assigned to this operator.
 ConcurrentOperatorsBucket belongsToBucket
          The ConcurrentOperatorsBucket this StatOperator belongs to.
 java.util.HashMap<FelixClause,java.util.HashSet<mln.Expression>> clauseConstraints
          Map from clauses to expressions partitioning the data.
(package private)  int currentRunTime
          How many times this operator has run.
 java.lang.String dataCrackerSignature
          The human-readable representation of data partitions.
 db.RDB db
          Database connection.
 FelixQuery fq
          Felix query.
(package private)  int id
          ID of this operator.
(package private) static int idCounter
          Global counter of StatOperators ID.
 java.util.HashSet<FelixPredicate> inputPredicates
          Set of predicates whose values are used by this operator as inputs.
 boolean isMarginal
          Whether this operator works in marginal or MAP mode.
(package private)  int maxRunTime
          Max time this operator can run.
protected  parser.CommandOptions options
          Options parsed from command line or configuration file.
 java.util.HashSet<FelixPredicate> outputPredicates
          Set of predicates whose values are output by this operator.
 int partitionedInto
          Parameter assigning the degree of data partitioning.
protected  int precedence
          The precedence of this operator.
 StatOperator.OPType type
          Type of this operator.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StatOperator(FelixQuery _fq, java.util.HashSet<FelixPredicate> _goalPredicates, parser.CommandOptions _opt)
          the constructor.
 
Method Summary
 StatOperator clone()
           
abstract  java.lang.String explain()
          Human-readable representation of the logic plan.
 java.util.List<DataMovementOperator> getAllDMOs()
          Get all DMOs used by this operator.
 int getPrecedence()
          Get the precedence of this operator.
 FelixPredicate getTargetPredicateIfHasOnlyOne()
          Get the target predicate of this StatOperator if this operator is CRF, LR or COREF.
abstract  void prepare()
          Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference.
abstract  void run()
          Method that executes this operator.
 java.lang.String toString()
           
 java.util.HashSet<mln.ConjunctiveQuery> translateFelixClasesIntoFactorGraphEdgeQueries(FelixPredicate target, boolean forceRecursive, FelixPredicate.FPProperty... props)
          Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

partitionedInto

public int partitionedInto
Parameter assigning the degree of data partitioning.


dataCrackerSignature

public java.lang.String dataCrackerSignature
The human-readable representation of data partitions. This is only used in toString()


clauseConstraints

public java.util.HashMap<FelixClause,java.util.HashSet<mln.Expression>> clauseConstraints
Map from clauses to expressions partitioning the data.


belongsToBucket

public ConcurrentOperatorsBucket belongsToBucket
The ConcurrentOperatorsBucket this StatOperator belongs to. StatOperators in one ConcurrentOperatorsBucket can be executed in parallel.


isMarginal

public boolean isMarginal
Whether this operator works in marginal or MAP mode.


options

protected parser.CommandOptions options
Options parsed from command line or configuration file.


maxRunTime

int maxRunTime
Max time this operator can run. This parameter will be useful when there are cycles in the operator graph.


currentRunTime

int currentRunTime
How many times this operator has run.


idCounter

static int idCounter
Global counter of StatOperators ID.


id

int id
ID of this operator. Note that, the statistical operator returned by .clone() has a different ID.


type

public StatOperator.OPType type
Type of this operator.


inputPredicates

public java.util.HashSet<FelixPredicate> inputPredicates
Set of predicates whose values are used by this operator as inputs.


outputPredicates

public java.util.HashSet<FelixPredicate> outputPredicates
Set of predicates whose values are output by this operator.


allRelevantFelixClause

public java.util.HashSet<FelixClause> allRelevantFelixClause
Set of clauses assigned to this operator.


db

public db.RDB db
Database connection.


fq

public FelixQuery fq
Felix query.


precedence

protected int precedence
The precedence of this operator. The larger this value, the earlier this operator will be ran in the final physical plan.


allDMOs

protected java.util.List<DataMovementOperator> allDMOs
All DataMovementOperators used in this statistical operator.

Constructor Detail

StatOperator

public StatOperator(FelixQuery _fq,
                    java.util.HashSet<FelixPredicate> _goalPredicates,
                    parser.CommandOptions _opt)
the constructor.

Parameters:
_oriMLN -
_opt -
Method Detail

clone

public StatOperator clone()
Overrides:
clone in class java.lang.Object

prepare

public abstract void prepare()
Generate the operator-specified logic plan, i.e., all data movement operators that will be used for inference. This function should be invoked after a new instance of operator is created. Any valid Felix operator should implement this method.


run

public abstract void run()
Method that executes this operator. Any valid Felix operator should implement this method.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

explain

public abstract java.lang.String explain()
Human-readable representation of the logic plan. Any valid Felix operator should implement this method. TODO: need to think out a better to explain physical plan. (e.g., a graph?)


getTargetPredicateIfHasOnlyOne

public FelixPredicate getTargetPredicateIfHasOnlyOne()
Get the target predicate of this StatOperator if this operator is CRF, LR or COREF.

Returns:

translateFelixClasesIntoFactorGraphEdgeQueries

public java.util.HashSet<mln.ConjunctiveQuery> translateFelixClasesIntoFactorGraphEdgeQueries(FelixPredicate target,
                                                                                              boolean forceRecursive,
                                                                                              FelixPredicate.FPProperty... props)
Given a first order logic clause and a target predicate, translate it into a conjunctive query with properly assigned weight.

Parameters:
target -
forceRecursive - If there are multiple literals of the given predicate, this parameter specifies whether the generated conjunctive queries are recursive. CRF will set this parameter as FALSE, while COREF will set it as TRUE.
props - The property selected for the target predicate.
Returns:

getAllDMOs

public java.util.List<DataMovementOperator> getAllDMOs()
Get all DMOs used by this operator.

Returns:

getPrecedence

public int getPrecedence()
Get the precedence of this operator.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread