1 package net.obsearch.ambient;
2
3 /*
4 OBSearch: a distributed similarity search engine This project is to
5 similarity search what 'bit-torrent' is to downloads.
6 Copyright (C) 2008 Arnoldo Jose Muller Molina
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /**
23 * Ambient is used to manage the serialization and de-serialization of indexes.
24 * You could do this by yourself but it is much more convenient to let Ambient
25 * do the work for you.
26 * @see org.obsearch.ambient.AbstractAmbient
27 *
28 * @author Arnoldo Jose Muller Molina
29 */
30
31 import java.io.IOException;
32
33 import net.obsearch.Index;
34 import net.obsearch.OB;
35 import net.obsearch.exception.AlreadyFrozenException;
36 import net.obsearch.exception.IllegalIdException;
37 import net.obsearch.exception.OBException;
38 import net.obsearch.exception.OBStorageException;
39 import net.obsearch.exception.OutOfRangeException;
40 import net.obsearch.exception.PivotsUnavailableException;
41 import net.obsearch.storage.OBStoreFactory;
42
43
44 public interface Ambient < O extends OB, I extends Index < O >> {
45
46 /**
47 * The name of the file in which the meta-data is stored.
48 */
49 String METADATA_FILENAME = "ob.xml";
50
51
52 /**
53 * Returns the index.
54 * @return the index.
55 */
56 public abstract I getIndex();
57
58 /**
59 * Freezes the index and stores the metadata of the index (the index itself)
60 * in the DB.
61 * @throws PivotsUnavailableException
62 * @see net.obsearch.Index#freeze()
63 */
64 public abstract void freeze() throws IOException, AlreadyFrozenException,
65 IllegalIdException, IllegalAccessException, InstantiationException,
66 OBStorageException, OutOfRangeException, OBException, PivotsUnavailableException;
67
68 /**
69 * Close all the internally used resources.
70 * @throws OBException
71 */
72 public void close() throws OBException;
73
74 /**
75 * Returns the factory (if the user wants to create some
76 * storages for personal use).
77 * @return The factory used to create storage devices.
78 */
79 public OBStoreFactory getFactory();
80
81 }