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 OBVectorByte 23 * and feeds parent TestFrameworkByte with them. 24 * @author Arnoldo Jose Muller Molina 25 */ 26 import java.util.Random; 27 28 public class VectorTestFrameworkApproxByte extends TestFrameworkApproxByte<OBVectorByte> { 29 30 private int vectorDimensionality; 31 private Random r; 32 public VectorTestFrameworkApproxByte(int vectorDimensionality, int dbSize, int querySize, 33 IndexByte<OBVectorByte> index) { 34 super(OBVectorByte.class, dbSize, querySize, index); 35 this.vectorDimensionality = vectorDimensionality; 36 r = new Random(); 37 } 38 39 @Override 40 protected OBVectorByte next() { 41 byte[] vector = new byte[vectorDimensionality]; 42 int i = 0; 43 while(i < vector.length){ 44 vector[i] = 45 (byte)r.nextInt(Byte.MAX_VALUE/vectorDimensionality); 46 47 //(byte)r.nextInt(Byte.MAX_VALUE/vectorDimensionality); 48 i++; 49 } 50 return new OBVectorByte(vector); 51 } 52 53 protected void search() throws Exception{ 54 search(index, (byte)1 , (byte) 3); 55 search(index, (byte)3 , (byte) 3); 56 search(index, (byte)10 , (byte) 3); 57 //TODO: Range 48 fails for Byte. Fix this. 58 //search(index, (byte)48 , (byte) 3); 59 60 } 61 62 63 } 64