View Javadoc

1   package net.obsearch.pivots;
2   
3   import net.obsearch.Index;
4   import net.obsearch.OB;
5   import net.obsearch.exception.OBException;
6   import net.obsearch.exception.OBStorageException;
7   import net.obsearch.exception.PivotsUnavailableException;
8   
9   import cern.colt.list.IntArrayList;
10  import cern.colt.list.LongArrayList;
11  
12  /*
13   OBSearch: a distributed similarity search engine This project is to
14   similarity search what 'bit-torrent' is to downloads. 
15   Copyright (C) 2008 Arnoldo Jose Muller Molina
16  
17   This program is free software: you can redistribute it and/or modify
18   it under the terms of the GNU General Public License as published by
19   the Free Software Foundation, either version 3 of the License, or
20   (at your option) any later version.
21  
22   This program is distributed in the hope that it will be useful,
23   but WITHOUT ANY WARRANTY; without even the implied warranty of
24   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25   GNU General Public License for more details.
26  
27   You should have received a copy of the GNU General Public License
28   along with this program.  If not, see <http://www.gnu.org/licenses/>.
29   */
30  
31  /**
32   * Objects that implement the IncrementalPivotSelector interface are expected to
33   * take objects from a) all the database, b) a subset of the database. The pivot
34   * selector should return a list with all the objects that will be pivots.
35   * 
36   * @author Arnoldo Jose Muller Molina
37   */
38  // TODO unify IncrementalPivotSelector and PivotSelector, find common
39  // functionality and create a better interface.
40  public interface IncrementalPivotSelector<O extends OB>  {
41  	
42  	/**
43       * Generates pivots from all the elements found in the DB.
44       * @param pivotCount The # of pivots that will be generated.
45       * @return A list of the  ids of the pivots.
46       * @throws OBStorageException
47       *             If something goes wrong with the DB
48       * @throws OBException
49       *             User generated exception
50       * @throws IllegalAccessException
51       *             If there is a problem when instantiating objects O
52       * @throws InstantiationException
53       *             If there is a problem when instantiating objects O
54       * @throws PivotsUnavailableException
55       *             If not all the pivots requested were found.
56       */
57      PivotResult generatePivots(int pivotCount, Index<O> index) throws OBException,
58      IllegalAccessException, InstantiationException, OBStorageException,
59      PivotsUnavailableException;
60  
61      /**
62       * Generates pivots from the elements (object ids) given in the array elements.
63       * Generates pivotsCount  pivots.
64       * @param pivotCount
65       * @param elements
66       * @return A list of the ids of the pivots.
67       */
68      PivotResult generatePivots(int pivotCount, LongArrayList elements,  Index<O> index) throws OBException,
69      IllegalAccessException, InstantiationException, OBStorageException,
70      PivotsUnavailableException; 
71  	
72  
73  }