felix.dstruct
Class FelixQuery

java.lang.Object
  extended by felix.dstruct.FelixQuery

public class FelixQuery
extends java.lang.Object

An object of FelixQuery consists of program, query and evidence from inputs.

Author:
Ce Zhang

Field Summary
 java.util.HashMap<java.lang.Integer,FelixClause> id2clause
          Map from integer IDs to clauses
 boolean loadingEvid
          Whether we consider the evidence file while parsing operators.
 java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Integer> mapConstantID
          Map from constant to constant ID.
 java.util.concurrent.ConcurrentHashMap<java.lang.Integer,java.lang.String> mapIDConstant
          Map from constant ID to constant.
 java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Integer> newMapConstantID
          Deprecated.  
 
Constructor Summary
FelixQuery()
           
 
Method Summary
 int addConstant(java.lang.String symbol)
          Add a constant to FelixQuery.
 void addDatalogRule(tuffy.ra.ConjunctiveQuery dr)
          Add a Datalog rule to FelixQuery.
 void addFelixClause(FelixClause fc)
          Add a clause to FelixQuery.
 void addFelixPredicate(FelixPredicate fp)
          Add a predicate to FelixQuery.
 void addScopingRule(tuffy.ra.ConjunctiveQuery sr)
          Add a scoping rule to FelixQuery.
 void closeFiles()
          Close all predicate's loadingFile.
 void executeAllDatalogRules(tuffy.db.RDB db)
          Execute all Datalog rules.
 java.util.HashSet<FelixClause> getAllClause()
          Get all clauses in this FelixQuery.
 java.util.HashSet<FelixPredicate> getAllOpenPred()
          Get all predicates which are open in this FelixQuery.
 java.util.HashSet<FelixPredicate> getAllPred()
          Get all predicates in this FelixQuery.
 tuffy.ra.Function getFunctionByName(java.lang.String name)
          Get function by name.
 tuffy.mln.Type getOrCreateTypeByName(java.lang.String name)
          Get or create type by name.
 FelixPredicate getPredByName(java.lang.String name)
          Get predicate by name.
 java.util.ArrayList<FelixPredicate> getPredicates()
          Get all predicates.
 java.util.ArrayList<tuffy.ra.ConjunctiveQuery> getScopingRules()
          Get all scoping rules.
 java.util.ArrayList<tuffy.ra.ConjunctiveQuery> getSpecialClusteringRules(java.lang.String _predName)
          Get Class and Tag rules for clustering predicates.
 int getSymbolID(java.lang.String symbol, tuffy.mln.Type type)
          Get or add (if not exists) a symbol to a type's constant table.
 void loadEvidences(java.lang.String[] evidFiles)
          Load MLN evidences.
 void loadPrograms(java.lang.String[] progFiles)
          Load MLN programs.
 void loadQueries(java.lang.String[] queryFiles)
          Load MLN queries.
 void materializeTables(tuffy.db.RDB db)
          Materialize database tables.
 void parseProgFromString(java.lang.String prog)
          Load MLN queries specified by command lines.
 void parseQueryCommaList(java.lang.String queryAtoms)
          Load MLN queries specified by command lines.
 void registerClusteringRule(tuffy.ra.ConjunctiveQuery cq)
          Add Class or Tag rules for clustering predicates.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id2clause

public java.util.HashMap<java.lang.Integer,FelixClause> id2clause
Map from integer IDs to clauses


mapConstantID

public java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Integer> mapConstantID
Map from constant to constant ID.


mapIDConstant

public java.util.concurrent.ConcurrentHashMap<java.lang.Integer,java.lang.String> mapIDConstant
Map from constant ID to constant.


newMapConstantID

public java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Integer> newMapConstantID
Deprecated. 

loadingEvid

public boolean loadingEvid
Whether we consider the evidence file while parsing operators.

Constructor Detail

FelixQuery

public FelixQuery()
Method Detail

addFelixClause

public void addFelixClause(FelixClause fc)
Add a clause to FelixQuery.

Parameters:
fc -

addFelixPredicate

public void addFelixPredicate(FelixPredicate fp)
Add a predicate to FelixQuery.

Parameters:
fp -

getScopingRules

public java.util.ArrayList<tuffy.ra.ConjunctiveQuery> getScopingRules()
Get all scoping rules.

Returns:

addScopingRule

public void addScopingRule(tuffy.ra.ConjunctiveQuery sr)
Add a scoping rule to FelixQuery.

Parameters:
sr -

addDatalogRule

public void addDatalogRule(tuffy.ra.ConjunctiveQuery dr)
Add a Datalog rule to FelixQuery.

Parameters:
dr -

getPredByName

public FelixPredicate getPredByName(java.lang.String name)
Get predicate by name.

Parameters:
name -
Returns:

getPredicates

public java.util.ArrayList<FelixPredicate> getPredicates()
Get all predicates.

Returns:

getOrCreateTypeByName

public tuffy.mln.Type getOrCreateTypeByName(java.lang.String name)
Get or create type by name.

Parameters:
name -
Returns:

getFunctionByName

public tuffy.ra.Function getFunctionByName(java.lang.String name)
Get function by name.

Parameters:
name -
Returns:

addConstant

public int addConstant(java.lang.String symbol)
Add a constant to FelixQuery.

Parameters:
symbol -
Returns:

getSymbolID

public int getSymbolID(java.lang.String symbol,
                       tuffy.mln.Type type)
Get or add (if not exists) a symbol to a type's constant table.

Parameters:
symbol -
type -
Returns:

loadPrograms

public void loadPrograms(java.lang.String[] progFiles)
Load MLN programs.

Parameters:
progFiles -

loadQueries

public void loadQueries(java.lang.String[] queryFiles)
Load MLN queries.

Parameters:
queryFiles -

parseQueryCommaList

public void parseQueryCommaList(java.lang.String queryAtoms)
Load MLN queries specified by command lines.

Parameters:
queryAtoms -

parseProgFromString

public void parseProgFromString(java.lang.String prog)
Load MLN queries specified by command lines.

Parameters:
queryAtoms -

closeFiles

public void closeFiles()
Close all predicate's loadingFile.


getAllPred

public java.util.HashSet<FelixPredicate> getAllPred()
Get all predicates in this FelixQuery.

Returns:

getAllOpenPred

public java.util.HashSet<FelixPredicate> getAllOpenPred()
Get all predicates which are open in this FelixQuery.

Returns:

getAllClause

public java.util.HashSet<FelixClause> getAllClause()
Get all clauses in this FelixQuery.

Returns:

loadEvidences

public void loadEvidences(java.lang.String[] evidFiles)
                   throws java.lang.InterruptedException
Load MLN evidences.

Parameters:
evidFiles -
Throws:
java.lang.InterruptedException

materializeTables

public void materializeTables(tuffy.db.RDB db)
Materialize database tables.

Parameters:
db -

executeAllDatalogRules

public void executeAllDatalogRules(tuffy.db.RDB db)
Execute all Datalog rules.

Parameters:
db -

getSpecialClusteringRules

public java.util.ArrayList<tuffy.ra.ConjunctiveQuery> getSpecialClusteringRules(java.lang.String _predName)
Get Class and Tag rules for clustering predicates.

Parameters:
_predName -
Returns:

registerClusteringRule

public void registerClusteringRule(tuffy.ra.ConjunctiveQuery cq)
Add Class or Tag rules for clustering predicates.

Parameters:
cq -