Class: Neo4j::Driver::Summary::SummaryCounters

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j/driver/summary/summary_counters.rb

Overview

Per-operation counts produced by the query. Mirrors org.neo4j.driver.summary.SummaryCounters.

Constant Summary collapse

COUNTER_KEYS =

Mapping from server metadata keys (kebab-case strings sent on the wire as Symbols) to Ruby attribute names.

{
  'nodes-created': :nodes_created,
  'nodes-deleted': :nodes_deleted,
  'relationships-created': :relationships_created,
  'relationships-deleted': :relationships_deleted,
  'properties-set': :properties_set,
  'labels-added': :labels_added,
  'labels-removed': :labels_removed,
  'indexes-added': :indexes_added,
  'indexes-removed': :indexes_removed,
  'constraints-added': :constraints_added,
  'constraints-removed': :constraints_removed,
  'system-updates': :system_updates
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stats) ⇒ SummaryCounters

Returns a new instance of SummaryCounters.



34
35
36
37
38
39
40
41
42
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 34

def initialize(stats)
  # Initialize all counters to 0 — server only reports nonzero ones.
  COUNTER_KEYS.each_value { |attr| instance_variable_set("@#{attr}", 0) }

  stats.each do |key, value|
    attr_name = COUNTER_KEYS[key]
    instance_variable_set("@#{attr_name}", value.to_i) if attr_name
  end
end

Instance Attribute Details

#constraints_addedObject (readonly)

Returns the value of attribute constraints_added.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def constraints_added
  @constraints_added
end

#constraints_removedObject (readonly)

Returns the value of attribute constraints_removed.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def constraints_removed
  @constraints_removed
end

#indexes_addedObject (readonly)

Returns the value of attribute indexes_added.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def indexes_added
  @indexes_added
end

#indexes_removedObject (readonly)

Returns the value of attribute indexes_removed.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def indexes_removed
  @indexes_removed
end

#labels_addedObject (readonly)

Returns the value of attribute labels_added.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def labels_added
  @labels_added
end

#labels_removedObject (readonly)

Returns the value of attribute labels_removed.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def labels_removed
  @labels_removed
end

#nodes_createdObject (readonly)

Returns the value of attribute nodes_created.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def nodes_created
  @nodes_created
end

#nodes_deletedObject (readonly)

Returns the value of attribute nodes_deleted.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def nodes_deleted
  @nodes_deleted
end

#properties_setObject (readonly)

Returns the value of attribute properties_set.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def properties_set
  @properties_set
end

#relationships_createdObject (readonly)

Returns the value of attribute relationships_created.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def relationships_created
  @relationships_created
end

#relationships_deletedObject (readonly)

Returns the value of attribute relationships_deleted.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def relationships_deleted
  @relationships_deleted
end

#system_updatesObject (readonly)

Returns the value of attribute system_updates.



9
10
11
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 9

def system_updates
  @system_updates
end

Instance Method Details

#contains_system_updates?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 58

def contains_system_updates?
  system_updates.positive?
end

#contains_updates?Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 44

def contains_updates?
  nodes_created.positive? ||
    nodes_deleted.positive? ||
    relationships_created.positive? ||
    relationships_deleted.positive? ||
    properties_set.positive? ||
    labels_added.positive? ||
    labels_removed.positive? ||
    indexes_added.positive? ||
    indexes_removed.positive? ||
    constraints_added.positive? ||
    constraints_removed.positive?
end

#to_hObject



62
63
64
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 62

def to_h
  COUNTER_KEYS.values.to_h { |attr| [attr, instance_variable_get("@#{attr}")] }
end

#to_sObject



66
67
68
# File 'lib/neo4j/driver/summary/summary_counters.rb', line 66

def to_s
  to_h.select { |_, v| v.positive? }.map { |k, v| "#{k}: #{v}" }.join(', ')
end