code: protected int[] computeKNearestCentroids(double[] descriptor, int k) {
  		BoundedPriorityQueue<Result> bpq = new BoundedPriorityQueue<Result>(new Result(), k);
  
  		double minDistance = Double.MAX_VALUE;
  		for (int i = 0; i < numCentroids; i++) {
  			double distance = 0;
  			boolean skip = false;
  			for (int j = 0; j < descriptorLength; j++) {
  				distance += (codebook[i][j] - descriptor[j]) * (codebook[i][j] - descriptor[j]);
  				if (distance > minDistance) {
  					skip = true;
  					break;
  				}
  			}
  			if (skip) {
  				continue;
  			}
  			bpq.offer(new Result(i, distance));
  			if (i >= k) {
  				minDistance = bpq.last().getDistance();
  			}
  		}
  		int[] nn = new int[k];
  		for (int i = 0; i < k; i++) {
  			nn[i] = bpq.poll().getId();
  		}
  		return nn;
  	}
docs: Returns the indices of the k centroids which are closer to the given descriptor. Can be used for soft
  quantization. Fast implementation with a bounded priority queue. TO DO: early stopping!
  
  @param descriptor
  @param k
  @return