View Javadoc

1   package net.obsearch.pivots.dummy;
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   import net.obsearch.pivots.AbstractIncrementalPivotSelector;
9   import net.obsearch.pivots.IncrementalPivotSelector;
10  import net.obsearch.pivots.PivotResult;
11  
12  
13  import cern.colt.list.IntArrayList;
14  import cern.colt.list.LongArrayList;
15  
16  /*
17   OBSearch: a distributed similarity search engine This project is to
18   similarity search what 'bit-torrent' is to downloads. 
19   Copyright (C) 2008 Arnoldo Jose Muller Molina
20  
21   This program is free software: you can redistribute it and/or modify
22   it under the terms of the GNU General Public License as published by
23   the Free Software Foundation, either version 3 of the License, or
24   (at your option) any later version.
25  
26   This program is distributed in the hope that it will be useful,
27   but WITHOUT ANY WARRANTY; without even the implied warranty of
28   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29   GNU General Public License for more details.
30  
31   You should have received a copy of the GNU General Public License
32   along with this program.  If not, see <http://www.gnu.org/licenses/>.
33   */
34  
35  /**
36   * IncrementalDummyPivotSelector is used for testing purposes.
37   * @author Arnoldo Jose Muller Molina
38   */
39  
40  public class IncrementalDummyPivotSelector < O extends OB >
41          extends AbstractIncrementalPivotSelector < O > implements
42  		IncrementalPivotSelector<O> {
43      
44      public IncrementalDummyPivotSelector(){
45          super(null);
46      }
47  
48      @Override
49      public PivotResult generatePivots(int pivotCount, Index<O> index)
50              throws OBException, IllegalAccessException, InstantiationException,
51              OBStorageException, PivotsUnavailableException {
52          // TODO Auto-generated method stub
53          return generatePivots(pivotCount, null, index);
54      }
55  
56      
57      public PivotResult generatePivots(int pivotCount, LongArrayList elements,
58              Index<O> index) throws OBException, IllegalAccessException,
59              InstantiationException, OBStorageException,
60              PivotsUnavailableException {
61          int i = 0;
62          long[] res = new long[pivotCount];
63          while (i < pivotCount) {
64              res[i] = super.mapId(i, elements);
65              i++;
66          }
67          return new PivotResult(res);
68      }
69  
70  }