Interface BaseRelation

All Known Subinterfaces:
Relation
All Known Implementing Classes:
CrossProductBaseRelation, MainMemoryBaseRelation, MainMemoryRelation, MainMemorySubRelation, MixedRelation, OneToOneBaseRelation, PersistentRelation, ReasoningMonitorRelation, RelationAdapter

public interface BaseRelation
A relation is a set of tuples, i.e. a container for facts.
Facts are encoded which means that a relation contains tuples of long codes.
The terms for the codes may be found in the symbol table.
Author:
angele
  • Method Details

    • getArity

      int getArity()
      returns the arity of the relation
      Returns:
      arity of relation
    • getInternalArity

      int getInternalArity()
      returns the internal arity of tuples
      Returns:
    • select

      void select() throws IOException, EDBException
      initialize
      Throws:
      EDBException
      IOException
    • elements

      returns an enumerator for all tuples
      Returns:
      returns enumerator for tuples
      Throws:
      IOException
      EDBException
    • elements

      TupleEnumerator elements(long[] filter) throws IOException, EDBException
      returns an filteres enumerator for all tuples
      Returns:
      returns enumerator for tuples
      Throws:
      IOException
      EDBException
    • size

      long size() throws IOException, EDBException
      returns the number of tuples in relation
      Returns:
      number of tuples in relation
      Throws:
      IOException
      EDBException
    • createSortedIndex

      SortedIndex createSortedIndex(int[] indexedpositions) throws IOException, EDBException
      ret or create a sorted index given by the argument positions in indexed positions
      Parameters:
      indexedpositions -
      Returns:
      Throws:
      IOException
      EDBException
    • getSortedIndex

      SortedIndex getSortedIndex(int[] indexedpositions)
      Get a sorted index given by the argument positions in indexed positions (if it already exists).
      Returns null if it does not exist.
      Parameters:
      indexedpositions - the indexed positions
      Returns:
      the corresponding index or null if none is available
    • createIndex

      Index createIndex(int[] indexedpositions) throws IOException, EDBException
      Get or create a simple (not sorted index) by the argument positions in indexed positions.
      Parameters:
      indexedpositions - , positions which are indexed
      Returns:
      index
      Throws:
      IOException
      EDBException
    • getIndex

      Index getIndex(int[] indexedpositions)
      Get an index given by the argument positions in indexed positions (if it already exists).
      Returns null if it does not exist.
      Parameters:
      indexedpositions - the indexed positions
      Returns:
      the corresponding index or null if none is available
    • getIdentifier

      String getIdentifier()
      returns a unique identifier for the relation
      Returns:
      unique identifier for relation
    • clear

      void clear() throws IOException, EDBException
      remove all tuples
      Throws:
      IOException
      EDBException
    • isEmpty

      boolean isEmpty() throws IOException
      Is the relation empty?
      Returns:
      relation is empty
      Throws:
      IOException
    • isPersistent

      boolean isPersistent()
      Is the relation persistent?
      Returns:
      is the relation persistent
    • isTemporary

      boolean isTemporary()
      Is the relation temporary only?
      Returns:
      is the relation persistent
    • close

      void close() throws IOException, EDBException
      Close the relation. Must be called to finalize the relation correctly
      Throws:
      IOException
      EDBException
    • flush

      void flush() throws IOException, EDBException
      Flush the relation. Must be called to finalize the relation correctly
      Throws:
      IOException
      EDBException
    • getCacheInfo

      CacheInfo getCacheInfo()
      get the caching info
      Returns:
      object containing caching info
    • containsTuple

      boolean containsTuple(int tuple) throws IOException
      Is tuple contained in relation?
      Parameters:
      tuple - to be checked
      Returns:
      tuple is contained
      Throws:
      IOException
    • containsTuple

      boolean containsTuple(TupleBuffer tuple) throws IOException
      Is tuple contained in relation?
      Parameters:
      tuple - to be checked
      Returns:
      tuple is contained
      Throws:
      IOException
    • containsTuple

      boolean containsTuple(long[] tuple) throws IOException
      Is tuple contained in relation?
      Parameters:
      tuple - to be checked
      Returns:
      tuple is contained
      Throws:
      IOException
    • addTuple

      boolean addTuple(TupleBuffer tuple) throws IOException, EDBException
      add a tuple to the relation
      Parameters:
      tuple - the tuple to add
      Returns:
      tuple has been added
      Throws:
      IOException
      EDBException
    • addTuple

      boolean addTuple(long[] tuple) throws IOException, EDBException
      add a tuple to the relation
      Parameters:
      tuple - the tuple to add
      Returns:
      tuple has been added
      Throws:
      IOException
      EDBException
    • addTuple

      boolean addTuple(int tuple) throws IOException, EDBException
      add a tuple to the relation
      Parameters:
      tuple - the tuple to add
      Returns:
      tuple has been added
      Throws:
      IOException
      EDBException
    • removeTuple

      boolean removeTuple(int tuple) throws IOException, EDBException
      remove a tuple from the relation
      Parameters:
      tuple - , address of tuple in tuple store
      Returns:
      true, if tuple has been removed
      Throws:
      IOException
      EDBException
    • removeTuple

      boolean removeTuple(TupleBuffer tuple) throws IOException, EDBException
      remove a tuple from the relation
      Parameters:
      tuple - , tuple to be removed
      Returns:
      true, if tuple has been removed
      Throws:
      IOException
      EDBException
    • removeTuple

      boolean removeTuple(long[] tuple) throws IOException, EDBException
      remove a tuple from the relation
      Parameters:
      tuple - , tuple to be removed
      Returns:
      true, if tuple has been removed
      Throws:
      IOException
      EDBException
    • overwriteTuple

      long[] overwriteTuple(long[] tuple) throws IOException, EDBException
      Overwrite last argument of tuple.
      First arguments are unique keys for tuple
      Especially useful for triples [subject,predicate,object]
      and object is changed
      Parameters:
      tuple - , overwrite tuple
      Returns:
      the overwritten tuple
      Throws:
      IOException
      EDBException
    • overwriteTuple

      TupleBuffer overwriteTuple(TupleBuffer tuple) throws IOException, EDBException
      Overwrite last argument of tuple.
      First arguments are unique keys for tuple
      Especially useful for triples [subject,predicate,object]
      and object is changed
      Parameters:
      tuple - , overwrite tuple
      Returns:
      the overwritten tuple
      Throws:
      IOException
      EDBException
    • isOverwrittenByTuple

      long[] isOverwrittenByTuple(long[] tuple) throws IOException, EDBException
      returns the tuple which will be overwritten by tuple.
      Parameters:
      tuple -
      Returns:
      Throws:
      IOException
      EDBException
    • getInputBuffer

      TupleStore getInputBuffer()
      get an input buffer for relation
      Returns:
      a tuple store which serves as buffer for input tuples
    • sizeInBytes

      long sizeInBytes()
      Return the size in bytes in main memory. Used for cache management
      Returns:
      approximate number of size in bytes
    • writeBinary

      void writeBinary(String filepath) throws IOException, EDBException
      write tuples in binary form to file
      Parameters:
      filepath -
      Throws:
      IOException
      EDBException
    • readTupleFile

      void readTupleFile(String filepath) throws IOException, EDBException
      read tuples from a file in binary form
      Parameters:
      filepath - , the file path to read from
      Throws:
      IOException
      EDBException
    • getMinValue

      long getMinValue(int argument) throws IOException, EDBException
      returns the minimal value at that argument position
      Parameters:
      argument - , argument position @return, minimal value
      Throws:
      IOException
      EDBException
    • getMaxValue

      long getMaxValue(int argument) throws IOException, EDBException
      returns the maximal value at that argument position
      Parameters:
      argument - , argument position
      Returns:
      max value at argument position
      Throws:
      IOException
      EDBException
    • lastModificationTime

      long lastModificationTime()
      returns the time of last modification
      Returns:
      time of last modification
    • mayContainDuplicates

      boolean mayContainDuplicates()
      Might there be duplicates?
      Returns:
      , might there be duplicates in relation
    • isDirectEncoded

      boolean isDirectEncoded(int i)
      are all values at argument i direct encoded
      Parameters:
      i - , argument index
      Returns:
    • getDirectEncodedType

      int getDirectEncodedType(int i)
      get the type of the direct encoded argument
      Parameters:
      i -
      Returns:
    • registerListener

      void registerListener(RelationListener listener)
      register a listener for adding, removing, modifying tuples
      Parameters:
      listener -
    • union

      void union(BaseRelation R) throws IOException, EDBException
      add all tuples of R to this
      Parameters:
      R -
      Throws:
      IOException
      EDBException
    • hasDuplicates

      boolean hasDuplicates()
      may relation contain duplicates?
      Returns: