Class: Cql::Client::QueryResult

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/cql/client/query_result.rb

Overview

Query results encapsulate the rows returned by a query.

In addition to containing the rows it contains metadata about the data types of the columns of the rows, and it knows the ID of the trace, if tracing was requested for the query.

When paging over a big result you can use #last_page? to find out if the page is the last, or #next_page to retrieve the next page.

QueryResult is an Enumerable so it can be mapped, filtered, reduced, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#metadataResultMetadata (readonly)

Returns:



19
20
21
# File 'lib/cql/client/query_result.rb', line 19

def 
  @metadata
end

#trace_idCql::Uuid (readonly)

The ID of the query trace associated with the query, if any.

Returns:



24
25
26
# File 'lib/cql/client/query_result.rb', line 24

def trace_id
  @trace_id
end

Instance Method Details

#each {|row| ... } ⇒ Enumerable<Hash> Also known as: each_row

Iterates over each row in the result set.

Yield Parameters:

  • row (Hash)

    each row in the result set as a hash

Returns:

  • (Enumerable<Hash>)


46
47
48
# File 'lib/cql/client/query_result.rb', line 46

def each(&block)
  @rows.each(&block)
end

#empty?Boolean

Returns whether or not there are any rows in this result set

Returns:

  • (Boolean)


38
39
40
# File 'lib/cql/client/query_result.rb', line 38

def empty?
  @rows.empty?
end

#last_page?Boolean

Returns true when there are no more pages to load.

This is only relevant when you have requested paging of the results with the :page_size option to Client#execute or PreparedStatement#execute.

Returns:

  • (Boolean)

See Also:

  • Client#execute


58
59
60
# File 'lib/cql/client/query_result.rb', line 58

def last_page?
  true
end

#next_pageObject

Returns the next page or nil when there is no next page.

This is only relevant when you have requested paging of the results with the :page_size option to Client#execute or PreparedStatement#execute.

See Also:

  • Client#execute


69
70
71
# File 'lib/cql/client/query_result.rb', line 69

def next_page
  nil
end