com.franz.ag
Class AllegroGraph

java.lang.Object
  extended bycom.franz.ag.AllegroGraph
All Implemented Interfaces:
ValueFactory

public class AllegroGraph
extends java.lang.Object
implements ValueFactory

Each instance of this class implements access to one AllegroGraph triple store.

There is no public constructor. Instances of this class are created by calls to methods in the AllegroGraphConnection class:

AllegroGraph is a triple store implementations that allows triples to be identified by an additional component that may be a literal or a URI. This component is sometimes called a context and sometimes a graph specifier. If this component is not specifed, triples are added to the null context, or the default graph. The terms null context and default graph are used interchangeably in the method descriptions.

In search operations, if the context is not specifed, then the search examines only the null context. If the context is specifed, then a null value is wild and matches any context, the empty string denotes the null context, any other value must be a valid Value reference.

The components of triples may be specfied as strings in ntriple notation, Value instances, and UPI instances. In some cases null and the empty string may be used to denote wild card or the null context.


Constructor Summary
protected AllegroGraph(AllegroGraphConnection sv, java.lang.String access, java.lang.String name, java.lang.String directory)
           
 
Method Summary
 void addDataMapping(java.lang.String[] map)
          Add to the table of datatype and property mappings in the triple store.
 void addIndexFlavors(java.lang.String[] flavors)
          Add some indexing options to the triple store.
 Literal addLiteral(boolean value)
          Create a typed Literal instance from a Java boolean value and add the Literal to the triple store registry.
 Literal addLiteral(byte value)
          Create a typed Literal instance from a Java byte value and add the Literal to the triple store registry.
 Literal addLiteral(double value)
          Create a typed Literal instance from a Java double value and add the Literal to the triple store registry.
 Literal addLiteral(float value)
          Create a typed Literal instance from a Java float value and add the Literal to the triple store registry.
 Literal addLiteral(int value)
          Create a typed Literal instance from a Java int value and add the Literal to the triple store registry.
 Literal addLiteral(long value)
          Create a typed Literal instance from a Java long value and add the Literal to the triple store registry.
 Literal addLiteral(short value)
          Create a typed Literal instance from a Java short value and add the Literal to the triple store registry.
 Literal addLiteral(java.lang.String value)
          Create a literal instance and add the Literal to the triple store registry.
 Literal addLiteral(java.lang.String value, java.lang.String language)
          Create a literal instance with a language tag and add the Literal to the triple store registry.
 Literal addLiteral(java.lang.String value, URI datatype)
          Create a literal instance with a datatype tag and add the Literal to the triple store registry.
 UPI[] addLiteralIds(java.lang.String[] values, java.lang.String[] datatypes, java.lang.String[] languages)
          Add a set of literal instances to the triple store registry.
 Literal[] addLiterals(java.lang.String[] values, java.lang.String[] datatypes, java.lang.String[] languages)
          Create a set of Literal instances and add the literals to the triple store registry.
 ValueNode addPart(java.lang.String part)
          Add a Literal, Node or BlankNode to the triple store.
 void addStatement(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Add a Statement in the null context to the triple store.
 void addStatement(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object context)
          Add a Statement to the triple store.
 void addStatements(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Add several null context Statements to the triple store.
 void addStatements(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object contexts)
          Add several Statements to the triple store.
 Literal addTypedLiteral(java.lang.String text, java.lang.String type)
          Create a typed Literal instance from a string and add the Literal to the triple store registry.
 Literal addTypedLiteral(java.lang.String text, UPI type)
          Create a typed Literal instance from a string and add the literal to the triple store registry.
 Literal addTypedLiteral(java.lang.String text, URI type)
          Create a typed Literal instance from a string and add the literal to the triple store registry.
 Node addURI(java.lang.String uri)
          Create a resource node with a URI label and add the resource to the triple store registry.
 UPI[] addURIIds(java.lang.String[] uri)
          Create a set of resource nodes in the triple store registry.
 URI[] addURIs(java.lang.String[] uri)
          Create a set of resource Node instances and add the resources to the triple store registry.
 void clear()
          Delete all the statements in the triple store (one-by-one).
 void closeDatabase()
          Deprecated. Use closeTripleStore() instead.
 void closeTripleStore()
          Close an AllegroGraph triple store.
 BNode createBNode()
          Create a BlankNode instance.
 BNode createBNode(java.lang.String nodeId)
          Create a BlankNode instance.
 UPI[] createBNodeIds(int n)
          Allocate a set of BlankNode ID numbers.
 BlankNode[] createBNodes(int n)
          Allocate a set of BlankNodes.
 EncodedLiteral createEncodedLiteral(double v, java.lang.String encoding)
          Create an AllegroGraph EncodedLiteral instance from a Java double value.
 EncodedLiteral createEncodedLiteral(long v, java.lang.String encoding)
          Create an AllegroGraph EncodedLiteral instance from a Java long value.
 EncodedLiteral createEncodedLiteral(java.lang.String v, java.lang.String encoding)
          Create an AllegroGraph EncodedLiteral instance from a Java string value.
 Literal createLiteral(boolean value)
          Create a typed Literal instance from a Java boolean value but do not modify the triple store.
 Literal createLiteral(byte value)
          Create a typed Literal instance from a Java byte value but do not modify the triple store.
 Literal createLiteral(double value)
          Create a typed Literal instance from a Java double value but do not modify the triple store.
 Literal createLiteral(float value)
          Create a typed Literal instance from a Java float value but do not modify the triple store.
 Literal createLiteral(int value)
          Create a typed Literal instance from a Java int value but do not modify the triple store.
 Literal createLiteral(long value)
          Create a typed Literal instance from a Java long value but do not modify the triple store.
 Literal createLiteral(short value)
          Create a typed Literal instance from a Java short value but do not modify the triple store.
 Literal createLiteral(java.lang.String value)
          Create a literal instance without updating the triple store.
 Literal createLiteral(java.lang.String value, java.lang.String language)
          Create a literal instance with a language tag but do not modify the triple store.
 Literal createLiteral(java.lang.String value, URI datatype)
          Create a literal instance with a datatype tag but do not modify the triple store.
 Statement createStatement(Resource subject, URI predicate, Value object)
          Create a Null Context Statement instance but do not update the triple store.
 Statement createStatement(Resource subject, URI predicate, Value object, Resource context)
          Create a Statement instance but do not update the triple store.
 Literal createTypedLiteral(java.lang.String text, java.lang.String type)
          Create a typed Literal instance from a string but do not modify the triple store.
 Literal createTypedLiteral(java.lang.String text, UPI type)
          Create a typed Literal instance from a string but do not modify the triple store.
 URI createURI(java.lang.String uri)
          Create a resource node with a URI label but do not modify the triple store.
 URI createURI(java.lang.String namespace, java.lang.String localName)
          Create a resource node with a URI label but do not modify the triple store.
 void dropIndexFlavors(java.lang.String[] flavors)
          Delete some indexing options from the triple store.
 java.lang.Object[] evalInServer(java.lang.String expression)
          Evaluate a Lisp expression in the AllegroGraph server.
 java.lang.Object[] evalInServer(java.lang.String expression, java.lang.String environment)
          Evaluate a Lisp expression in the AllegroGraph server.
 java.lang.String[] getDataMapping()
          Query the current table of datatype and property mappings in the triple store.
 java.lang.String[] getFreetextPredicates()
          Retrieve the URI labels of the registered freetext predicates.
 Cursor getFreetextStatements(java.lang.String pattern)
          Find triples that match a text pattern.
 ValueObject[] getFreetextUniqueSubjects(java.lang.String pattern)
          Collect the unique subjects from triples that match a text pattern.
 java.lang.String[] getIndexFlavors()
          Query the range of indexing that is applied to this triple store.
 int getLookAhead()
          Query the look-ahead value.
 java.lang.String[] getNamespaces()
          Query the namespace definitions specific to this triple store.
 java.lang.String[] getParts(UPI id)
          Retrieve the components of an AllegroGraph Value instance given the id number.
 void getParts(UPI[] ids, java.lang.String[] types, java.lang.String[] vals, java.lang.String[] mods)
          Like getParts(long) but operates on an array of UPI instances.
 int getSelectLimit()
          Get the current value of the select limit parameter.
 Cursor getStatements(boolean includeInferred, java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Retrieve null context statements from the triple store.
 Cursor getStatements(boolean includeInferred, java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object context)
          Retrieve statements from the triple store.
 Cursor getStatements(boolean includeInferred, java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object obEnd, java.lang.Object context, java.lang.Object contextEnd)
          Retrieve statements from the triple store and specify a range of values for the object and/or context components of the triples.
 Cursor getStatements(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Retrieve null context statements from the triple store.
 Cursor getStatements(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object context)
          Retrieve statements from the triple store .
 Cursor getStatements(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object obEnd, java.lang.Object context, java.lang.Object contextEnd)
          Retrieve statements from the triple store and specify a range of values for the object and/or context components of the triples.
 boolean getSyncEveryTime()
          Query the synchronization mode for this AllegroGraph instance.
 UPI[] getTripleParts(long id)
          Return an array of 4 UPI instances for subject, predicate, object, and context.
 int getUnindexedThreshold()
          Query the threshold for automatic indexing of the triple store.
 int getUnindexedTripleCount()
          Query the number of unindexed triples in the triple store.
 int getUnmergedCount()
          Query the number of unmerged index chunks in the triple store.
 int getUnmergedThreshold()
          Query the threshold for automatic re-indexing of the triple store.
 boolean hasStatement(boolean includeInferred, java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Find out if null-context statements matching the arguments are in the triple store.
 boolean hasStatement(boolean includeInferred, java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object context)
          Find out if any statements matching the arguments are in the triple store.
 boolean hasStatement(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object)
          Find out if null-context statements matching the arguments are in the triple store.
 boolean hasStatement(java.lang.Object subject, java.lang.Object predicate, java.lang.Object object, java.lang.Object context)
          Find out if any statements matching the arguments are in the triple store.
 void indexAll()
          Deprecated. Use indexAllTriples() instead
 void indexAllTriples()
          Index all the triples in the triple store.
 void indexAllTriples(boolean wait)
          Index all triples immediately or in the background.
 void indexNewTriples()
          Index new triples.
 void indexNewTriples(boolean wait)
          Index new triples immediately or in the background.
 void indexTriples()
          Deprecated. Use indexNewTriples() instead
 long loadNTriples(java.lang.String name)
          Load a file of triple declarations.
 long loadNTriples(java.lang.String[] names)
          Load several files of triple declarations.
 long loadNTriples(java.lang.String[] names, java.lang.Object context)
           
 long loadNTriples(java.lang.String name, java.lang.Object context)
           
 long loadRDF(java.lang.String filePath)
          Parse an XML file of RDF triple definitions and add the triples to the triple store.
 long loadRDF(java.lang.String filePath, java.lang.Object context)
           
static void main(java.lang.String[] args)
           
 int moreValues(java.lang.Object x)
          Determine if more results are available for a selectValues(String) result.
 Triple newTriple(java.lang.Object s, java.lang.Object p, java.lang.Object o)
          Add a new triple to the triple store.
 Triple newTriple(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
           
 long newTripleId(java.lang.Object s, java.lang.Object p, java.lang.Object o)
           
 long newTripleId(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
           
 long[] newTripleIds(java.lang.Object s, java.lang.Object p, java.lang.Object o)
           
 long[] newTripleIds(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
           
 Triple[] newTriples(java.lang.Object s, java.lang.Object p, java.lang.Object o)
          Add new triples to the triple store.
 Triple[] newTriples(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
           
 ValueObject newValue(UPI id)
          Convert a UPI instance into a ValueObject instance.
 long numberOfTriples()
          Query the number of triples in the triple store.
 long parseNTriples(java.lang.String from)
          Parse a string and add triples to the null context of triple store.
 long parseNTriples(java.lang.String from, java.lang.Object context)
          Parse a string and add triples to the specified context of the triple store.
 void registerFreetextPredicate(java.lang.Object predicate)
          Register a predicate for freetext indexing.
 void registerNamespace(java.lang.String prefix, java.lang.String full)
          Register one namespace definition for this triple store.
 void registerNamespaces(java.lang.String[] defs)
          Register several namespace definitions for this triple store.
 void removeStatement(java.lang.Object s, java.lang.Object p, java.lang.Object o)
          Remove one null-context statement from the triple store.
 void removeStatement(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
          Remove one statement from the triple store.
 void removeStatements(java.lang.Object s, java.lang.Object p, java.lang.Object o)
          Remove all statement that match a pattern from the triple store.
 void removeStatements(java.lang.Object s, java.lang.Object p, java.lang.Object o, java.lang.Object c)
          Remove all statement that match a pattern from the triple store.
 Cursor select(java.lang.String query)
          Deprecated. Use selectStatements(String) instead
 Cursor select(java.lang.String query, java.lang.Object arg)
          Deprecated. Use selectStatements(String,Object) instead
 Cursor select(java.lang.String query, java.lang.Object arg, java.lang.String svar)
          Deprecated. Use selectStatements(String,Object,String) instead
 ValueObject[] selectMore(ValueObject[] sr)
          Get more results from a previous selectSingleValues query.
 ValueObject[][] selectMore(ValueObject[][] sr)
          Get more results from a previous selectValues query.
 ValueObject[] selectSingleValues(java.lang.String query, java.lang.Object[] invals, java.lang.String invars)
          Evaluate a Prolog query that retrieves a single value in each success.
 Cursor selectStatements(java.lang.String query)
          Search the AllegroGraph triple store with a Prolog query.
 Cursor selectStatements(java.lang.String query, java.lang.Object arg)
          Search the AllegroGraph triple store with a Prolog query.
 Cursor selectStatements(java.lang.String query, java.lang.Object arg, java.lang.String svars)
          Search the AllegroGraph triple store with a Prolog query.
 ValueObject[][] selectValues(java.lang.String query)
          Evaluate a Prolog query that retrieves triples, resources, or literals from the triple store.
 ValueObject[][] selectValues(java.lang.String query, java.lang.Object[] invals, java.lang.String invars)
          Evaluate a Prolog query that retrieves triples, resources, or literals from the triple store.
 int serverTrace(boolean onoff)
          Change the trace state in the AllegroGraph server.
 int serverTrace(java.lang.String outFile)
          Start tracing calls from Java in the AllegroGraph server.
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setDataMapping(java.lang.String[] map)
          Replace the current table of datatype and property mappings in the triple store.
 void setIndexFlavors(java.lang.String[] flavors)
          Replace the indexing options of the triple store.
 void setLookAhead(int n)
          Set the look-ahead value for subsequent Statement search operations.
 void setSelectLimit(int v)
          Set the value of the select limit parameter.
 void setSyncEveryTime(boolean s)
          Set the synchronization mode for this AllegroGraph instance.
 void setUnindexedThreshold(int val)
          Set the threshold for automatic indexing of the triple store.
 void setUnmergedThreshold(int val)
          Set the threshold for automatic re-indexing of the triple store.
 void syncDatabase()
          Deprecated. Use syncTripleStore() instead.
 void syncTripleStore()
          Sync an AllegroGraph triple store.
 boolean twinqlAsk(boolean includeInferred, java.lang.String query)
           
 boolean twinqlAsk(java.lang.String query)
          Send a SPARQL ASK query to AllegroGraph.
 long twinqlCount(boolean includeInferred, java.lang.String query, java.lang.String vars, int limit, int offset)
           
 long twinqlCount(java.lang.String query, java.lang.String vars, int limit, int offset)
          Send a SPARQL SELECT query to AllegroGraph and return only the number of results.
 Cursor twinqlFind(boolean includeInferred, java.lang.String query, int limit, int offset)
           
 Cursor twinqlFind(java.lang.String query, int limit, int offset)
          Send a SPARQL DESCRIBE or CONSTRUCT query to AllegroGraph.
 java.lang.String twinqlQuery(boolean includeInferred, java.lang.String query, java.lang.String format, int limit, int offset)
           
 java.lang.String twinqlQuery(java.lang.String query, java.lang.String format, int limit, int offset)
          Send a SPARQL query to AllegroGraph and retrieve a serialized XML reply.
 ValueObject[][] twinqlSelect(boolean includeInferred, java.lang.String query, java.lang.String vars, int limit, int offset)
           
 ValueObject[][] twinqlSelect(java.lang.String query, java.lang.String vars, int limit, int offset)
          Send a SPARQL SELECT query to AllegroGraph.
 java.lang.String[] valueNames(java.lang.Object x)
           
 int valuesLength(ValueObject[][] x)
          Return the number of result sets in the array returned by selectValues(String).
static java.lang.String version()
          Query the current AllegroGraph version.
static java.lang.String[] versions()
          Query the current AllegroGraph and component versions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllegroGraph

protected AllegroGraph(AllegroGraphConnection sv,
                       java.lang.String access,
                       java.lang.String name,
                       java.lang.String directory)
                throws AllegroGraphException
Method Detail

version

public static java.lang.String version()
Query the current AllegroGraph version.

Returns:
a version string.

versions

public static java.lang.String[] versions()
Query the current AllegroGraph and component versions.

Returns:
An array of strings for the AllegroGraph version, the server protocol level, and the socket protocol level.

main

public static void main(java.lang.String[] args)

setLookAhead

public void setLookAhead(int n)
Set the look-ahead value for subsequent Statement search operations.

Parameters:
n - an integer look-ahead value - must be positive. A zero value specifies that the defaultLookAhead value in the Cursor class should be used.

The look-ahead value determines how many Statements will be pre-loaded into a Cursor instance when it is created or advanced. The pre-loaded Statements in the Cursor are retrieved immediately in Java without a round-trip to the AllegroGraph server.

See Also:
Cursor.setLookAhead(int)

getLookAhead

public int getLookAhead()
Query the look-ahead value.

Returns:
an integer
See Also:
setLookAhead(int)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)

syncDatabase

public void syncDatabase()
                  throws AllegroGraphException
Deprecated. Use syncTripleStore() instead.

Throws:
AllegroGraphException
See Also:
syncTripleStore()

syncTripleStore

public void syncTripleStore()
                     throws AllegroGraphException
Sync an AllegroGraph triple store.

Throws:
AllegroGraphException

closeDatabase

public void closeDatabase()
                   throws AllegroGraphException
Deprecated. Use closeTripleStore() instead.

Throws:
AllegroGraphException
See Also:
closeTripleStore()

closeTripleStore

public void closeTripleStore()
                      throws AllegroGraphException
Close an AllegroGraph triple store.

Throws:
AllegroGraphException

loadNTriples

public long loadNTriples(java.lang.String name)
                  throws AllegroGraphException
Load a file of triple declarations. The triples are added in the null context of the triple store.

Parameters:
name - - a pathname string. The file must be in the ntriples format expected by the AllegroGraph server.

If a file is very large, the operation may take a long time. During that time, the calling thread, and the interface to the AllegroGraph server are blocked. On Windows, it is possible to see progress messages in the server console window which is normally hidden. On Unix, the server progress messages may be seen if the server is running with a log file; in that case the log file will grow as progress messages are added.

Throws:
AllegroGraphException

loadNTriples

public long loadNTriples(java.lang.String name,
                         java.lang.Object context)
                  throws AllegroGraphException
Throws:
AllegroGraphException

loadNTriples

public long loadNTriples(java.lang.String[] names)
                  throws AllegroGraphException
Load several files of triple declarations. The triples are added in the null context of the triple store.

Parameters:
names - - an array of pathname string. The files must be in the ntriples format expected by the AllegroGraph server.

See the note about progress messages in the description of

Throws:
AllegroGraphException
See Also:
loadNTriples(String)

loadNTriples

public long loadNTriples(java.lang.String[] names,
                         java.lang.Object context)
                  throws AllegroGraphException
Throws:
AllegroGraphException

parseNTriples

public long parseNTriples(java.lang.String from)
                   throws AllegroGraphException
Parse a string and add triples to the null context of triple store. The string must be in the ntriples format expected by the AllegroGraph server.

Parameters:
from - a string in ntriples format
Throws:
AllegroGraphException

parseNTriples

public long parseNTriples(java.lang.String from,
                          java.lang.Object context)
                   throws AllegroGraphException
Parse a string and add triples to the specified context of the triple store. The string must be in the ntriples format expected by the AllegroGraph server.

Parameters:
from - a string in ntriples format
context - a string, UPI instance, Value instance or null.
Throws:
AllegroGraphException

loadRDF

public long loadRDF(java.lang.String filePath)
             throws AllegroGraphException
Parse an XML file of RDF triple definitions and add the triples to the triple store.

Parameters:
filePath - A string that points to the file. The file must be in the RDF format expected by the AllegroGraph server.

See the note about progress messages in the description of loadNTriples.

Throws:
AllegroGraphException

loadRDF

public long loadRDF(java.lang.String filePath,
                    java.lang.Object context)
             throws AllegroGraphException
Throws:
AllegroGraphException

numberOfTriples

public long numberOfTriples()
                     throws AllegroGraphException
Query the number of triples in the triple store.

Returns:
the number of triples in the triple store.
Throws:
AllegroGraphException

indexTriples

public void indexTriples()
                  throws AllegroGraphException
Deprecated. Use indexNewTriples() instead

Index new triples.

Throws:
AllegroGraphException - if an error occurs during indexing.

If the current indexing chunk size is too small, it can cause too many files to be opened during indexing; in that case the AllegroGraphException exception with the string "too-many-index-chunks-error: will create nnn files" is thrown; nnn is the number of chunks. At this point, the triple store has not been indexed, but the server is in a stable state. The Application can adjust the chunk size with AllegroGraphConnection.setChunkSize() and try the indexing call again.

If the current indexing chunk size is too large, the server may run out of memory during indexing; in that case, the thrown exception will depend on where and when the out-of-memory condition occurred. The triple store may be in a partially indexed state.


indexNewTriples

public void indexNewTriples()
                     throws AllegroGraphException
Index new triples.

Throws:
AllegroGraphException - if an error occurs during indexing.

If the current indexing chunk size is too small, it can cause too many files to be opened during indexing; in that case the AllegroGraphException exception with the string "too-many-index-chunks-error: will create nnn files" is thrown; nnn is the number of chunks. At this point, the triple store has not been indexed, but the server is in a stable state. The Application can adjust the chunk size with AllegroGraphConnection.setChunkSize() and try the indexing call again.

If the current indexing chunk size is too large, the server may run out of memory during indexing; in that case, the thrown exception will depend on where and when the out-of-memory condition occurred. The triple store may be in a partially indexed state.


indexNewTriples

public void indexNewTriples(boolean wait)
                     throws AllegroGraphException
Index new triples immediately or in the background.

Parameters:
wait - If true, then return only after indexing is completed. If false, schedule an indexing task to run in the background and return immediately.
Throws:
AllegroGraphException

indexAll

public void indexAll()
              throws AllegroGraphException
Deprecated. Use indexAllTriples() instead

Index all the triples in the triple store.

Throws:
AllegroGraphException - if an error occurs during indexing.

See the discussion of chunk size at indexTriples().


indexAllTriples

public void indexAllTriples()
                     throws AllegroGraphException
Index all the triples in the triple store.

Throws:
AllegroGraphException - if an error occurs during indexing.

See the discussion of chunk size at indexNewTriples().


indexAllTriples

public void indexAllTriples(boolean wait)
                     throws AllegroGraphException
Index all triples immediately or in the background.

Parameters:
wait - If true, then return only after indexing is completed. If false, schedule an indexing task to run in the background and return immediately.
Throws:
AllegroGraphException

newValue

public ValueObject newValue(UPI id)
Convert a UPI instance into a ValueObject instance.

Parameters:
id - A UPI instance that denotes a Resource or Literal object
Returns:
The Resource or Literal object instance.
Throws:
java.lang.IllegalStateException - if the object could not be created.

getParts

public java.lang.String[] getParts(UPI id)
                            throws AllegroGraphException
Retrieve the components of an AllegroGraph Value instance given the id number.

Parameters:
id - A UPI instance.
Returns:
An array of three strings:
  • A string that identifies the type of the object:
    • "anon" - A blank node
    • "node" - A resource node
    • "literal" - A literal node
    • "literal/lang" - A literal node with a language tag
    • "typed-literal" - A literal node with a type tag
    • "unknown" - The id is not in the triple store
  • A string that contains the URL or literal data associated with the object
  • A string that contains additional data, ie a language or a type tag
If the object does not have the component, then the array element is null.
Throws:
AllegroGraphException

getTripleParts

public UPI[] getTripleParts(long id)
                     throws AllegroGraphException
Return an array of 4 UPI instances for subject, predicate, object, and context.

Throws:
AllegroGraphException

getParts

public void getParts(UPI[] ids,
                     java.lang.String[] types,
                     java.lang.String[] vals,
                     java.lang.String[] mods)
              throws AllegroGraphException
Like getParts(long) but operates on an array of UPI instances.

Parameters:
ids - an array of UPI instances
types - a String array of the same length as ids.
vals - a String array of the same length as ids.
mods - a String array of the same length as ids.

The arrays types, vals, mods are modified to hold the string values corresponding to the id number in the ids array.

Throws:
AllegroGraphException

getSelectLimit

public int getSelectLimit()
Get the current value of the select limit parameter.

Returns:
an integer value.

This number determines the number of values transmitted in one set of results from the AllegroGraph server to the Java client. If the number of expected results is very large, but the application is interested in only a few, then a small number may improve performance. If the number is very large, there may be a long delay as the large array of results is prepared and transmitted to the client. The total numer of actual values returned depends on the number of free variables in the query.

The built-in initial value is 1000.


setSelectLimit

public void setSelectLimit(int v)
Set the value of the select limit parameter.

Parameters:
v - A positive integer.
See Also:
getSelectLimit()

createBNode

public BNode createBNode()
Create a BlankNode instance.

Specified by:
createBNode in interface ValueFactory
Returns:
a value that can be safely cast to BlankNode
Throws:
java.lang.IllegalStateException - if the creation fails.

It does not make sense to create a BNode that is not registered in the triple store becuse two instances of apparently identical unregistered BNodes would map to distinct BNodes in the triple store.


createBNode

public BNode createBNode(java.lang.String nodeId)
Create a BlankNode instance.

Specified by:
createBNode in interface ValueFactory
Parameters:
nodeId - the bnode identifier
Returns:
a value that can be safely cast to BlankNode
Throws:
java.lang.IllegalStateException - if the creation fails.

See note on createBNode().


createBNodes

public BlankNode[] createBNodes(int n)
                         throws AllegroGraphException
Allocate a set of BlankNodes.

Parameters:
n - the number of nodes to allocate.
Returns:
an array of BlankNode instances.
Throws:
AllegroGraphException - if there is a problem during creation.

See note on createBNode().


createEncodedLiteral

public EncodedLiteral createEncodedLiteral(long v,
                                           java.lang.String encoding)
Create an AllegroGraph EncodedLiteral instance from a Java long value.

Parameters:
v - The Java long value.
encoding - A string that specifies the AllegroGraph encoding desired. The available encodings are described in the AllegroGraph Introduction document.
Returns:
an EncodedLiteral instance that can be used in query ir update operations.

createEncodedLiteral

public EncodedLiteral createEncodedLiteral(double v,
                                           java.lang.String encoding)
Create an AllegroGraph EncodedLiteral instance from a Java double value.

Parameters:
v - The Java double value.
encoding - A string that specifies the AllegroGraph encoding desired. The available encodings are described in the AllegroGraph Introduction document.
Returns:
an EncodedLiteral instance that can be used in query ir update operations.

createEncodedLiteral

public EncodedLiteral createEncodedLiteral(java.lang.String v,
                                           java.lang.String encoding)
Create an AllegroGraph EncodedLiteral instance from a Java string value.

Parameters:
v - The Java string value.
encoding - A string that specifies the AllegroGraph encoding desired. The available encodings are described in the AllegroGraph Introduction document.
Returns:
an EncodedLiteral instance that can be used in query ir update operations.

createLiteral

public Literal createLiteral(java.lang.String value)
Create a literal instance without updating the triple store.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.
Returns:
a value that can be safely cast to Literal

The literal instance will have a null UPI.


addLiteral

public Literal addLiteral(java.lang.String value)
Create a literal instance and add the Literal to the triple store registry.

Returns:
a Literal instance that can be safely cast to com.franz.ag.Literal
Throws:
java.lang.IllegalStateException - if the creation fails.

createLiteral

public Literal createLiteral(java.lang.String value,
                             java.lang.String language)
Create a literal instance with a language tag but do not modify the triple store.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.
language - The literal's language attribute, or null if the literal doesn't have a language.
Returns:
a value that can be safely cast to Literal

The literal instance will have a null UPI.


addLiteral

public Literal addLiteral(java.lang.String value,
                          java.lang.String language)
Create a literal instance with a language tag and add the Literal to the triple store registry.

Returns:
a Literal instance that can be safely cast to com.franz.ag.Literal
Throws:
java.lang.IllegalStateException - if the creation fails.

createTypedLiteral

public Literal createTypedLiteral(java.lang.String text,
                                  java.lang.String type)
Create a typed Literal instance from a string but do not modify the triple store.

Parameters:
text - A string URI.
type - A string URI that denotes the type.
Returns:
a Literal instance.

addTypedLiteral

public Literal addTypedLiteral(java.lang.String text,
                               java.lang.String type)
Create a typed Literal instance from a string and add the Literal to the triple store registry.

Parameters:
text - A string URI.
type - A string URI that denotes the type.
Returns:
a Literal instance.
Throws:
java.lang.IllegalStateException - if the creation fails.

createTypedLiteral

public Literal createTypedLiteral(java.lang.String text,
                                  UPI type)
Create a typed Literal instance from a string but do not modify the triple store.

Parameters:
text - A string.
type - A UPI instance that identifie a Node
Returns:
a Literal instance.

addTypedLiteral

public Literal addTypedLiteral(java.lang.String text,
                               UPI type)
Create a typed Literal instance from a string and add the literal to the triple store registry.

Parameters:
text - A string.
type - A UPI instance that identifies the datatype resource.
Returns:
a Literal instance.
Throws:
java.lang.IllegalStateException - if the creation fails.

addTypedLiteral

public Literal addTypedLiteral(java.lang.String text,
                               URI type)
Create a typed Literal instance from a string and add the literal to the triple store registry.

Parameters:
text - A string.
type - A URI instance that identifies the datatype resource.
Returns:
a Literal instance.
Throws:
java.lang.IllegalStateException - if the creation fails.

createLiteral

public Literal createLiteral(java.lang.String value,
                             URI datatype)
Create a literal instance with a datatype tag but do not modify the triple store.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.
datatype - The literal's datatype, or null if the literal doesn't have a datatype.
Returns:
a value that can be safely cast to Literal

The literal instance will have a null UPI.


addLiteral

public Literal addLiteral(java.lang.String value,
                          URI datatype)
                   throws AllegroGraphException
Create a literal instance with a datatype tag and add the Literal to the triple store registry.

Returns:
a Literal instance that can be safely cast to com.franz.ag.Literal
Throws:
java.lang.IllegalStateException - if the creation fails.
AllegroGraphException

addLiterals

public Literal[] addLiterals(java.lang.String[] values,
                             java.lang.String[] datatypes,
                             java.lang.String[] languages)
                      throws AllegroGraphException
Create a set of Literal instances and add the literals to the triple store registry.

Parameters:
values - An array of string literal values (of length n).
datatypes - null, or an array of datatype URIs. If null, none of the new Literal instances will have a datatype qualifier. If an array, the first n elements will be used as datatype labels for the corresponding Literal. A null element specifies a Literal without a datatype label. If the length of the array is less than n, the last element is repeated as often as necessary. If a non-null value is specified in an array element, the corresponding element in the languages array is ignored.
languages - null, or an array of language labels. If null, none of the new Literal instances will have a language qualifier. If an array, the first n elements will be used as language labels for the corresponding Literal. A null element specifies a Literal without a language label. If the length of the array is less than n, the last element is repeated as often as necessary.
Returns:
An array of Literal instances of the same size as the first argument array.
Throws:
AllegroGraphException

createURI

public URI createURI(java.lang.String uri)
Create a resource node with a URI label but do not modify the triple store.

Specified by:
createURI in interface ValueFactory
Parameters:
uri -
Returns:
a URI instance tah can be cast safely to Node

addURI

public Node addURI(java.lang.String uri)
            throws