Class: Ferret::Store::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/ferret/store/directory.rb,
ext/ram_directory.c

Overview

A Directory is an object which is used to access the index storage. Ruby’s IO API is not used so that we can use different storage mechanisms to store the index. Some examples are;

  • File system based storage

  • RAM based storage

  • Database based storage

NOTE: Once a file has been written and closed, it can no longer be modified. To make any changes to the file it must be deleted and rewritten. For this reason, the method to open a file for writing is called create_output, while the method to open a file for reading is called open_input If there is a risk of simultaneous modifications of the files then locks should be used. See Lock to find out how.

Direct Known Subclasses

FSDirectory, RAMDirectory

Instance Method Summary collapse

Instance Method Details

#closeObject

Closes the store.

Raises:

  • (NotImplementedError)


78
79
80
# File 'lib/ferret/store/directory.rb', line 78

def close
  raise NotImplementedError
end

#create_output(file_name) ⇒ Object

Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

Raises:

  • (NotImplementedError)


63
64
65
# File 'lib/ferret/store/directory.rb', line 63

def create_output(file_name)
  raise NotImplementedError
end

#delete(file) ⇒ Object

Removes an existing file in the directory.

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/ferret/store/directory.rb', line 45

def delete(file)
  raise NotImplementedError
end

#eachObject

returns an array of strings, one for each file in the directory

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/ferret/store/directory.rb', line 18

def each # :yeilds: file_name
  raise NotImplementedError
end

#exists?(file) ⇒ Boolean

Returns true if a file with the given name exists.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/ferret/store/directory.rb', line 30

def exists?(file)
  raise NotImplementedError
end

#file_countObject

returns the number of files in the directory



23
24
25
26
27
# File 'lib/ferret/store/directory.rb', line 23

def file_count() 
  i = 0
  each {|f| i += 1}
  return i
end

#length(file) ⇒ Object

Returns the length of a file in the directory.

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/ferret/store/directory.rb', line 57

def length(file)
  raise NotImplementedError
end

#make_lock(lock_name) ⇒ Object

Construct a Lock.

Raises:

  • (NotImplementedError)


73
74
75
# File 'lib/ferret/store/directory.rb', line 73

def make_lock(lock_name)
  raise NotImplementedError
end

#modified(file) ⇒ Object

Returns the time the named file was last modified.

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/ferret/store/directory.rb', line 35

def modified(file)
  raise NotImplementedError
end

#open_input(file_name) ⇒ Object

Returns a stream reading an existing file.

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/ferret/store/directory.rb', line 68

def open_input(file_name)
  raise NotImplementedError
end

#rename(from, to) ⇒ Object

Renames an existing file in the directory. If a file already exists with the new name, then it is replaced. This replacement should be atomic.

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/ferret/store/directory.rb', line 52

def rename(from, to)
  raise NotImplementedError
end

#touch(file) ⇒ Object

Set the modified time of an existing file to now.

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/ferret/store/directory.rb', line 40

def touch(file)
  raise NotImplementedError
end