Module: PKIAdapter

Includes:
TSVAdapter
Defined in:
lib/scout/persist/tsv/adapter/packed_index.rb

Constant Summary

Constants included from TSVAdapter

TSVAdapter::ANNOTATION_ATTR_HASH_KEY, TSVAdapter::ANNOTATION_ATTR_HASH_SERIALIZER, TSVAdapter::MAX_CHAR, TSVAdapter::SERIALIZER_ALIAS

Instance Attribute Summary collapse

Attributes included from TSVAdapter

#closed, #persistence_class, #persistence_path, #serializer, #writable

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TSVAdapter

#close, #closed?, #collect, #delete, #each_annotation_hash_key, #get_prefix, #keys_annotation_hash_key, #load_value, #lock, #lock_and_close, #merge!, #orig_get, #orig_set, #prefix, #range, #read, #read?, #read_and_close, #read_lock, #save_value, serializer_module, #size_annotation_hash_key, #values, #values_at, #with_read, #with_write, #write, #write?, #write_and_close, #write_and_read, #write_lock

Instance Attribute Details

#pos_functionObject

Returns the value of attribute pos_function.



7
8
9
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 7

def pos_function
  @pos_function
end

Class Method Details

.extended(base) ⇒ Object



9
10
11
12
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 9

def self.extended(base)
  base.extend TSVAdapter
  base
end

Instance Method Details

#[](key, clean = false) ⇒ Object



31
32
33
34
35
36
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 31

def [](key, clean = false)
  key = pos_function.call(key) if pos_function and not clean
  res = super(key)
  res.extend MultipleResult unless res.nil?
  res
end

#[]=(key, value) ⇒ Object



42
43
44
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 42

def []=(key, value)
  add key, value
end

#add(key, value) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 46

def add(key, value)
  key = pos_function.call(key) if pos_function 
  if Numeric === key
    @_last ||= -1
    skipped = key - @_last - 1
    skipped.times do
      self.send(:<<, nil)
    end
    @_last = key
  end
  self.send(:<<, value)
end

#add_range_point(key, value) ⇒ Object



59
60
61
62
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 59

def add_range_point(key, value)
  key = pos_function.call(key) if pos_function
  super(key, value)
end

#eachObject



69
70
71
72
73
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 69

def each
  size.times do |i|
    yield i, value(i)
  end
end

#include?(i) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 64

def include?(i)
  return true if Numeric === i and i < size
  false
end

#keysObject



75
76
77
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 75

def keys
  []
end

#load_annotation_hashObject



23
24
25
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 23

def load_annotation_hash
  ANNOTATION_ATTR_HASH_SERIALIZER.load(Open.read(, mode: 'rb'))
end

#metadata_fileObject



19
20
21
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 19

def 
  @metadata_file ||= self.persistence_path + '.metadata'
end

#persistence_path=(value) ⇒ Object



14
15
16
17
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 14

def persistence_path=(value)
  @persistence_path = value
  @file = value
end

#save_annotation_hashObject



27
28
29
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 27

def save_annotation_hash
  Open.write(, ANNOTATION_ATTR_HASH_SERIALIZER.dump(self.annotation_hash), mode: 'wb')
end

#sizeObject



79
80
81
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 79

def size
  orig_size
end

#value(pos) ⇒ Object



38
39
40
# File 'lib/scout/persist/tsv/adapter/packed_index.rb', line 38

def value(pos)
  self.send(:[], pos, true)
end