Class: Neo4j::Driver::Summary::ResultSummary
- Inherits:
-
Object
- Object
- Neo4j::Driver::Summary::ResultSummary
- Defined in:
- lib/neo4j/driver/summary/result_summary.rb
Overview
Summary of query execution. Mirrors Java's
org.neo4j.driver.summary.ResultSummary — same name and place in
the namespace; no public metadata accessor, no Bolt-wire-format
leakage.
Instance Method Summary collapse
- #counters ⇒ Object
- #database ⇒ Object
-
#gql_status_objects ⇒ Object
GQL status objects.
- #has_plan? ⇒ Boolean
- #has_profile? ⇒ Boolean
-
#initialize(metadata, query_text = nil, parameters = {}, connection = nil, had_record: false) ⇒ ResultSummary
constructor
A new instance of ResultSummary.
-
#notifications ⇒ Object
Bolt 5.5+ servers report query info via
statuses(GQL status objects) rather than the legacynotificationslist. - #plan ⇒ Object
- #profile ⇒ Object
- #query ⇒ Object
-
#query_profile ⇒ Object
MRI has a single profile concept; the modern (JRuby 6.2) query_profile accessor maps to it.
-
#query_type ⇒ Object
Mirrors Java's ResultSummary#queryType — returns nil only when the server omitted the :type field (testkit relies on this).
-
#result_available_after ⇒ Object
Time until results are available (milliseconds).
-
#result_consumed_after ⇒ Object
Time to consume results (milliseconds).
- #server ⇒ Object
Constructor Details
#initialize(metadata, query_text = nil, parameters = {}, connection = nil, had_record: false) ⇒ ResultSummary
Returns a new instance of ResultSummary.
11 12 13 14 15 16 17 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 11 def initialize(, query_text = nil, parameters = {}, connection = nil, had_record: false) @metadata = @query_text = query_text @parameters = parameters @connection = connection @had_record = had_record end |
Instance Method Details
#counters ⇒ Object
42 43 44 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 42 def counters @counters ||= SummaryCounters.new(@metadata[:stats] || {}) end |
#database ⇒ Object
61 62 63 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 61 def database @database_info ||= DatabaseInfo.new(@metadata[:db]) end |
#gql_status_objects ⇒ Object
GQL status objects. Bolt 5.6+ servers report them natively in the
summary statuses list, which we preserve verbatim (server order —
the driver must not reorder them). Older servers (or any SUCCESS
without statuses) don't, so we synthesise the list from the legacy
notifications plus a mandatory outcome status — the pre-5.6
backfill. A status carrying a neo4j_code is also a notification
(GqlNotification); the rest are plain status objects.
123 124 125 126 127 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 123 def gql_status_objects (@metadata[:statuses] || polyfilled_statuses).map do |status| (status[:neo4j_code] ? GqlNotification : GqlStatusObject).new(status) end end |
#has_plan? ⇒ Boolean
98 99 100 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 98 def has_plan? !@metadata[:plan].nil? || !@metadata[:profile].nil? end |
#has_profile? ⇒ Boolean
102 103 104 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 102 def has_profile? !@metadata[:profile].nil? end |
#notifications ⇒ Object
Bolt 5.5+ servers report query info via statuses (GQL status
objects) rather than the legacy notifications list. Statuses
without a neo4j_code are pure-GQL info (e.g. "successful
completion") and have no legacy-notification equivalent, so we
drop them; the rest are reshaped to look like notifications.
111 112 113 114 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 111 def notifications (@metadata[:notifications] || statuses_as_notifications) .map { |n| Notification.new(n) } end |
#plan ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 75 def plan return @plan if defined?(@plan) @plan = if @metadata[:plan] Plan.new(@metadata[:plan]) elsif @metadata[:profile] # A profiled query exposes both: `plan` is the plan-only view # (no stats), `profile` adds them. Distinct objects, matching # the Java driver 6.2 model. Plan.new(@metadata[:profile]) end end |
#profile ⇒ Object
88 89 90 91 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 88 def profile return @profile if defined?(@profile) @profile = @metadata[:profile] ? Profile.new(@metadata[:profile]) : nil end |
#query ⇒ Object
19 20 21 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 19 def query Query.new(@query_text, @parameters) end |
#query_profile ⇒ Object
MRI has a single profile concept; the modern (JRuby 6.2) query_profile accessor maps to it. MRI doesn't advertise OptionalStats, so absent stats still default to 0 (testkit uses its strict-driver path).
96 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 96 def query_profile = profile |
#query_type ⇒ Object
Mirrors Java's ResultSummary#queryType — returns nil only when the server omitted the :type field (testkit relies on this). A field that is present but holds anything other than a known code — an unrecognised string, or an explicit null — is a protocol violation, so we raise (Java's extractQueryType chokes on those too) rather than silently returning nil.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 29 def query_type return nil unless @metadata.key?(:type) case @metadata[:type] when 'r' then QueryType::READ_ONLY when 'w' then QueryType::WRITE_ONLY when 'rw' then QueryType::READ_WRITE when 's' then QueryType::SCHEMA_WRITE else raise Exceptions::ProtocolException, "Unexpected query type: #{@metadata[:type].inspect}" end end |
#result_available_after ⇒ Object
Time until results are available (milliseconds). 't_first' on the wire.
66 67 68 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 66 def result_available_after @metadata[:t_first] end |
#result_consumed_after ⇒ Object
Time to consume results (milliseconds). 't_last' on the wire.
71 72 73 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 71 def result_consumed_after @metadata[:t_last] end |
#server ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/neo4j/driver/summary/result_summary.rb', line 46 def server @server_info ||= if @metadata[:server] ServerInfo.new(@metadata[:server]) elsif @connection ServerInfo.new( address: @connection.address, agent: @connection.server_agent, protocol_version: @connection.protocol&.version ) else ServerInfo.new(nil) end end |