Class: Google::Cloud::Bigquery::Data
- Inherits:
-
Array
- Object
- Array
- Google::Cloud::Bigquery::Data
- Defined in:
- lib/google/cloud/bigquery/data.rb
Overview
Data
Represents Table Data as a list of name/value pairs.
Also contains metadata such as etag
and total
.
Direct Known Subclasses
Instance Method Summary collapse
- #all(request_limit: nil) {|row| ... } ⇒ Enumerator
-
#etag ⇒ Object
The etag.
-
#fields ⇒ Object
The fields of the data.
-
#headers ⇒ Object
The name of the columns in the data.
-
#kind ⇒ Object
The resource type of the API response.
-
#next ⇒ Data
Retrieve the next page of data.
-
#next? ⇒ Boolean
Whether there is a next page of data.
-
#schema ⇒ Object
The schema of the data.
-
#token ⇒ Object
A token used for paging results.
-
#total ⇒ Object
The total number of rows in the complete table.
Instance Method Details
#all(request_limit: nil) {|row| ... } ⇒ Enumerator
Retrieves all rows by repeatedly loading #next until #next?
returns false
. Calls the given block once for each row, which is
passed as the parameter.
An Enumerator is returned if no block is given.
This method may make several API calls until all rows are retrieved. Be sure to use as narrow a search criteria as possible. Please use with caution.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/google/cloud/bigquery/data.rb', line 181 def all request_limit: nil request_limit = request_limit.to_i if request_limit unless block_given? return enum_for(:all, request_limit: request_limit) end results = self loop do results.each { |r| yield r } if request_limit request_limit -= 1 break if request_limit < 0 end break unless results.next? results = results.next end end |
#etag ⇒ Object
The etag.
51 52 53 |
# File 'lib/google/cloud/bigquery/data.rb', line 51 def etag @gapi.etag end |
#fields ⇒ Object
The fields of the data.
76 77 78 |
# File 'lib/google/cloud/bigquery/data.rb', line 76 def fields schema.fields end |
#headers ⇒ Object
The name of the columns in the data.
82 83 84 |
# File 'lib/google/cloud/bigquery/data.rb', line 82 def headers schema.headers end |
#kind ⇒ Object
The resource type of the API response.
45 46 47 |
# File 'lib/google/cloud/bigquery/data.rb', line 45 def kind @gapi.kind end |
#next ⇒ Data
Retrieve the next page of data.
124 125 126 127 128 |
# File 'lib/google/cloud/bigquery/data.rb', line 124 def next return nil unless next? ensure_table! table.data token: token end |
#next? ⇒ Boolean
Whether there is a next page of data.
103 104 105 |
# File 'lib/google/cloud/bigquery/data.rb', line 103 def next? !token.nil? end |
#schema ⇒ Object
The schema of the data.
70 71 72 |
# File 'lib/google/cloud/bigquery/data.rb', line 70 def schema table.schema end |
#token ⇒ Object
A token used for paging results.
57 58 59 |
# File 'lib/google/cloud/bigquery/data.rb', line 57 def token @gapi.page_token end |
#total ⇒ Object
The total number of rows in the complete table.
62 63 64 65 66 |
# File 'lib/google/cloud/bigquery/data.rb', line 62 def total Integer @gapi.total_rows rescue nil end |