Class: VertxSql::SQLRowStream

Inherits:
Object
  • Object
show all
Includes:
Vertx::ReadStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb

Overview

A ReadStream of Rows from the underlying RDBMS. This class follows the ReadStream semantics and will automatically close the underlying resources if all returned rows are returned. For cases where the results are ignored before the full processing of the returned rows is complete the close method **MUST** be called in order to release underlying resources. The interface is minimal in order to support all SQL clients not just JDBC.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 24

def @@j_api_type.accept?(obj)
  obj.class == SQLRowStream
end

+ (Object) j_api_type



33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 33

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



36
37
38
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 36

def self.j_class
  Java::IoVertxExtSql::SQLRowStream.java_class
end

+ (Object) unwrap(obj)



30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 30

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 27

def @@j_api_type.wrap(obj)
  SQLRowStream.new(obj)
end

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Closes the stream/underlying cursor(s). The actual close happens asynchronously.

Yields:

  • called when the stream/underlying cursor(s) is(are) closed

Raises:

  • (ArgumentError)


134
135
136
137
138
139
140
141
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 134

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  elsif block_given?
    return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (Fixnum) column(name = nil)

Will convert the column name to the json array index.

Parameters:

  • name (String) (defaults to: nil)
    the column name

Returns:

  • (Fixnum)
    the json array index

Raises:

  • (ArgumentError)


97
98
99
100
101
102
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 97

def column(name=nil)
  if name.class == String && !block_given?
    return @j_del.java_method(:column, [Java::java.lang.String.java_class]).call(name)
  end
  raise ArgumentError, "Invalid arguments when calling column(#{name})"
end

- (Array<String>) columns

Returns all column names available in the underlying resultset. One needs to carefully use this method since in contrast to the singular version it does not perform case insensitive lookups or takes alias in consideration on the column names.

Returns:

  • (Array<String>)
    the list of columns names returned by the query

Raises:

  • (ArgumentError)


107
108
109
110
111
112
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 107

def columns
  if !block_given?
    return @j_del.java_method(:columns, []).call().to_a.map { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling columns()"
end

- (self) end_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


87
88
89
90
91
92
93
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 87

def end_handler
  if block_given?
    @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling end_handler()"
end

- (self) exception_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


53
54
55
56
57
58
59
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 53

def exception_handler
  if block_given?
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) fetch(amount = nil)

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 44

def fetch(amount=nil)
  if amount.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(amount)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{amount})"
end

- (self) handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


62
63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 62

def handler
  if block_given?
    @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.encode) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler()"
end

- (void) more_results

This method returns an undefined value.

Request for more results if available

Raises:

  • (ArgumentError)


125
126
127
128
129
130
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 125

def more_results
  if !block_given?
    return @j_del.java_method(:moreResults, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling more_results()"
end

- (self) pause

Returns:

  • (self)

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 70

def pause
  if !block_given?
    @j_del.java_method(:pause, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling pause()"
end

- (self) result_set_closed_handler { ... }

Event handler when a resultset is closed. This is useful to request for more results.

Yields:

  • called when the current result set is closed

Returns:

  • (self)

Raises:

  • (ArgumentError)


116
117
118
119
120
121
122
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 116

def result_set_closed_handler
  if block_given?
    @j_del.java_method(:resultSetClosedHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling result_set_closed_handler()"
end

- (self) resume

Returns:

  • (self)

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-sql/sql_row_stream.rb', line 78

def resume
  if !block_given?
    @j_del.java_method(:resume, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling resume()"
end