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, create, #indexed?, #required?, valid_data_type?

Constructor Details

#initialize(tbl_class, name, col_def) ⇒ SkipListIndexColumn

Returns a new instance of SkipListIndexColumn.



148
149
150
151
# File 'lib/mongoose/column.rb', line 148

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

Instance Method Details

#<(other) ⇒ Object



165
166
167
# File 'lib/mongoose/column.rb', line 165

def <(other)
  @tbl_class.query << [@idx, :<, other]
end

#<=(other) ⇒ Object



169
170
171
# File 'lib/mongoose/column.rb', line 169

def <=(other)
  @tbl_class.query << [@idx, :<=, other]
end

#==(other) ⇒ Object



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

def ==(other)
  @tbl_class.query << [@idx, :==, other]
end

#>(other) ⇒ Object



157
158
159
# File 'lib/mongoose/column.rb', line 157

def >(other)
  @tbl_class.query << [@idx, :>, other]
end

#>=(other) ⇒ Object



161
162
163
# File 'lib/mongoose/column.rb', line 161

def >=(other)
  @tbl_class.query << [@idx, :>=, other]
end

#add_index_rec(key, value) ⇒ Object



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

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

#between(*other) ⇒ Object



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

def between(*other)
  @tbl_class.query << [@idx, :between, other]
end

#clear_indexObject



153
154
155
# File 'lib/mongoose/column.rb', line 153

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

#one_of(*other) ⇒ Object



185
186
187
# File 'lib/mongoose/column.rb', line 185

def one_of(*other)
  @tbl_class.query << [@idx, :one_of, other]
end

#rebuild_index_fileObject



189
190
191
# File 'lib/mongoose/column.rb', line 189

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

#rebuild_index_from_index_fileObject



202
203
204
205
# File 'lib/mongoose/column.rb', line 202

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

#rebuild_index_from_tableObject



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

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



211
212
213
# File 'lib/mongoose/column.rb', line 211

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

#search(other) ⇒ Object



177
178
179
# File 'lib/mongoose/column.rb', line 177

def search(other)
  @tbl_class.query << [@idx, :search, other]
end