Class: TinyPresto::TinyPresto

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tiny-presto.rb

Overview

Singleton object representing a Presto cluster running in the local machine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTinyPresto

Returns a new instance of TinyPresto.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tiny-presto.rb', line 16

def initialize
  @cluster = Cluster.new
  @cluster.run
  @client = Presto::Client.new(server: 'localhost:8080', catalog: 'memory', user: 'tiny-user', schema: 'default')
  loop do
    @client.run('show schemas')
    break
  rescue StandardError => _
    # Waiting for the cluster is launched
    sleep(1)
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



14
15
16
# File 'lib/tiny-presto.rb', line 14

def client
  @client
end

#clusterObject (readonly)

Returns the value of attribute cluster.



14
15
16
# File 'lib/tiny-presto.rb', line 14

def cluster
  @cluster
end

Instance Method Details

#stopObject



29
30
31
# File 'lib/tiny-presto.rb', line 29

def stop
  @cluster.stop
end