Class: MiqSqlite3DB::MiqSqlite3Cell
- Inherits:
-
Object
- Object
- MiqSqlite3DB::MiqSqlite3Cell
- Defined in:
- lib/db/MiqSqlite/MiqSqlite3Cell.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#key ⇒ Object
Returns the value of attribute key.
-
#left_child ⇒ Object
Returns the value of attribute left_child.
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Instance Method Summary collapse
- #dump ⇒ Object
- #fields ⇒ Object
-
#initialize(page, pointer) ⇒ MiqSqlite3Cell
constructor
A new instance of MiqSqlite3Cell.
Constructor Details
#initialize(page, pointer) ⇒ MiqSqlite3Cell
Returns a new instance of MiqSqlite3Cell.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 11 def initialize(page, pointer) @page = page @pointer = pointer @data = @key = @left_child = @fields = nil offset = nData = 0 unless @page.leaf @left_child = @page.buf[@pointer + offset, 4].unpack('N')[0] offset += 4 end if @page.hasData nData, count = MiqSqlite3DB.variableInteger(@page.buf[@pointer + offset, 9]) offset += count end nKey, count = MiqSqlite3DB.variableInteger(@page.buf[@pointer + offset, 9]) offset += count if @page.intKey @key = nKey nKey = 0 end getPayload(nData, nKey, offset) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 9 def data @data end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 9 def key @key end |
#left_child ⇒ Object
Returns the value of attribute left_child.
9 10 11 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 9 def left_child @left_child end |
#pointer ⇒ Object
Returns the value of attribute pointer.
9 10 11 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 9 def pointer @pointer end |
Instance Method Details
#dump ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 79 def dump puts "======== Dumping Cell =========" puts "Page: #{@page.pagenum}" puts "Cell: #{@pointer}" puts "Left Child: #{@left_child}" if @left_child puts "Key: #{@key}" if @key puts "Data: #{@data}" if @data puts "Data Length: #{@data.size}" if @data fields.each do |f| p f end end |
#fields ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 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 73 74 75 76 77 |
# File 'lib/db/MiqSqlite/MiqSqlite3Cell.rb', line 37 def fields return @fields if @fields return nil if @data.nil? len = @data[0].ord @fields = [] offset = len byte = 1 while byte < len val, count = MiqSqlite3DB.variableInteger(@data[byte..-1]) byte += count flen, type = decodeField(val) field = {} if flen == 0 if type == 'null' field['type'] = 'text' field['data'] = nil else field['type'] = 'boolean' field['data'] = true if type == 'true' field['data'] = false if type == 'false' end else field['len'] = flen field['type'] = type fdata = @data[offset, flen] offset += flen if type == 'integer' fdata = "\x00".concat(fdata) if flen == 3 field['data'] = fdata.unpack("C")[0] if flen == 1 field['data'] = fdata.unpack("n")[0] if flen == 2 field['data'] = fdata.unpack("N")[0] if flen == 3 || flen == 4 else field['data'] = fdata end end @fields << field end @fields end |