class Roma::Storage::GroongaStorage::GroongaHash
Public Class Methods
new(fname)
click to toggle source
# File lib/roma/storage/groonga_storage.rb 34 def initialize(fname) 35 @fname = fname 36 end
Public Instance Methods
close()
click to toggle source
# File lib/roma/storage/groonga_storage.rb 93 def close 94 @database.close 95 @context.close 96 @hash = @value = @database = @context = nil 97 end
each() { |key, value| ... }
click to toggle source
# File lib/roma/storage/groonga_storage.rb 67 def each 68 @hash.each do |record| 69 yield(record.key, @value[record.id]) 70 end 71 end
get(key)
click to toggle source
# File lib/roma/storage/groonga_storage.rb 47 def get(key) 48 record = @hash[key] 49 return nil if record.nil? 50 @value[record.id] 51 end
open()
click to toggle source
# File lib/roma/storage/groonga_storage.rb 73 def open 74 @context = Groonga::Context.new(:encoding => :none) 75 if File.exist?(@fname) 76 @database = Groonga::Database.new(@fname, :context => @context) 77 else 78 @database = Groonga::Database.create(:context => @context, 79 :path => @fname) 80 Groonga::Schema.define(:context => @context) do |schema| 81 schema.create_table("hash", 82 :type => :hash, 83 :key_type => "ShortText") do |table| 84 table.text("value") 85 end 86 end 87 end 88 89 @hash = @context["hash"] 90 @value = @hash.column("value") 91 end
out(key)
click to toggle source
# File lib/roma/storage/groonga_storage.rb 53 def out(key) 54 record = @hash[key] 55 if record 56 record.delete 57 true 58 else 59 false 60 end 61 end
path()
click to toggle source
# File lib/roma/storage/groonga_storage.rb 38 def path 39 @hash.path 40 end
put(key, value)
click to toggle source
# File lib/roma/storage/groonga_storage.rb 42 def put(key, value) 43 record = @hash.add(key) 44 @value[record.id] = value 45 end
rnum()
click to toggle source
# File lib/roma/storage/groonga_storage.rb 63 def rnum 64 @hash.count 65 end