Class LiveStore

Indexed Formula aka Store

Hierarchy (view full)

Constructors

Properties

HTTPRedirects: Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

Redirections we got from HTTP

_existentialVariables?: BlankNode[]
_universalVariables?: NamedNode[]
aliases: any[]

Reverse mapping to redirection: aliases for this

classActions: {
    [k: string]: Function[];
}

Map of iri predicates to functions to call when adding { s type X }

Type declaration

  • [k: string]: Function[]
classOrder: number = ClassOrder.Graph

The class order for this node

constraints: readonly any[] = []

initial array of constraints

features: FeaturesType
fetcher: Fetcher

The accompanying fetcher instance.

Is set by the fetcher when initialized.

index: [Statement<SubjectType, PredicateType, ObjectType, GraphType>[], Statement<SubjectType, PredicateType, ObjectType, GraphType>[], Statement<SubjectType, PredicateType, ObjectType, GraphType>[], Statement<SubjectType, PredicateType, ObjectType, GraphType>[]]
initBindings: readonly any[] = []

initial bindings used in Query

isVar: number = 0
namespaces: {
    [key: string]: string;
}

Dictionary of namespace prefixes

Type declaration

  • [key: string]: string
ns: ((nsuri, factory?) => ((ln) => NamedNode)) = Namespace

A namespace for the specified namespace's URI

Type declaration

    • (nsuri, factory?): ((ln) => NamedNode)
    • Parameters

      • nsuri: string

        The URI for the namespace

      • Optional factory: RdfJsDataFactory

      Returns ((ln) => NamedNode)

        • (ln): NamedNode
        • Parameters

          • ln: string

          Returns NamedNode

objectIndex: Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

Array of statements with this X as object

optional: readonly any[] = []

optional

predicateIndex: Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

Array of statements with this X as predicate

propertyActions: {
    [k: string]: Function[];
}

Map of iri predicates to functions to call when getting statement with {s X o}

Type declaration

  • [k: string]: Function[]
rdfFactory: any

The factory used to generate statements and terms

redirections: any[]

Redirect to lexically smaller equivalent symbol

statements: Statement<SubjectType, PredicateType, ObjectType, GraphType>[] = []

Initial array of statements

subjectIndex: Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

Array of statements with this X as subject

termType: "Graph" = GraphTermType

The type of node

updater: UpdateManager

An UpdateManager initialised to this store

value: string

The node's value

whyIndex: Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

Array of statements with X as provenance

fromValue: (<T>(value) => T)

Type declaration

    • <T>(value): T
    • Type Parameters

      • T extends FromValueReturns

      Parameters

      • value: ValueType

      Returns T

handleRDFType: Function
toJS: ((term) => string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[])

Type declaration

    • (term): string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[]
    • Parameters

      • term: any

      Returns string | boolean | object | Number | Date | (string | boolean | object | Number | Date)[]

Accessors

  • get length(): number
  • Returns the number of statements contained in this IndexedFormula. (Getter proxy to this.statements). Usage:

    var kb = rdf.graph()
    kb.length // -> 0

    Returns number

  • get defaultGraphURI(): string
  • Gets the URI of the default graph

    Returns string

Methods

  • Transform a collection of NTriple URIs into their URI strings

    Parameters

    • t: any

      Some iterable collection of NTriple URI strings

    Returns {}

    A collection of the URIs as strings todo: explain why it is important to go through NT

    • Adds a triple (quad) to the store.

      Parameters

      • subj: Quad_Subject | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Statement<SubjectType, PredicateType, ObjectType, GraphType> | Statement<SubjectType, PredicateType, ObjectType, GraphType>[] | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        The thing about which the fact a relationship is asserted. Also accepts a statement or an array of Statements.

      • Optional pred: Quad_Predicate

        The relationship which is asserted

      • Optional obj: string | Term

        The object of the relationship, e.g. another thing or a value. If passed a string, this will become a literal.

      • Optional why: Quad_Graph

        The document in which the triple (S,P,O) was or will be stored on the web

      Returns null | number | Statement<SubjectType, PredicateType, ObjectType, GraphType> | LiveStore

      The statement added to the store, or the store

    • Adds all the statements to this formula

      Parameters

      • statements: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        A collection of statements

      Returns void

    • Add a callback which will be triggered after a statement has been added to the store.

      Parameters

      • cb: ((q) => void)
          • (q): void
          • Parameters

            • q: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>

            Returns void

      Returns void

    • Follow link from one node, using one wildcard, looking for one

      For example, any(me, knows, null, profile) - a person I know accoring to my profile . any(me, knows, null, null) - a person I know accoring to anything in store . any(null, knows, me, null) - a person who know me accoring to anything in store .

      Parameters

      • Optional s: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional p: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional o: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional g: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      Returns null | Node

      A node which match the wildcard position, or null

    • Gets the first JavaScript object equivalent to a node based on the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns any

    • Gets the first statement that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject
      • Optional p: null | Quad_Predicate
      • Optional o: null | Quad_Object
      • Optional g: null | Quad_Graph

      Returns undefined | Statement<SubjectType, PredicateType, ObjectType, GraphType>

    • Gets the value of a node that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns string | void

    • Apply a set of statements to be deleted and to be inserted

      Parameters

      • patch: {
            delete?: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[];
            patch?: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[];
            where?: any;
        }

        The set of statements to be deleted and to be inserted

        • Optional delete?: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]
        • Optional patch?: readonly Statement<SubjectType, PredicateType, ObjectType, GraphType>[]
        • Optional where?: any
      • target: NamedNode

        The name of the document to patch

      • patchCallback: ((errorString?) => void)

        Callback to be called when patching is complete

          • (errorString?): void
          • Parameters

            • Optional errorString: string

            Returns void

      Returns void

    • Finds the types in the list which have no stored subtypes These are a set of classes which provide by themselves complete information -- the other classes are redundant for those who know the class DAG.

      Parameters

      • types: any

        A map of the types

      Returns any

    • Checks a list of statements for consistency

      Parameters

      • sts: readonly Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        The list of statements to check

      • Optional from: number

        An index with the array ['subject', 'predicate', 'object', 'why']

      Returns boolean | void

    • Trace statements which connect directly, or through bnodes

      Parameters

      • subject: Quad_Subject

        The node to start looking for statments

      • doc: Quad_Graph

        The document to be searched, or null to search all documents

      • Optional excludePredicateURIs: readonly string[]

      Returns Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

      an array of statements, duplicate statements are suppresssed.

    • replaces

      Parameters

      • template: Quad_Subject

        node to copy

      • target: Quad_Subject

        node to copy to

      • Optional flags: ("delete" | "two-direction")[]

        Whether or not to do a two-directional copy and/or delete triples

      Returns void

      Target

      and add appropriate triples removes no triples by default and is a one-direction replication

    • Follow links from one node, using one wildcard.

      For example, each(me, knows, null, profile) - people I know accoring to my profile . each(me, knows, null, null) - people I know accoring to anything in store . each(null, knows, me, null) - people who know me accoring to anything in store .

      Parameters

      • Optional s: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional p: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional o: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional g: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      Returns Node[]

      • An array of nodes which match the wildcard position
    • Simplify graph in store when we realize two identifiers are equivalent We replace the bigger with the smaller.

      Parameters

      • u1in: Term

        The first node

      • u2in: Term

        The second node

      Returns boolean

    • For thisClass or any subclass, anything which has it is its type or is the object of something which has the type as its range, or subject of something which has the type as its domain We don't bother doing subproperty (yet?)as it doesn't seeem to be used much. Get all the Classes of which we can RDFS-infer the subject is a member

      Parameters

      • subject: Node

        A named node

      Returns UriMap

    • For thisClass or any subclass, anything which has it is its type or is the object of something which has the type as its range, or subject of something which has the type as its domain We don't bother doing subproperty (yet?)as it doesn't seeem to be used much. Get all the Classes of which we can RDFS-infer the subject is a member

      Parameters

      • thisClass: any

      Returns MembersMap

      a hash of URIs

    • Get all the Classes of which we can RDFS-infer the subject is a superclass Returns a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      Parameters

      Returns {
          [uri: string]: boolean;
      }

      • [uri: string]: boolean
    • Get all the Classes of which we can RDFS-infer the subject is a subclass

      Parameters

      • subject: Node

        The thing whose classes are to be found

      Returns {
          [uri: string]: boolean;
      }

      a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      • [uri: string]: boolean
    • Get all the Classes of which we can RDFS-infer the subject is a member todo: This will loop is there is a class subclass loop (Sublass loops are not illegal) Returns a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      Parameters

      • subject: Quad_Subject

        A subject node

      Returns UriMap

    • Get all the Classes of which we can RDFS-infer the subject is a member todo: This will loop is there is a class subclass loop (Sublass loops are not illegal)

      Parameters

      • subject: any

        The thing whose classes are to be found

      Returns {
          [uri: string]: boolean;
      }

      a hash table where key is NT of type and value is statement why we think so. Does NOT return terms, returns URI strings. We use NT representations in this version because they handle blank nodes.

      • [uri: string]: boolean
    • Creates a new empty indexed formula Only applicable for IndexedFormula, but TypeScript won't allow a subclass to override a property

      Parameters

      • features: FeaturesType

        The list of features

      Returns Store

    • Transforms an NTriples string format into a Node. The blank node bit should not be used on program-external values; designed for internal work such as storing a blank node id in an HTML attribute. This will only parse the strings generated by the various toNT() methods.

      Parameters

      • str: any

      Returns any

    • Returns true if this formula holds the specified statement(s)

      Parameters

      • s: any
      • Optional p: any
      • Optional o: any
      • Optional g: any

      Returns boolean

    • Returns a unique index-safe identifier for the given term.

      Falls back to the rdflib hashString implementation if the given factory doesn't support id.

      Parameters

      • term: TFIDFactoryTypes

      Returns Indexable

    • Used by the n3parser to generate list elements

      Parameters

      • values: any

        The values of the collection

      • context: any

        The store

      Returns any

      • The term for the statement
    • Returns any quads matching the given arguments. Standard RDFJS spec method for Source objects, implemented as an alias to statementsMatching()

      Parameters

      • Optional subject: null | Quad_Subject

        The subject

      • Optional predicate: null | Quad_Predicate

        The predicate

      • Optional object: null | Quad_Object

        The object

      • Optional graph: null | Quad_Graph

        The graph that contains the statement

      Returns Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

    • Find out whether a given URI is used as symbol in the formula

      Parameters

      • uri: string

        The URI to look for

      Returns boolean

    • Adds a new property action

      Parameters

      • pred: Quad_Predicate

        the predicate that the function should be triggered on

      • action: ((store, subject, predicate, object) => boolean)

        the function that should trigger

          • (store, subject, predicate, object): boolean
          • Parameters

            • store: Store
            • subject: Quad_Subject
            • predicate: Quad_Predicate
            • object: Quad_Object

            Returns boolean

      Returns boolean

    • Find an unused id for a file being edited: return a symbol (Note: Slow iff a lot of them -- could be O(log(k)) )

      Parameters

      • doc: NamedNode

        A document named node

      Returns NamedNode

    • Query this store asynchronously, return bindings in callback

      Parameters

      • myQuery: Query

        The query to be run

      • callback: ((bindings) => void)

        Function to call when bindings

          • (bindings): void
          • Parameters

            • bindings: Bindings

            Returns void

      • Optional fetcher: null | Fetcher
      • Optional onDone: (() => void)

        OBSOLETE - do not use this // @@ Why not ?? Called when query complete

          • (): void
          • Returns void

      Returns void

    • Removes one or multiple statement(s) from this formula

      Parameters

      • st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph> | Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>[]

        A Statement or array of Statements to remove

      Returns Store

    • Remove all statements matching args (within limit) *

      Parameters

      • Optional subj: null | Quad_Subject

        The subject

      • Optional pred: null | Quad_Predicate

        The predicate

      • Optional obj: null | Quad_Object

        The object

      • Optional why: null | Quad_Graph

        The graph that contains the statement

      • Optional limit: number

        The number of statements to remove

      Returns void

    • Remove all matching statements

      Parameters

      • Optional subject: null | Quad_Subject

        The subject

      • Optional predicate: null | Quad_Predicate

        The predicate

      • Optional object: null | Quad_Object

        The object

      • Optional graph: null | Quad_Graph

        The graph that contains the statement

      Returns Store

    • Remove a particular statement object from the store

      Parameters

      • st: Quad<Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph>

        a statement which is already in the store and indexed. Make sure you only use this for these. Otherwise, you should use remove() above.

      Returns Store

    • Replace big with small, obsoleted with obsoleting.

      Parameters

      • big: Quad_Subject
      • small: Quad_Subject

      Returns boolean

    • Serializes this formula

      Parameters

      • base: any

        The base string

      • contentType: any

        The content type of the syntax to use

      • provenance: any

        The provenance URI

      • Optional options: any

        options to pass to the serializer, as defined in serialize method

      Returns undefined | string

    • Search the Store

      ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS!

      Parameters

      • Optional subj: null | Quad_Subject

        A node to search for as subject, or if null, a wildcard

      • Optional pred: null | Quad_Predicate

        A node to search for as predicate, or if null, a wildcard

      • Optional obj: null | Quad_Object

        A node to search for as object, or if null, a wildcard

      • Optional why: null | Quad_Graph

        A node to search for as graph, or if null, a wildcard

      • Optional justOne: boolean

        flag - stop when found one rather than get all of them?

      Returns Statement<SubjectType, PredicateType, ObjectType, GraphType>[]

      An array of nodes which match the wildcard position

    • Gets the node matching the specified pattern. Throws when no match could be made.

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns undefined | null | Node

    • Finds the types in the list which have no stored supertypes We exclude the universal class, owl:Things and rdf:Resource, as it is information-free.

      Parameters

      • types: {
            [id: string]: string | NamedNode;
        }

        The types

      Returns {
          [id: string]: string | NamedNode;
      }

    • RDFS Inference These are hand-written implementations of a backward-chaining reasoner over the RDFS axioms.

      Parameters

      • seeds: BooleanMap

        A hash of NTs of classes to start with

      • predicate: Quad_Predicate

        The property to trace though

      • Optional inverse: boolean

        Trace inverse direction

      Returns {
          [uri: string]: boolean;
      }

      • [uri: string]: boolean
    • A list of all the URIs by which this thing is known

      Parameters

      • term: Quad_Subject

      Returns string[]

    • Gets the number of statements in this formula that matches the specified pattern

      Parameters

      • Optional s: null | Quad_Subject

        The subject

      • Optional p: null | Quad_Predicate

        The predicate

      • Optional o: null | Quad_Object

        The object

      • Optional g: null | Quad_Graph

        The graph that contains the statement

      Returns number