Class: Dse::Graph::Vertex

Inherits:
Object
  • Object
show all
Includes:
Cassandra::Util
Defined in:
lib/dse/graph/vertex.rb

Overview

Vertex represents a vertex in DSE graph. Vertices have sophisticated properties. A given property can have multiple values, and each value can have a collection of meta-properties. To access a property of a vertex, you'd reference the #properties hash, and then get the n'th value, which is a VertexProperty, and then get the actual value from there.

Examples:

To get the first value of the 'name' property:

v.properties['name'][0].value

Use array/hash dereference shortcut

v['name'][0].value

Get all of the values of the 'name' property

values = v['name'].map do |vertex_prop|
  vertex_prop.value
end

Use the 'values' method on the array to do the heavy-lifting for you.

values = v['name'].values

VertexProperty exposes meta-properties for a value:

meta1 = v['name'][0].properties['meta1']
# Shortcut
meta1 = v['name'][0]['meta1']

Instance Attribute Summary collapse

Instance Attribute Details

#idHash (readonly)

Returns id of this vertex.

Returns:

  • (Hash)

    id of this vertex.



34
35
36
# File 'lib/dse/graph/vertex.rb', line 34

def id
  @id
end

#labelString (readonly)

Returns label of this vertex.

Returns:

  • (String)

    label of this vertex.



36
37
38
# File 'lib/dse/graph/vertex.rb', line 36

def label
  @label
end

#propertiesHash<String, Array<VertexProperty>> (readonly)

Returns properties of this vertex.

Returns:

  • (Hash<String, Array<VertexProperty>>)

    properties of this vertex.



38
39
40
# File 'lib/dse/graph/vertex.rb', line 38

def properties
  @properties
end