Package org.fastlsh.util

Examples of org.fastlsh.util.Signature


        BitSet b5 = new BitSet(64);
        b5.set(0);         
        b5.set(63);         

        ArrayList<Signature> al = new ArrayList<Signature>();
        al.add(new Signature(1,b1));
        al.add(new Signature(2,b2));
        al.add(new Signature(4,b4));
        al.add(new Signature(3,b3));
        al.add(new Signature(5,b5));
       
        Collections.sort(al, new LexicographicBitSetComparator());
        Assert.assertEquals(4, al.get(0).id);
        Assert.assertEquals(3, al.get(1).id);
        Assert.assertEquals(2, al.get(2).id);
View Full Code Here


        BitSet b4 = new BitSet(4);
        b4.set(2);
        b4.set(3);

        ArrayList<Signature> al = new ArrayList<Signature>();
        al.add(new Signature(1,b1));
        al.add(new Signature(2,b2));
        al.add(new Signature(4,b4));
        al.add(new Signature(3,b3));
       
        Collections.sort(al, new LexicographicBitSetComparator());
        Assert.assertEquals(2, al.get(0).id);
        Assert.assertEquals(3, al.get(1).id);
        Assert.assertEquals(4, al.get(2).id);
View Full Code Here

        BitSet b4 = new BitSet(356);
        b4.set(2);
        b4.set(3);

        ArrayList<Signature> al = new ArrayList<Signature>();
        al.add(new Signature(11,b11));
        al.add(new Signature(1,b1));
        al.add(new Signature(2,b2));
        al.add(new Signature(4,b4));
        al.add(new Signature(3,b3));
       
        Collections.sort(al, new LexicographicBitSetComparator());
        Assert.assertEquals(2, al.get(0).id);
        Assert.assertEquals(3, al.get(1).id);
        Assert.assertEquals(4, al.get(2).id);
View Full Code Here

    {
        ObjectInputStream ois = null;
        try
        {
            ois = new ObjectInputStream(new FileInputStream(file));
            Signature sig = null;
            do
            {
                sig = (Signature) ois.readObject();
                tempSigs.add(sig);
                sigMap.put(sig.id, sig.bits);
View Full Code Here

  }
   
    public void indexVector(VectorWithId vec) throws IOException {
      double norm = vec.norm2();
        if(norm == 0.0) return// TODO: create a separate zeros file for these.
        sigStream.writeObject(new Signature(vec.id, family.makeSignature(vec)));
        rawStream.writeObject(vec);
        numVectors++;
        if(numVectors%10000 == 0)
        {
            rawStream.flush();
View Full Code Here

    }
   
    public static void permuteAndSort(Permuter p, Signature [] sigs)
    {
        p.reset();
        for(int i = 0, max = sigs.length; i < max; i++) sigs[i] = new Signature(sigs[i].id, p.permute(sigs[i].bits));
        Arrays.sort(sigs, new LexicographicBitSetComparator());
    }
View Full Code Here

                VectorWithId vec = parser.parse(line);
                double norm = vec.norm2();
                if(norm == 0.0) continue;
                // Compute the signatures non-normalized, but normalize the raw vectors before serialization so that when we check
                // cosine distances, we only have to do dot products
                sigStream.writeObject(new Signature(vec.id, family.makeSignature(vec)));
//                vec.scalarDivide(norm);
                vecStream.writeObject(vec);
            }
            sigStream.reset();                   
            vecStream.reset();                               
View Full Code Here

            BitSet bs = new BitSet(cardinality);
            for(int i = 0; i < cardinality; i++)
            {
                if(rand.nextBoolean()) bs.set(i);
            }
            bitsetList.add(new Signature(curId, bs));
            curId++;
        }
        while(curId <= numBitSets);
        return bitsetList.toArray(new Signature[bitsetList.size()]);
    }
View Full Code Here

TOP

Related Classes of org.fastlsh.util.Signature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.