Sha256: dd93ad52bc7528689f3b41a2bcd5631778444513001f7befdba1007a08f29b3a

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

module Cadet
  module CadetIndex
    class Index
      def initialize(lucene_index, name, type)
        @name = name
        @type = type
        @index = {}
        @lucene_index = lucene_index
      end

      def add(node, property, value)
        @index[property] ||= {}
        @index[property][value] = node
      end

      def get(property, value)
        @index[property] ||= {}
        [@index[property][value]]
      end

      def flush
        index = @lucene_index.nodeIndex(@name, @type)

        @index.each do |property, mappings|
          mappings.each do |value, node|
            index.add(node, {property.to_java_string => value})
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cadet-0.0.9-java lib/cadet/cadet_index/index.rb
cadet-0.0.8-java lib/cadet/cadet_index/index.rb