Module: Neo4j::Core::PackStream

Defined in:
lib/neo4j/core/cypher_session/adaptors/bolt/pack_stream.rb

Overview

Implements the the PackStream packing and unpacking specifications as specified by Neo Technology for the Neo4j graph database

Defined Under Namespace

Classes: Packer, Structure, Unpacker

Constant Summary collapse

MARKER_TYPES =
{
  C0: nil,
  C1: [:float, 64],
  C2: false,
  C3: true,
  C8: [:int, 8],
  C9: [:int, 16],
  CA: [:int, 32],
  CB: [:int, 64],
  CC: [:bytes, 8],
  CD: [:bytes, 16],
  CE: [:bytes, 32],
  D0: [:text, 8],
  D1: [:text, 16],
  D2: [:text, 32],
  D4: [:list, 8],
  D5: [:list, 16],
  D6: [:list, 32],
  D8: [:map, 8],
  D9: [:map, 16],
  DA: [:map, 32],
  DC: [:struct, 8],
  DD: [:struct, 16],
  DE: [:struct, 32]
}
MARKER_BYTES =

Translates directly from types to bytes

MARKER_TYPES.invert
MARKER_HEADERS =
MARKER_TYPES.each_with_object({}) do |(byte, (type, size)), headers|
  headers[type] ||= {}
  headers[type][size] = [byte].pack('C')
end
HEADER_PACK_STRINGS =
%w[C S L].freeze

Class Method Summary collapse

Class Method Details

.marker_type_and_size(marker) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/neo4j/core/cypher_session/adaptors/bolt/pack_stream.rb', line 274

def self.marker_type_and_size(marker)
  if (marker_spec = MARKER_TYPES[marker]).is_a?(Array)
    marker_spec
  else
    case marker
    when 0x80..0x8F then [:tiny_text, marker - 0x80]
    when 0x90..0x9F then [:tiny_list, marker - 0x90]
    when 0xA0..0xAF then [:tiny_map, marker - 0xA0]
    when 0xB0..0xBF then [:tiny_struct, marker - 0xB0]
    end
  end
end