Class: Mongoose::IDColumn

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

Overview


IDColumn 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) ⇒ IDColumn


initialize




238
239
240
241
# File 'lib/mongoose/column.rb', line 238

def initialize(tbl_class, name, col_def)
  @idx = {}
  super
end

Instance Method Details

#<(other) ⇒ Object


<




267
268
269
# File 'lib/mongoose/column.rb', line 267

def <(other)
  return @idx.keys.select { |k| k < other }
end

#<=(other) ⇒ Object


<=




274
275
276
# File 'lib/mongoose/column.rb', line 274

def <=(other)
  return @idx.keys.select { |k| k <= other }
end

#>(other) ⇒ Object


>




253
254
255
# File 'lib/mongoose/column.rb', line 253

def >(other)
  return @idx.keys.select { |k| k > other }
end

#>=(other) ⇒ Object


>=




260
261
262
# File 'lib/mongoose/column.rb', line 260

def >=(other)
  return @idx.keys.select { |k| k >= other }
end

#add_index_rec(id, fpos) ⇒ Object


add_index_rec




329
330
331
# File 'lib/mongoose/column.rb', line 329

def add_index_rec(id, fpos)
  @idx[id] = fpos
end

#between(search_start, search_end, start_inclusive = false, end_inclusive = false) ⇒ Object


between




281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/mongoose/column.rb', line 281

def between(search_start, search_end, start_inclusive=false, 
 end_inclusive=false)
  return @idx.keys.select do |k| 
    if k == search_start and start_inclusive
      true
    elsif k > search_start and k < search_end
      true
    elsif k == search_end and end_inclusive
      true
    else
      false
    end
  end
end

#clear_indexObject


clear_index




246
247
248
# File 'lib/mongoose/column.rb', line 246

def clear_index
  @idx = {}
end

#one_of(*other) ⇒ Object


one_of




299
300
301
# File 'lib/mongoose/column.rb', line 299

def one_of(*other)
  return @idx.keys.select { |k| other.include?(k) }
end

#rebuild_index_fileObject


rebuild_index_file




306
307
308
# File 'lib/mongoose/column.rb', line 306

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

#rebuild_index_from_index_fileObject


rebuild_index_from_index_file




321
322
323
324
# File 'lib/mongoose/column.rb', line 321

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

#rebuild_index_from_tableObject


rebuild_index_from_table




313
314
315
316
# File 'lib/mongoose/column.rb', line 313

def rebuild_index_from_table
  clear_index
  @tbl_class.get_all_recs { |rec, fpos| add_index_rec(rec[0], fpos) }
end

#remove_index_rec(id) ⇒ Object


remove_index_rec




336
337
338
# File 'lib/mongoose/column.rb', line 336

def remove_index_rec(id)
  @idx.delete(id)
end