Class: RDF::Benchmark::BerlinGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/benchmark/berlin_generator.rb

Overview

Constant Summary collapse

DEFAULT_FILENAME =
'dataset'.freeze
DEFAULT_FACTOR =
2_000.freeze
DEFAULT_FORMAT =
'nt'.freeze
DEFAULT_PATH =
'./bsbmtools'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename: DEFAULT_FILENAME, product_factor: DEFAULT_FACTOR, format: DEFAULT_FORMAT, tool_path: DEFAULT_PATH) ⇒ BerlinGenerator

Returns a new instance of BerlinGenerator.

Parameters:

  • filename (String) (defaults to: DEFAULT_FILENAME)

    (default: ‘dataset’)

  • products (Integer)

    (default: 2000)

  • format (String) (defaults to: DEFAULT_FORMAT)

    (default: ‘nt’)



23
24
25
26
27
28
29
30
31
# File 'lib/rdf/benchmark/berlin_generator.rb', line 23

def initialize(filename:       DEFAULT_FILENAME, 
               product_factor: DEFAULT_FACTOR, 
               format:         DEFAULT_FORMAT, 
               tool_path:      DEFAULT_PATH)
  self.filename       = filename
  self.product_factor = product_factor
  self.format         = format
  self.tool_path      = tool_path
end

Instance Attribute Details

#filenameObject



17
18
19
# File 'lib/rdf/benchmark/berlin_generator.rb', line 17

def filename
  @filename
end

#formatObject



17
# File 'lib/rdf/benchmark/berlin_generator.rb', line 17

attr_accessor :filename, :product_factor, :format, :tool_path

#product_factorObject



17
# File 'lib/rdf/benchmark/berlin_generator.rb', line 17

attr_accessor :filename, :product_factor, :format, :tool_path

#tool_pathObject



17
# File 'lib/rdf/benchmark/berlin_generator.rb', line 17

attr_accessor :filename, :product_factor, :format, :tool_path

Instance Method Details

#data(&block) ⇒ RDF::Reader

Returns a stream of the requested data.

Returns:

  • (RDF::Reader)

    a stream of the requested data



35
36
37
38
39
40
# File 'lib/rdf/benchmark/berlin_generator.rb', line 35

def data(&block)
  filepath = Pathname.new(tool_path) + "#{filename}.#{format}"
  generate_data! unless File.exists?(filepath)
  
  RDF::Reader.open(filepath, &block)
end

#generate_data!Boolean

Note:

writes the output of the Berlin data generator to stdout

Generates the data for this instance, writing it to disk.

Returns:

  • (Boolean)

    true if successful



48
49
50
51
52
53
54
55
# File 'lib/rdf/benchmark/berlin_generator.rb', line 48

def generate_data!
  start_dir = Dir.pwd
  
  Dir.chdir tool_path
  system "./generate -pc #{product_factor} -fn #{filename} -fc"
ensure
  Dir.chdir start_dir
end