com.bigdata.rdf.model
Class BNodeContextFactory

java.lang.Object
  extended by com.bigdata.rdf.model.BNodeContextFactory
All Implemented Interfaces:
BigdataValueFactory, ValueFactory

public class BNodeContextFactory
extends Object
implements BigdataValueFactory

Class provides a document-scoped context for generating blank node identifiers (IDs). This class is intended for use to generate blank node identifiers (IDs) for a source document within a shared prefix. When that prefix is mapped onto the term2id index, all blank nodes for the same source document will tend to be mapped onto the same index partition (this is more efficient since the ordered writes are more local). The prefix itself is a UUID, which is how we ensure that blank nodes generated for different sources are understood as distinct blank nodes by the database (this is required).

Note: All BigdataValue instances are in fact created by the delegate instances created by this class and by the delegate will appear to have been created by the same factory. This is intentional - it makes the instances reusable by the base factory.

Note: nextID() is NOT thread-safe, but different documents that are being passed concurrently will have a distinct instance of this factory and processing a single document is generally single-threaded.

Version:
$Id: BNodeContextFactory.java 2547 2010-03-24 20:44:07Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
BNodeContextFactory(BigdataValueFactory valueFactory)
           
 
Method Summary
 BigdataBNode asValue(BNode v)
          Strongly typed for BNodes.
 BigdataLiteral asValue(Literal v)
          Strongly typed for Literals.
 BigdataResource asValue(Resource v)
          Strongly typed for Resources.
 BigdataURI asValue(URI v)
          Strongly typed for URIs.
 BigdataValue asValue(Value v)
          Converts a Value into a BigdataValue.
 BigdataBNode createBNode()
           
 BigdataBNode createBNode(String id)
           
 BigdataLiteral createLiteral(boolean arg0)
           
 BigdataLiteral createLiteral(byte arg0)
           
 BigdataLiteral createLiteral(byte arg0, boolean unsigned)
           
 BigdataLiteral createLiteral(double arg0)
           
 BigdataLiteral createLiteral(float arg0)
           
 BigdataLiteral createLiteral(int arg0)
           
 BigdataLiteral createLiteral(int arg0, boolean unsigned)
           
 BigdataLiteral createLiteral(long arg0)
           
 BigdataLiteral createLiteral(long arg0, boolean unsigned)
           
 BigdataLiteral createLiteral(short arg0)
           
 BigdataLiteral createLiteral(short arg0, boolean unsigned)
           
 BigdataLiteral createLiteral(String label)
           
 BigdataLiteral createLiteral(String label, String language)
           
 BigdataLiteral createLiteral(String label, URI datatype)
           
 BigdataLiteral createLiteral(XMLGregorianCalendar arg0)
           
 BigdataStatement createStatement(Resource s, URI p, Value o)
          Create a statement whose StatementEnum is NOT specified.
 BigdataStatement createStatement(Resource s, URI p, Value o, Resource c)
          Create a statement whose StatementEnum is NOT specified.
 BigdataStatement createStatement(Resource s, URI p, Value o, Resource c, StatementEnum type)
          Create a statement (core impl).
 BigdataStatement createStatement(Resource s, URI p, Value o, Resource c, StatementEnum type, boolean userFlag)
          Create a statement (core impl).
 BigdataURI createURI(String uriString)
           
 BigdataURI createURI(String namespace, String localName)
           
 String getNamespace()
          The namespace of the KB instance associated with the value factory.
 BigdataValueSerializer<BigdataValue> getValueSerializer()
          An object that can efficiently (de-)serialize Values using this ValueFactory.
 BigdataValueFactory newBNodeContext()
          Recursive contexts are not available (should not be necessary, right?)
protected  String nextID()
          A globally unique blank node identifier (ID) created with prefix shared by all blank nodes whose identifers are generated by this class.
 void remove()
          Remove instance of valueFactory from static cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BNodeContextFactory

public BNodeContextFactory(BigdataValueFactory valueFactory)
Method Detail

getNamespace

public String getNamespace()
Description copied from interface: BigdataValueFactory
The namespace of the KB instance associated with the value factory.

Specified by:
getNamespace in interface BigdataValueFactory

remove

public void remove()
Description copied from interface: BigdataValueFactory
Remove instance of valueFactory from static cache

Specified by:
remove in interface BigdataValueFactory

nextID

protected String nextID()
A globally unique blank node identifier (ID) created with prefix shared by all blank nodes whose identifers are generated by this class.


createBNode

public BigdataBNode createBNode()
Specified by:
createBNode in interface BigdataValueFactory
Specified by:
createBNode in interface ValueFactory

asValue

public BigdataValue asValue(Value v)
Description copied from interface: BigdataValueFactory
Converts a Value into a BigdataValue. If the value is already a BigdataValue and it was allocated by this BigdataValueFactoryImpl then it is returned unchanged. Otherwise a new BigdataValue will be creating using the same data as the given value and the term identifier on the new BigdataValue will be initialized to IRawTripleStore#NULL.

All BigdataValues created by a BigdataValueFactoryImpl internally store a transient reference to the BigdataValueFactoryImpl. This reference is used to decide if a BigdataValue MIGHT have been created by a different lexicon (term identifiers generated by different lexicons CAN NOT be used interchangeably). This has the effect of protecting against incorrect use of the term identifier with a database backed by a different lexicon while allowing reuse of the BigdataValues when possible.

Specified by:
asValue in interface BigdataValueFactory
Parameters:
v - The value.
Returns:
A BigdataValue with the same data. If the value is null then null is returned.

createBNode

public BigdataBNode createBNode(String id)
Specified by:
createBNode in interface BigdataValueFactory
Specified by:
createBNode in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(boolean arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(byte arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(double arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(float arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(int arg0,
                                    boolean unsigned)
Specified by:
createLiteral in interface BigdataValueFactory

createLiteral

public BigdataLiteral createLiteral(long arg0,
                                    boolean unsigned)
Specified by:
createLiteral in interface BigdataValueFactory

createLiteral

public BigdataLiteral createLiteral(short arg0,
                                    boolean unsigned)
Specified by:
createLiteral in interface BigdataValueFactory

createLiteral

public BigdataLiteral createLiteral(byte arg0,
                                    boolean unsigned)
Specified by:
createLiteral in interface BigdataValueFactory

createLiteral

public BigdataLiteral createLiteral(int arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(long arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(short arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(String label,
                                    String language)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(String label,
                                    URI datatype)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(String label)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createLiteral

public BigdataLiteral createLiteral(XMLGregorianCalendar arg0)
Specified by:
createLiteral in interface BigdataValueFactory
Specified by:
createLiteral in interface ValueFactory

createStatement

public BigdataStatement createStatement(Resource s,
                                        URI p,
                                        Value o)
Description copied from interface: BigdataValueFactory
Create a statement whose StatementEnum is NOT specified.

Specified by:
createStatement in interface BigdataValueFactory
Specified by:
createStatement in interface ValueFactory

createStatement

public BigdataStatement createStatement(Resource s,
                                        URI p,
                                        Value o,
                                        Resource c)
Description copied from interface: BigdataValueFactory
Create a statement whose StatementEnum is NOT specified.

Specified by:
createStatement in interface BigdataValueFactory
Specified by:
createStatement in interface ValueFactory

createStatement

public BigdataStatement createStatement(Resource s,
                                        URI p,
                                        Value o,
                                        Resource c,
                                        StatementEnum type)
Description copied from interface: BigdataValueFactory
Create a statement (core impl). The s,p,o, and the optional c arguments will be normalized to this BigdataValueFactory using BigdataValueFactory.asValue(Value).

Specified by:
createStatement in interface BigdataValueFactory
Parameters:
s - The subject.
p - The predicate.
o - The object.
c - The context (optional). Note: When non-null and statement identifiers are enabled, then this will be a blank node whose term identifier is the statement identifier.
type - The statement type (optional).

createStatement

public BigdataStatement createStatement(Resource s,
                                        URI p,
                                        Value o,
                                        Resource c,
                                        StatementEnum type,
                                        boolean userFlag)
Description copied from interface: BigdataValueFactory
Create a statement (core impl). The s,p,o, and the optional c arguments will be normalized to this BigdataValueFactory using BigdataValueFactory.asValue(Value).

Specified by:
createStatement in interface BigdataValueFactory
Parameters:
s - The subject.
p - The predicate.
o - The object.
c - The context (optional). Note: When non-null and statement identifiers are enabled, then this will be a blank node whose term identifier is the statement identifier.
type - The statement type (optional).
userFlag - The user flag

createURI

public BigdataURI createURI(String namespace,
                            String localName)
Specified by:
createURI in interface BigdataValueFactory
Specified by:
createURI in interface ValueFactory

createURI

public BigdataURI createURI(String uriString)
Specified by:
createURI in interface BigdataValueFactory
Specified by:
createURI in interface ValueFactory

getValueSerializer

public BigdataValueSerializer<BigdataValue> getValueSerializer()
Description copied from interface: BigdataValueFactory
An object that can efficiently (de-)serialize Values using this ValueFactory. When the values are de-serialized they will have a reference to this BigdataValueFactoryImpl. That reference can be used to identify when two BigdataValues MIGHT be from different lexicons.

Specified by:
getValueSerializer in interface BigdataValueFactory
Returns:

newBNodeContext

public BigdataValueFactory newBNodeContext()
Recursive contexts are not available (should not be necessary, right?)

Specified by:
newBNodeContext in interface BigdataValueFactory
See Also:
BNodeContextFactory

asValue

public BigdataResource asValue(Resource v)
Description copied from interface: BigdataValueFactory
Strongly typed for Resources.

Specified by:
asValue in interface BigdataValueFactory

asValue

public BigdataURI asValue(URI v)
Description copied from interface: BigdataValueFactory
Strongly typed for URIs.

Specified by:
asValue in interface BigdataValueFactory

asValue

public BigdataLiteral asValue(Literal v)
Description copied from interface: BigdataValueFactory
Strongly typed for Literals.

Specified by:
asValue in interface BigdataValueFactory

asValue

public BigdataBNode asValue(BNode v)
Description copied from interface: BigdataValueFactory
Strongly typed for BNodes.

Specified by:
asValue in interface BigdataValueFactory


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.