1 package net.obsearch.index; 2 /* 3 OBSearch: a distributed similarity search engine This project is to 4 similarity search what 'bit-torrent' is to downloads. 5 Copyright (C) 2008 Arnoldo Jose Muller Molina 6 7 This program is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 /** 22 * VectorTestFramework creates objects of type OBVectorInt 23 * and feeds parent TestFrameworkInt with them. 24 * @author Arnoldo Jose Muller Molina 25 */ 26 import java.util.Random; 27 28 public class VectorTestFrameworkInt extends TestFrameworkInt<OBVectorInt> { 29 30 private int vectorDimensionality; 31 private Random r; 32 public VectorTestFrameworkInt(int vectorDimensionality, int dbSize, int querySize, 33 IndexInt<OBVectorInt> index) { 34 super(OBVectorInt.class, dbSize, querySize, index); 35 this.vectorDimensionality = vectorDimensionality; 36 r = new Random(); 37 } 38 39 @Override 40 protected OBVectorInt next() { 41 int[] vector = new int[vectorDimensionality]; 42 int i = 0; 43 while(i < vector.length){ 44 vector[i] = 45 (int)r.nextInt(Integer.MAX_VALUE/vectorDimensionality); 46 47 //(int)r.nextInt(Integer.MAX_VALUE/vectorDimensionality); 48 i++; 49 } 50 return new OBVectorInt(vector); 51 } 52 53 protected void search() throws Exception{ 54 super.search(); 55 search(index, (int)(Integer.MAX_VALUE/vectorDimensionality * 6) , (byte) 3); 56 57 } 58 59 60 } 61