Method: QueryResult#parse_resultset
- Defined in:
- lib/redisgraph/query_result.rb
#parse_resultset(response) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/redisgraph/query_result.rb', line 48 def parse_resultset(response) # In the v2 protocol, CREATE does not contain an empty row preceding statistics return unless response.length > 1 # Any non-empty result set will have multiple rows (arrays) # First row is header describing the returned records, corresponding # precisely in order and naming to the RETURN clause of the query. header = response[0] @columns = header.map { |(_type, name)| name } # Second row is the actual data returned by the query # note handling for encountering an id for propertyKey that is out of # the cached set. data = response[1].map do |row| i = -1 header.reduce([]) do |agg, (type, _it)| i += 1 el = row[i] agg << map_scalar(el[0], el[1]) end end data end |