protected void indexVectorInternal(double[] vector) throws Exception {
		if (vector.length != vectorLength) {
			throw new Exception("The dimensionality of the vector is wrong!");
		}
		// apply a random transformation if needed
		if (transformation == TransformationType.RandomRotation) {
			vector = rr.rotate(vector);
		} else if (transformation == TransformationType.RandomPermutation) {
			vector = rp.permute(vector);
		}
		// transform the vector into a PQ code
		int[] pqCode = new int[numSubVectors];

		for (int i = 0; i < numSubVectors; i++) {
			// take the appropriate sub-vector
			int fromIdex = i * subVectorLength;
			int toIndex = fromIdex + subVectorLength;
			double[] subvector = Arrays.copyOfRange(vector, fromIdex, toIndex);
			// assign the sub-vector to the nearest centroid of the respective sub-quantizer
			pqCode[i] = computeNearestProductIndex(subvector, i);
		}

		if (numProductCentroids <= 256) {
			byte[] pqByteCode = transformToByte(pqCode);
			if (loadIndexInMemory) { // append the ram-based index
				pqByteCodes.add(pqByteCode);
			}
			appendPersistentIndex(pqByteCode); // append the disk-based index
		} else {
			short[] pqShortCode = transformToShort(pqCode);
			if (loadIndexInMemory) { // append the ram-based index
				pqShortCodes.add(pqShortCode);
			}
			appendPersistentIndex(pqShortCode); // append the disk-based index
		}

	}
protected void indexVectorInternal ( double [ ] vector ) throws Exception { if ( vector . length != vectorLength ) { throw new Exception ( "The dimensionality of the vector is wrong!" ) ; } if ( transformation == TransformationType . RandomRotation ) { vector = rr . rotate ( vector ) ; } else if ( transformation == TransformationType . RandomPermutation ) { vector = rp . permute ( vector ) ; } int [ ] pqCode = new int [ numSubVectors ] ; for ( int i = 0 ; i < numSubVectors ; i ++ ) { int fromIdex = i * subVectorLength ; int toIndex = fromIdex + subVectorLength ; double [ ] subvector = Arrays . copyOfRange ( vector , fromIdex , toIndex ) ; pqCode [ i ] = computeNearestProductIndex ( subvector , i ) ; } if ( numProductCentroids <= 256 ) { byte [ ] pqByteCode = transformToByte ( pqCode ) ; if ( loadIndexInMemory ) { pqByteCodes . add ( pqByteCode ) ; } appendPersistentIndex ( pqByteCode ) ; } else { short [ ] pqShortCode = transformToShort ( pqCode ) ; if ( loadIndexInMemory ) { pqShortCodes . add ( pqShortCode ) ; } appendPersistentIndex ( pqShortCode ) ; } }
Append the PQ index with the given vector.

@param vector
The vector to be indexed
@throws Exception