Class: Mongoose::SkipListIndexColumn

Inherits:
IndexedColumn show all
Defined in:
lib/mongoose/column.rb

Overview


SkipListIndexColumn class


Instance Attribute Summary

Attributes inherited from IndexedColumn

#idx, #index_file_name

Attributes inherited from BaseColumn

#data_type, #name, #required, #tbl_class

Instance Method Summary collapse

Methods inherited from IndexedColumn

#close, #index_file_out_of_date?, #init_index, #with_index_file

Methods inherited from BaseColumn

#close, #convert_to_native, create, #indexed?, #required?, valid_data_type?

Constructor Details

#initialize(tbl_class, name, col_def) ⇒ SkipListIndexColumn


initialize




172
173
174
175
# File 'lib/mongoose/column.rb', line 172

def initialize(tbl_class, name, col_def)
  @idx = SkipList.new(self)
  super
end

Instance Method Details

#add_index_rec(key, value) ⇒ Object


add_index_rec




214
215
216
# File 'lib/mongoose/column.rb', line 214

def add_index_rec(key, value)
  @idx.store(key, value)
end

#clear_indexObject


clear_index




180
181
182
# File 'lib/mongoose/column.rb', line 180

def clear_index
  @idx = SkipList.new(self)
end

#rebuild_index_fileObject


rebuild_index_file




187
188
189
# File 'lib/mongoose/column.rb', line 187

def rebuild_index_file
  with_index_file('w') { |fptr| fptr.write(Marshal.dump(@idx.dump_to_hash)) }
end

#rebuild_index_from_index_fileObject


rebuild_index_from_index_file




206
207
208
209
# File 'lib/mongoose/column.rb', line 206

def rebuild_index_from_index_file
  clear_index
  with_index_file { |fptr| @idx.load_from_hash(Marshal.load(fptr)) }
end

#rebuild_index_from_tableObject


rebuild_index_from_table




194
195
196
197
198
199
200
201
# File 'lib/mongoose/column.rb', line 194

def rebuild_index_from_table
  clear_index
  i = @tbl_class.columns.index(self)

  @tbl_class.get_all_recs do |rec, fpos|
    add_index_rec(rec[i], rec[0]) unless rec[i].nil?
  end
end

#remove_index_rec(key, value) ⇒ Object


remove_index_rec




221
222
223
# File 'lib/mongoose/column.rb', line 221

def remove_index_rec(key, value)
  @idx.remove(key, value)
end