Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.db
Class GraphRDB

    java.lang.Object
      com.hp.hpl.jena.graph.impl.GraphBase
          com.hp.hpl.jena.db.GraphRDB

All Implemented Interfaces:
  Graph, GraphAdd, com.hp.hpl.jena.graph.impl.GraphWithPerform

    public class GraphRDB

extends com.hp.hpl.jena.graph.impl.GraphBase
implements Graph

A persistent Graph implementation using a relational database for storage.

This graph stores data persistently in a relational database. It supports the full Graph interface and should operate just like a GraphMem.

Internally, each GraphRDB keeps a list of specialized graphs. For each operation, it works through the list of graphs attempting to perform the operation on each one.

The intention is that each type of specialized graph is optimized for a different type of triple. For example, one type of specialied graph might be optimized for storing triples in a particular ontology. The last specialized graph in the list is always a generic one that can handle any valid RDF triple.

The order of the specialized graphs is consistent and immutable after the graph is constructed. This aids optimization. For example, if a specialized graph is asked to perform an operatin on a triple, and it knows that it would have added it if asked, then it can advise the calling GraphRDB that the operaton is complete even though it doesn't know anything about other specialized graphs later in the list.

Since:
  Jena 2.0
Version:
  $Revision: 1.49 $
Author:
  csayers (based in part on GraphMem by bwm).

Field Summary
`static java.lang.String` | `DEFAULT` The name used for the default graph.
`static int` | `OPTIMIZE_ALL_REIFICATIONS_AND_HIDE_NOTHING` Optimize all triples representing part or all of a reified statement; this is the recommended option.
`static int` | `OPTIMIZE_AND_HIDE_FULL_AND_PARTIAL_REIFICATIONS` Optimize and hide any triples representing part or all of a reified statement.
`static int` | `OPTIMIZE_AND_HIDE_ONLY_FULL_REIFICATIONS` Optimize and hide only fully reified statements added via the Reifier interface, use only for backward-compatability with Jena1.

Fields inherited from interface com.hp.hpl.jena.graph.Graph
`emptyGraph`

Constructor Summary
`GraphRDB(IDBConnection con, java.lang.String graphID, Graph requestedProperties, boolean isNew)` Deprecated. Please use the alternate constructor and choose the desired reification behaviour.
`GraphRDB(IDBConnection con, java.lang.String graphID, Graph requestedProperties, int reificationBehaviour, boolean isNew)` Construct a new GraphRDB

Method Summary
`void` | `add(java.util.List triples)` Add a list of triples.
`void` | `clear()` Remove all statements from this graph.
`void` | `close()` Close this graph.
`com.hp.hpl.jena.db.impl.DBQueryHandler` | `DBqueryHandler()`
`void` | `delete(java.util.List triples)` Delete a list of triples.
`BulkUpdateHandler` | `getBulkUpdateHandler()` Answer a BulkUpdateHandler bound to this graph.
`Capabilities` | `getCapabilities()` Database graphs do not presently support the equivalence of plain string literals and xsd:string literals (and other typed literals in general).
`IDBConnection` | `getConnection()` Return the connection
`boolean` | `getDoDuplicateCheck()` Get the value of DoDuplicateCheck
`boolean` | `getDoFastpath()` Get the value of DoFastpath.
`Node` | `getNode()` Returns the Node for this model in the system properties graph.
`PrefixMapping` | `getPrefixMapping()` Answer the PrefixMapping object for this graph, the same one each time.
`ExtendedIterator` | `getPropertyTriples()` Returns triples that describe this graph in the system properties graph.
`boolean` | `getQueryFullReified()` Get the value of QueryFullReified.
`boolean` | `getQueryOnlyAsserted()` Get the value of QueryOnlyAsserted.
`boolean` | `getQueryOnlyReified()` Get the value of QueryOnlyReified.
`Reifier` | `getReifier()` Answer this graph's reifier.
`java.util.Iterator` | `getSpecializedGraphs()` Return an iterator over the specialized graphs for this graph
`TransactionHandler` | `getTransactionHandler()` Answer a transaction handler bound to this graph.
`boolean` | `graphBaseContains(Triple t)` Answer true if the graph contains any triple matching `t`.
`ExtendedIterator` | `graphBaseFind(TripleMatch m)` Answer an iterator over all the triples held in this graph's non-reified triple store that match `m`.
`int` | `graphBaseSize()` Answer the number of triples in this graph.
`boolean` | `isClosed()` Answer true iff .close() has been called onn this Graph.
`void` | `performAdd(Triple t)` Add a triple to the triple store.
`void` | `performDelete(Triple t)` Remove a triple from the triple store.
`QueryHandler` | `queryHandler()` Answer a QueryHandler bound to this graph.
`int` | `reificationBehavior()` Return the reification behavior (GraphRDB) for this graph
`int` | `reifierSize()` Answer the number of visible reification quads.
`ExtendedIterator` | `reifierTriples(TripleMatch m)` Answer an iterator over all the triples exposed in this graph's reifier that match `m`.
`void` | `remove()` Remove this Graph entirely from the database.
`void` | `setDoDuplicateCheck(boolean bool)` Set the value of DoDuplicateCheck.
`void` | `setDoFastpath(boolean val)` Set the value of DoFastpath.
`void` | `setDoImplicitJoin(boolean val)` Set the value of DoImplicitJoin.
`void` | `setQueryFullReified(boolean opt)` Set the value of QueryFullReified.
`void` | `setQueryOnlyAsserted(boolean opt)` Set the value of QueryOnlyAsserted.
`void` | `setQueryOnlyReified(boolean opt)` Set the value of QueryOnlyReified.
`static ReificationStyle` | `styleRDB(int behaviour)` Answer the reification style corresponding to the DB behaviour integer.
`static int` | `styleRDB(ReificationStyle style)` Answer the integer representing the RDB reifier style given the Reifier style.

Methods inherited from class com.hp.hpl.jena.graph.impl.GraphBase
`add, contains, contains, delete, dependsOn, find, find, forTestingOnly_graphBaseFind, getEventManager, getStatisticsHandler, isEmpty, isIsomorphicWith, notifyAdd, notifyDelete, size, toString, toString`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.hp.hpl.jena.graph.Graph
`contains, contains, delete, dependsOn, find, find, getEventManager, getStatisticsHandler, isEmpty, isIsomorphicWith, size`

Methods inherited from interface com.hp.hpl.jena.graph.GraphAdd
`add`

Field Detail

### DEFAULT

    public static final java.lang.String DEFAULT

  The name used for the default graph.

  See Also:
    Constant Field Values

### OPTIMIZE_ALL_REIFICATIONS_AND_HIDE_NOTHING

    public static final int OPTIMIZE_ALL_REIFICATIONS_AND_HIDE_NOTHING

  Optimize all triples representing part or all of a reified statement; this is the recommended option.

  This is the best choice in almost every case. It optimizes all reified triples regardless of how they are added to the graph, provides a simple interface, and is quite efficient.

  With this choice, if you do `add(A)` then `contains(A)` will return true for all A.

  See Also:
    Constant Field Values

### OPTIMIZE_AND_HIDE_FULL_AND_PARTIAL_REIFICATIONS

    public static final int OPTIMIZE_AND_HIDE_FULL_AND_PARTIAL_REIFICATIONS

  Optimize and hide any triples representing part or all of a reified statement.

  This optimizes all triples but hides them so they are visible only via the reifier interface. There is no significant performance advantage in using this option and it is not recommended. It is included only for compatability with in-memory graphs.

  Note that it will also cause unexpected behaviour, for example, if you do: `add(new Triple( s, RDF.predicate, o))` then that triple will be hidden and a subsequent call to `contains`, `find`, or `size` will not show it's presence. The only way to see that statement is to use `Reifier.getHiddenTriples`.

  See Also:
    Constant Field Values

### OPTIMIZE_AND_HIDE_ONLY_FULL_REIFICATIONS

    public static final int OPTIMIZE_AND_HIDE_ONLY_FULL_REIFICATIONS

  Optimize and hide only fully reified statements added via the Reifier interface, use only for backward-compatability with Jena1.

  This treats triples added through the Reifier interface as distinct from those added using the normal Graph.add function. Those added via the reifier interface will be optimized and hidden from view. Those added via Graph.add will not be optimized and will be visible.

  Since many of the techniques for adding triple to Graphs use Graph.add, and that is never optimized, this is not usually a good choice. It is included only for backward compability with Jena 1. There is no performance advantage in using this option.

  See Also:
    Constant Field Values

Constructor Detail

### GraphRDB

    public GraphRDB(IDBConnection con,
                    java.lang.String graphID,
                    Graph requestedProperties,
                    boolean isNew)

  Deprecated. Please use the alternate constructor and choose the desired reification behaviour.

  Construct a new GraphRDB using an unusual reification style.

  Parameters:
    `con` - an open connection to the database
    `graphID` - is the name of a graph or GraphRDB.DEFAULT
    `requestedProperties` - a set of default properties. (May be null, if non-null should be a superset of the properties obtained by calling ModelRDB.getDefaultModelProperties ).
    `isNew` - is true if the graph doesn't already exist and false otherwise. (If unsure, test for existance by using IDBConnection.containsGraph ).

### GraphRDB

    public GraphRDB(IDBConnection con,
                    java.lang.String graphID,
                    Graph requestedProperties,
                    int reificationBehaviour,
                    boolean isNew)

  Construct a new GraphRDB

  Parameters:
    `con` - an open connection to the database
    `graphID` - is the name of a graph or GraphRDB.DEFAULT
    `requestedProperties` - a set of default properties. (May be null, if non-null should be a superset of the properties obtained by calling ModelRDB.getDefaultModelProperties ).
    `reificationBehaviour` - specifies how this graph should handle reified triples. The options are OPTIMIZE_ALL_REIFICATIONS_AND_HIDE_NOTHING (strongly recommended), OPTIMIZE_AND_HIDE_FULL_AND_PARTIAL_REIFICATIONS (included only for full compatability with all the options for in-memory Graphs), OPTIMIZE_AND_HIDE_ONLY_FULL_REIFICATIONS (included only for compatability with older jena1-style usage).
    `isNew` - is true if the graph doesn't already exist and false otherwise. (If unsure, test for existance by using IDBConnection.containsGraph ).

Method Detail

### styleRDB

    public static int styleRDB(ReificationStyle style)

  Answer the integer representing the RDB reifier style given the Reifier style.

### styleRDB

    public static ReificationStyle styleRDB(int behaviour)

  Answer the reification style corresponding to the DB behaviour integer.

### getCapabilities

    public Capabilities getCapabilities()

  Database graphs do not presently support the equivalence of plain string literals and xsd:string literals (and other typed literals in general).

  Specified by:
    `getCapabilities` in interface `Graph`
  Overrides:
    `getCapabilities` in class `com.hp.hpl.jena.graph.impl.GraphBase`
  See Also:
    `Graph.getCapabilities()`

### getNode

    public Node getNode()

  Returns the Node for this model in the system properties graph. The properties of each GraphRDB (things like how it is stored in the database) are themelves stored in a system Graph. This function returns the Node which represents this GraphRDB in the system Graph.

  Since:
    Jena 2.0

### getPropertyTriples

    public ExtendedIterator getPropertyTriples()

  Returns triples that describe this graph in the system properties graph. The properties of each GraphRDB (things like how it is stored in the database) are stored as triples in a system Graph. This function returns those triples.

  Since:
    Jena 2.0

### isClosed

    public boolean isClosed()

  Description copied from interface: `Graph`
  Answer true iff .close() has been called onn this Graph.

  Specified by:
    `isClosed` in interface `Graph`
  Overrides:
    `isClosed` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### performAdd

    public void performAdd(Triple t)

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Add a triple to the triple store. The default implementation throws an AddDeniedException; subclasses must override if they want to be able to add triples.

  Specified by:
    `performAdd` in interface `com.hp.hpl.jena.graph.impl.GraphWithPerform`
  Overrides:
    `performAdd` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### add

    public void add(java.util.List triples)

  Add a list of triples.

  Parameters:
    `triples` - List to be added. This is unchanged by the call

### performDelete

    public void performDelete(Triple t)

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Remove a triple from the triple store. The default implementation throws a DeleteDeniedException; subclasses must override if they want to be able to remove triples.

  Specified by:
    `performDelete` in interface `com.hp.hpl.jena.graph.impl.GraphWithPerform`
  Overrides:
    `performDelete` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### delete

    public void delete(java.util.List triples)

  Delete a list of triples.

  Parameters:
    `triples` - List to be deleted. This is unchanged by the call.

### graphBaseSize

    public int graphBaseSize()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer the number of triples in this graph. Default implementation counts its way through the results of a findAll. Subclasses must override if they want size() to be efficient.

  Overrides:
    `graphBaseSize` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### graphBaseContains

    public boolean graphBaseContains(Triple t)

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer true if the graph contains any triple matching `t`. The default implementation uses `find` and checks to see if the iterator is non-empty.

  Overrides:
    `graphBaseContains` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### graphBaseFind

    public ExtendedIterator graphBaseFind(TripleMatch m)

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer an iterator over all the triples held in this graph's non-reified triple store that match `m`. Subclasses must override; it is the core implementation for `find(TripleMatch)`.

  Specified by:
    `graphBaseFind` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### reifierTriples

    public ExtendedIterator reifierTriples(TripleMatch m)

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer an iterator over all the triples exposed in this graph's reifier that match `m`. The default implementation delegates this to the reifier; subclasses probably don't need to override this.

  Overrides:
    `reifierTriples` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### reifierSize

    public int reifierSize()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer the number of visible reification quads. Subclasses will not normally need to override this, since it just invokes the reifier's size() method, and they can implement their own reifier.

  Overrides:
    `reifierSize` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### getBulkUpdateHandler

    public BulkUpdateHandler getBulkUpdateHandler()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer a BulkUpdateHandler bound to this graph. The default is a SimpleBulkUpdateHandler, which does bulk update by repeated simple (add/delete) updates; the same handler is returned on each call. Subclasses may override if they have specialised implementations.

  Specified by:
    `getBulkUpdateHandler` in interface `Graph`
  Overrides:
    `getBulkUpdateHandler` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### getReifier

    public Reifier getReifier()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer this graph's reifier. The reifier may be lazily constructed, and it must be the same reifier on each call. The default implementation is a SimpleReifier. Generally DO NOT override this method: override `constructReifier` instead.

  Specified by:
    `getReifier` in interface `Graph`
  Overrides:
    `getReifier` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### getPrefixMapping

    public PrefixMapping getPrefixMapping()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer the PrefixMapping object for this graph, the same one each time. Subclasses are unlikely to want to modify this.

  Specified by:
    `getPrefixMapping` in interface `Graph`
  Overrides:
    `getPrefixMapping` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### getTransactionHandler

    public TransactionHandler getTransactionHandler()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer a transaction handler bound to this graph. The default is SimpleTransactionHandler, which handles no transactions.

  Specified by:
    `getTransactionHandler` in interface `Graph`
  Overrides:
    `getTransactionHandler` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### close

    public void close()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Close this graph. Subgraphs may extend to discard resources.

  Specified by:
    `close` in interface `Graph`
  Overrides:
    `close` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### remove

    public void remove()

  Remove this Graph entirely from the database. This operation is unique to GraphRDB - it removes all mention of this graph from the database - after removing a graph it is recommended to immediately call close() (there is no other useful operation that may be performed, and so no reason to keep the Graph around).

### clear

    public void clear()

  Remove all statements from this graph.

### getConnection

    public IDBConnection getConnection()

  Return the connection

  Returns:
    IDBConnection for the database on which this graph is stored. Returns null if the connection has not yet been estabilished.

### reificationBehavior

    public int reificationBehavior()

  Return the reification behavior (GraphRDB) for this graph

  Returns:
    integer that defines the reification behavior for this graphRDB.

### getSpecializedGraphs

    public java.util.Iterator getSpecializedGraphs()

  Return an iterator over the specialized graphs for this graph

  Returns:
    Iterator over the list of specialized graphs.

### queryHandler

    public QueryHandler queryHandler()

  Description copied from class: `com.hp.hpl.jena.graph.impl.GraphBase`
  Answer a QueryHandler bound to this graph. The default implementation returns the same SimpleQueryHandler each time it is called; sub-classes may override if they need specialised query handlers.

  Specified by:
    `queryHandler` in interface `Graph`
  Overrides:
    `queryHandler` in class `com.hp.hpl.jena.graph.impl.GraphBase`

### DBqueryHandler

    public com.hp.hpl.jena.db.impl.DBQueryHandler DBqueryHandler()

### getDoDuplicateCheck

    public boolean getDoDuplicateCheck()

  Get the value of DoDuplicateCheck

  Returns:
    bool boolean

### setDoDuplicateCheck

    public void setDoDuplicateCheck(boolean bool)

  Set the value of DoDuplicateCheck.

  Parameters:
    `bool` - boolean

### setDoFastpath

    public void setDoFastpath(boolean val)

  Set the value of DoFastpath.

  Parameters:
    `val` - boolean

### getDoFastpath

    public boolean getDoFastpath()

  Get the value of DoFastpath.

  Returns:
    boolean

### setQueryOnlyAsserted

    public void setQueryOnlyAsserted(boolean opt)

  Set the value of QueryOnlyAsserted.

  Parameters:
    `opt` - boolean

### getQueryOnlyAsserted

    public boolean getQueryOnlyAsserted()

  Get the value of QueryOnlyAsserted.

  Returns:
    boolean

### setQueryOnlyReified

    public void setQueryOnlyReified(boolean opt)

  Set the value of QueryOnlyReified.

  Parameters:
    `opt` - boolean

### getQueryOnlyReified

    public boolean getQueryOnlyReified()

  Get the value of QueryOnlyReified.

  Returns:
    boolean

### setQueryFullReified

    public void setQueryFullReified(boolean opt)

  Set the value of QueryFullReified.

  Parameters:
    `opt` - boolean

### getQueryFullReified

    public boolean getQueryFullReified()

  Get the value of QueryFullReified.

  Returns:
    boolean

### setDoImplicitJoin

    public void setDoImplicitJoin(boolean val)

  Set the value of DoImplicitJoin.

  Parameters:
    `val` - boolean

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP