Class RandomStatementGenerator

java.lang.Object
com.google.common.collect.UnmodifiableIterator<Statement>
com.complexible.common.rdf.random.RandomStatementGenerator
All Implemented Interfaces:
Iterator<Statement>

public class RandomStatementGenerator extends com.google.common.collect.UnmodifiableIterator<Statement>
Generates an infinite sequence of random RDF triples. Configuration options can be used to control what kind of triples are generated.
Since:
3.1.2
Version:
6.0
Author:
Evren Sirin
  • Constructor Details

    • RandomStatementGenerator

      public RandomStatementGenerator()
    • RandomStatementGenerator

      public RandomStatementGenerator(RandomValueGenerator theRandomValueGenerator)
  • Method Details

    • hasNext

      public boolean hasNext()
    • getNumberOfDistinctProperties

      public int getNumberOfDistinctProperties()
    • setNumberOfDistinctProperties

      public void setNumberOfDistinctProperties(int theNumberOfDistinctProperties)
      Sets the number of distinct properties to be used. If set to 0, completely random set of properties will be generated.
    • getNumberOfStatementsPerSubject

      public int getNumberOfStatementsPerSubject()
    • setNumberOfStatementsPerSubject

      public void setNumberOfStatementsPerSubject(int theNumberOfStatementsPerSubject)
      Sets the number of statements to be generated for a given subject. Set to 0 to use completely random set of properties.
    • getNumberOfDistinctClasses

      public int getNumberOfDistinctClasses()
    • setNumberOfDistinctClasses

      public void setNumberOfDistinctClasses(int theNumberOfDistinctClasses)
      Sets the number of distinct classes to be used as types. If set to 0, no rdf:type triples will be generated.
    • getNumberOfSubjectsPerGraph

      public int getNumberOfSubjectsPerGraph()
    • setNumberOfSubjectsPerGraph

      public void setNumberOfSubjectsPerGraph(int theNumberOfSubjectsPerGraph)
      Sets the number of subjects generated per graph. Default is 0 which means no named graphs are generated. Set to Integer.MAX_VALUE to generate a single named graph.
    • next

      public Statement next()
      Returns the next random triple.
    • randomGraph

      public static Set<Statement> randomGraph(Random rnd, int numNodes, int numEdges, List<IRI> predicates)
      A utility method to generate a simple random graph with the given number of nodes and edges chosen at random from the provided list of predicates. Should not be used for any kind of performance tests because the graph is unlikely to exhibit realistic properties.
    • randomSubjects

      public static List<Resource> randomSubjects(Set<Statement> data, Random rnd, int size)
    • pickFrom

      public static <T> T pickFrom(List<? extends T> resources, Random rnd)
    • main

      public static void main(String[] args)