chord.bddbddb
Class Rel

java.lang.Object
  extended by chord.bddbddb.Rel
Direct Known Subclasses:
ProgramRel

public class Rel
extends java.lang.Object

Generic implementation of a BDD-based relation.

Typical usage is as follows:

Note: Much of the BDD-related code in this class is adapted from bddbddb.

Author:
Mayur Naik (mhn@cs.stanford.edu)

Nested Class Summary
 class Rel.AryNIterable
           
 class Rel.HextIterable<T0,T1,T2,T3,T4,T5>
           
 class Rel.IntAryNIterable
           
 class Rel.IntHextIterable
           
 class Rel.IntPairIterable
           
 class Rel.IntPentIterable
           
 class Rel.IntQuadIterable
           
 class Rel.IntTrioIterable
           
 class Rel.PairIterable<T0,T1>
           
 class Rel.PentIterable<T0,T1,T2,T3,T4>
           
 class Rel.QuadIterable<T0,T1,T2,T3>
           
 class Rel.RelView
          An immutable view of a relation.
 class Rel.SelfIterable<T>
           
 class Rel.TrioIterable<T0,T1,T2>
           
 class Rel.TupleIterator<T>
           
 
Field Summary
protected  net.sf.javabdd.BDD bdd
           
protected  net.sf.javabdd.BDDDomain[] domBdds
           
protected  int[] domIdxs
           
protected  Dom[] doms
           
protected  net.sf.javabdd.BDDFactory factory
           
protected  net.sf.javabdd.BDD iterBdd
           
protected  java.lang.String name
           
protected  int numDoms
           
protected  RelSign sign
           
 
Constructor Summary
Rel()
           
 
Method Summary
 void add(int idx0)
           
 void add(int[] idxs)
           
 void add(int idx0, int idx1)
           
 void add(int idx0, int idx1, int idx2)
           
 void add(int idx0, int idx1, int idx2, int idx3)
           
 void add(int idx0, int idx1, int idx2, int idx3, int idx4)
           
 void add(int idx0, int idx1, int idx2, int idx3, int idx4, int idx5)
           
 void add(java.lang.Object[] vals)
           
<T0> void
add(T0 val0)
           
<T0,T1> void
add(T0 val0, T1 val1)
           
<T0,T1,T2> void
add(T0 val0, T1 val1, T2 val2)
           
<T0,T1,T2,T3>
void
add(T0 val0, T1 val1, T2 val2, T3 val3)
           
<T0,T1,T2,T3,T4>
void
add(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4)
           
<T0,T1,T2,T3,T4,T5>
void
add(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4, T5 val5)
           
protected  void checkRange(int idx, int domIdx)
           
protected  void checkRange(java.lang.Object val, int domIdx)
           
 void close()
          Frees this relation from memory.
 boolean contains(int idx0)
           
 boolean contains(int idx0, int idx1)
           
 boolean contains(java.lang.Object[] vals)
           
<T0> boolean
contains(T0 val0)
           
<T0,T1> boolean
contains(T0 val0, T1 val1)
           
<T0,T1,T2> boolean
contains(T0 val0, T1 val1, T2 val2)
           
<T0,T1,T2,T3>
boolean
contains(T0 val0, T1 val1, T2 val2, T3 val3)
           
<T0,T1,T2,T3,T4>
boolean
contains(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4)
           
<T0,T1,T2,T3,T4,T5>
boolean
contains(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4, T5 val5)
           
<T0> java.lang.Iterable<T0>
getAry1ValTuples()
           
 Rel.IntPairIterable getAry2IntTuples()
           
<T0,T1> Rel.PairIterable<T0,T1>
getAry2ValTuples()
           
 Rel.IntTrioIterable getAry3IntTuples()
           
<T0,T1,T2> Rel.TrioIterable<T0,T1,T2>
getAry3ValTuples()
           
 Rel.IntQuadIterable getAry4IntTuples()
           
<T0,T1,T2,T3>
Rel.QuadIterable<T0,T1,T2,T3>
getAry4ValTuples()
           
 Rel.IntPentIterable getAry5IntTuples()
           
<T0,T1,T2,T3,T4>
Rel.PentIterable<T0,T1,T2,T3,T4>
getAry5ValTuples()
           
 Rel.IntHextIterable getAry6IntTuples()
           
<T0,T1,T2,T3,T4,T5>
Rel.HextIterable<T0,T1,T2,T3,T4,T5>
getAry6ValTuples()
           
 Rel.IntAryNIterable getAryNIntTuples()
           
 Rel.AryNIterable getAryNValTuples()
           
 Dom[] getDoms()
           
 java.lang.String getName()
          Provides the name of this relation.
 RelSign getSign()
          Provides the signature of this relation.
 Rel.RelView getView()
          Provides a fresh view of the relation.
protected  void initialize()
           
 boolean isOpen()
          Determines whether the relation in memory is initialized.
 void load(java.lang.String dirName)
          Copies this relation from disk to memory.
 void one()
          Sets this relation in memory to the full relation (containing all tuples).
 void print()
           
 void print(java.io.PrintStream out)
           
 void print(java.lang.String dirName)
           
 void remove(int idx0)
           
 void remove(int idx0, int idx1)
           
<T0> void
remove(T0 val0)
           
<T0,T1> void
remove(T0 val0, T1 val1)
           
 void save(java.lang.String dirName)
          Copies the relation from memory to disk and frees it from memory.
 void setDoms(Dom[] doms)
          Sets the domains of this relation.
 void setName(java.lang.String name)
          Sets the name of this relation.
 void setSign(RelSign sign)
          Sets the signature of this relation.
 void setSign(java.lang.String[] domNames, java.lang.String domOrder)
          Sets the signature of this relation.
 void setSign(java.lang.String domNames, java.lang.String domOrder)
          Sets the signature of this relation.
 int size()
          Provides the size of the relation.
 void zero()
          Sets this relation in memory to the empty relation (containing no tuples).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

sign

protected RelSign sign

doms

protected Dom[] doms

numDoms

protected int numDoms

factory

protected net.sf.javabdd.BDDFactory factory

domIdxs

protected int[] domIdxs

domBdds

protected net.sf.javabdd.BDDDomain[] domBdds

bdd

protected net.sf.javabdd.BDD bdd

iterBdd

protected net.sf.javabdd.BDD iterBdd
Constructor Detail

Rel

public Rel()
Method Detail

setName

public void setName(java.lang.String name)
Sets the name of this relation. The name must be set only once.

Parameters:
name - The name of this relation.

getName

public java.lang.String getName()
Provides the name of this relation.

Returns:
The name of this relation.

setSign

public void setSign(java.lang.String domNames,
                    java.lang.String domOrder)
Sets the signature of this relation. The signature must be set only once.

Parameters:
domNames - An ordered list of comma-separated domain names of this relation.
domOrder - The BDD ordering of the domain names.

setSign

public void setSign(java.lang.String[] domNames,
                    java.lang.String domOrder)
Sets the signature of this relation. The signature must be set only once.

Parameters:
domNames - An ordered list of domain names of this relation.
domOrder - The BDD ordering of the domain names.

setSign

public void setSign(RelSign sign)
Sets the signature of this relation. The signature must be set only once.

Parameters:
sign - The signature of this relation.

getSign

public RelSign getSign()
Provides the signature of this relation.

Returns:
The signature of this relation.

getDoms

public Dom[] getDoms()

setDoms

public void setDoms(Dom[] doms)
Sets the domains of this relation. The domains must be set only once.

The signature of the relation must be set before the domains are set.

The contents of the domains need not be uptodate when this method is called. The contents of the domains are used only when the contents of this relation are initialized (by calling one of methods one(), zero(), and load(String)).

Parameters:
doms - The domains of this relation.

initialize

protected void initialize()

one

public void one()
Sets this relation in memory to the full relation (containing all tuples).


zero

public void zero()
Sets this relation in memory to the empty relation (containing no tuples).


load

public void load(java.lang.String dirName)
Copies this relation from disk to memory.


close

public void close()
Frees this relation from memory.


save

public void save(java.lang.String dirName)
Copies the relation from memory to disk and frees it from memory.


print

public void print(java.lang.String dirName)

getView

public Rel.RelView getView()
Provides a fresh view of the relation.

Returns:
A fresh view of the relation.

checkRange

protected void checkRange(java.lang.Object val,
                          int domIdx)

checkRange

protected void checkRange(int idx,
                          int domIdx)

isOpen

public boolean isOpen()
Determines whether the relation in memory is initialized.

Returns:
true iff the relation in memory is initialized.

size

public int size()
Provides the size of the relation.

Returns:
The size of the relation.

add

public <T0> void add(T0 val0)

add

public void add(int idx0)

remove

public <T0> void remove(T0 val0)

remove

public void remove(int idx0)

contains

public <T0> boolean contains(T0 val0)

contains

public boolean contains(int idx0)

getAry1ValTuples

public <T0> java.lang.Iterable<T0> getAry1ValTuples()

add

public <T0,T1> void add(T0 val0,
                        T1 val1)

add

public void add(int idx0,
                int idx1)

remove

public <T0,T1> void remove(T0 val0,
                           T1 val1)

remove

public void remove(int idx0,
                   int idx1)

contains

public <T0,T1> boolean contains(T0 val0,
                                T1 val1)

contains

public boolean contains(int idx0,
                        int idx1)

getAry2ValTuples

public <T0,T1> Rel.PairIterable<T0,T1> getAry2ValTuples()

getAry2IntTuples

public Rel.IntPairIterable getAry2IntTuples()

add

public <T0,T1,T2> void add(T0 val0,
                           T1 val1,
                           T2 val2)

add

public void add(int idx0,
                int idx1,
                int idx2)

contains

public <T0,T1,T2> boolean contains(T0 val0,
                                   T1 val1,
                                   T2 val2)

getAry3ValTuples

public <T0,T1,T2> Rel.TrioIterable<T0,T1,T2> getAry3ValTuples()

getAry3IntTuples

public Rel.IntTrioIterable getAry3IntTuples()

add

public <T0,T1,T2,T3> void add(T0 val0,
                              T1 val1,
                              T2 val2,
                              T3 val3)

add

public void add(int idx0,
                int idx1,
                int idx2,
                int idx3)

contains

public <T0,T1,T2,T3> boolean contains(T0 val0,
                                      T1 val1,
                                      T2 val2,
                                      T3 val3)

getAry4ValTuples

public <T0,T1,T2,T3> Rel.QuadIterable<T0,T1,T2,T3> getAry4ValTuples()

getAry4IntTuples

public Rel.IntQuadIterable getAry4IntTuples()

add

public <T0,T1,T2,T3,T4> void add(T0 val0,
                                 T1 val1,
                                 T2 val2,
                                 T3 val3,
                                 T4 val4)

add

public void add(int idx0,
                int idx1,
                int idx2,
                int idx3,
                int idx4)

contains

public <T0,T1,T2,T3,T4> boolean contains(T0 val0,
                                         T1 val1,
                                         T2 val2,
                                         T3 val3,
                                         T4 val4)

getAry5ValTuples

public <T0,T1,T2,T3,T4> Rel.PentIterable<T0,T1,T2,T3,T4> getAry5ValTuples()

getAry5IntTuples

public Rel.IntPentIterable getAry5IntTuples()

add

public <T0,T1,T2,T3,T4,T5> void add(T0 val0,
                                    T1 val1,
                                    T2 val2,
                                    T3 val3,
                                    T4 val4,
                                    T5 val5)

add

public void add(int idx0,
                int idx1,
                int idx2,
                int idx3,
                int idx4,
                int idx5)

contains

public <T0,T1,T2,T3,T4,T5> boolean contains(T0 val0,
                                            T1 val1,
                                            T2 val2,
                                            T3 val3,
                                            T4 val4,
                                            T5 val5)

getAry6ValTuples

public <T0,T1,T2,T3,T4,T5> Rel.HextIterable<T0,T1,T2,T3,T4,T5> getAry6ValTuples()

getAry6IntTuples

public Rel.IntHextIterable getAry6IntTuples()

add

public void add(java.lang.Object[] vals)

add

public void add(int[] idxs)

contains

public boolean contains(java.lang.Object[] vals)

getAryNValTuples

public Rel.AryNIterable getAryNValTuples()

getAryNIntTuples

public Rel.IntAryNIterable getAryNIntTuples()

print

public void print()

print

public void print(java.io.PrintStream out)