Class: ReactivePgClient::PgCursor

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb

Overview

A cursor that reads progressively the rows from Postgres, it is usefull for reading very large result.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

18
19
20
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 18

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

+ (Object) j_api_type


27
28
29
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 27

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


30
31
32
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 30

def self.j_class
  Java::IoReactiversePgclient::PgCursor.java_class
end

+ (Object) unwrap(obj)


24
25
26
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 24

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

+ (Object) wrap(obj)


21
22
23
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 21

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

Instance Method Details

- (void) close { ... }

This method returns an undefined value.

Like #close but with a completionHandler called when the cursor has been released.

Yields:

Raises:

  • (ArgumentError)

55
56
57
58
59
60
61
62
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 55

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

- (true, false) has_more?

Returns true when the cursor has results in progress and the should be called to retrieve them.

Returns:

  • (true, false)
    whether the cursor has more results,

Raises:

  • (ArgumentError)

46
47
48
49
50
51
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 46

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

- (void) read(count = nil) { ... }

This method returns an undefined value.

Read rows from the cursor, the result is provided asynchronously to the handler.

Parameters:

  • count (Fixnum) (defaults to: nil)
    the amount of rows to read

Yields:

  • the handler for the result

Raises:

  • (ArgumentError)

37
38
39
40
41
42
# File '/Users/julien/java/reactive-pg-client/target/classes/reactive-pg-client/pg_cursor.rb', line 37

def read(count=nil)
  if count.class == Fixnum && block_given?
    return @j_del.java_method(:read, [Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(count,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::ReactivePgClient::PgRowSet) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling read(#{count})"
end