Append the PQ index with the given vector.

@param vector
The vector to be indexed
@throws Exception
355687
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
		}

	}
235272
@Override
    public void append(long streamSegmentId, long offset, byte[] data) throws StreamSegmentNotExistsException {
        Exceptions.checkNotClosed(this.closed.get(), this);
        log.debug("{}: append (StreamSegmentId = {}, Offset = {}, DataLength = {}).", this.traceObjectId, streamSegmentId, offset, data.length);

        // Append the data to the StreamSegment Index. It performs further validation with respect to offsets, etc.
        StreamSegmentReadIndex index = getOrCreateIndex(streamSegmentId);
        Exceptions.checkArgument(!index.isMerged(), "streamSegmentId", "StreamSegment is merged. Cannot append to it anymore.");
        index.append(offset, data);
    }
117887
public void insert(INDArray point) {
        if (!point.isVector() || point.length() != dims)
            throw new IllegalArgumentException("Point must be a vector of length " + dims);

        if (root == null) {
            root = new KDNode(point);
            rect = new HyperRect(HyperRect.point(point));
        } else {
            int disc = 0;
            KDNode node = root;
            KDNode insert = new KDNode(point);
            int successor;
            while (true) {
                //exactly equal
                INDArray pt = node.getPoint();
                INDArray countEq = Nd4j.getExecutioner().execAndReturn(new Any(pt.neq(point))).z();
                if (countEq.getInt(0) == 0) {
                    return;
                } else {
                    successor = successor(node, point, disc);
                    KDNode child;
                    if (successor < 1)
                        child = node.getLeft();
                    else
                        child = node.getRight();
                    if (child == null)
                        break;
                    disc = (disc + 1) % dims;
                    node = child;
                }
            }

            if (successor < 1)
                node.setLeft(insert);

            else
                node.setRight(insert);

            rect.enlargeTo(point);
            insert.setParent(node);
        }
        size++;

    }
401072
public function addWithIndex($index, $element)
    {
        if (!is_null($index)
            && is_scalar($index)
        ) {
            if (!$this->hasIndex($index)) {
                $this->set($index, $element);
            } else {
                // index already exist
                throw new ListException('Element could not be added to list. Index already exist.', E_NOTICE);
            }
        } else {
            // given index name is not valid
            throw new ListException('Element could not be added to list. Index is not valid.', E_NOTICE);
        }
    }
1371318
public void rebuildIndex(String index) throws Exception {

        OpenCms.getSearchManager().rebuildIndex(index, new CmsShellReport(m_cms.getRequestContext().getLocale()));
    }
307213
public void insert(StringBuilder buffer, Object value, int index) {
        if (buffer == null) {
            throw new NullPointerException("buffer");
        }

        buffer.insert(index, value);
    }
705175
public function offsetAppend($index, $value)
    {
        $items = [];
        if ($this->offsetExists($index)) {
            $items = $this->offsetGet($index);
            if (!is_array($items)) {
                $itemsType = gettype($items);
                throw new \Exception("Offset '$index' is '$itemsType' and must be array to append.");
            }
        }
        $items[] = $value;
        $this->offsetSet($index, $items);
    }
1349031
@Override
  public void add(int index, Object element) {    
    element = mapIfNumber(element);
    addComponent(index, element, ComponentEquality.EQUAL);
  }
477860
public void add(int index, int element)
    {
        if (index == size())//special case, just appending
        {
            add(element);
        }
        else
        {
            boundsCheck(index);
            enlargeIfNeeded(1);
            System.arraycopy(array, index, array, index+1, end-index);
            array[index] = element;
            end++;
        }
    }
1065707
@Override
    public void add(int idx, double val) {
        int i = Arrays.binarySearch(indices, 0, used, idx);
        if (i >= 0) {
            // Just add to the existing value.
            values[i] += val;
            return;
        } 
        int insertionPoint = -(i + 1);
        indices = insert(indices, insertionPoint, idx);
        values = insert(values, insertionPoint, val);
        used++;
    }
315485
@Override
	public Appendable append(CharSequence csq, int start, int end) {
		final int otherLen = end - start;
		grow(this.len + otherLen);
		for (int pos = start; pos < end; pos++) {
			this.value[this.len + pos] = csq.charAt(pos);
		}
		this.len += otherLen;
		return this;
	}
442050
void append(final MultiIndex.Action action) throws IOException
   {
      initOut();
      out.write(action.toString() + "\n");
      entryCount++;
   }
671283
@Override
    public void writeVectorUInt(Vector<Long> vector) {
        log.debug("writeVectorUInt: {}", vector);
        writeAMF3();
        buf.put(AMF3.TYPE_VECTOR_UINT);
        if (hasReference(vector)) {
            putInteger(getReferenceId(vector) << 1);
            return;
        }
        storeReference(vector);
        putInteger(vector.size() << 1 | 1);
        buf.put((byte) 0x00);
        for (Long v : vector) {
            // update this class to implement valueOf like Long.valueOf
            UnsignedInt uint = new UnsignedInt(v);
            byte[] arr = uint.getBytes();
            buf.put(arr);
        }
    }
1019401
public void add(IntFloatVector other) {
        if (other instanceof IntFloatUnsortedVector) {
            IntFloatUnsortedVector vec = (IntFloatUnsortedVector) other;
            for (int i=0; i<vec.top; i++) {
                this.add(vec.idx[i], vec.vals[i]);
            }
        } else {
            //  TODO: Add special case for IntFloatDenseVector.
            other.iterate(new SparseBinaryOpApplier(this, new Lambda.FloatAdd()));
        }
    }
547550
public void addAll(StringArrayList vec) {
        int i;
        int max;

        max = vec.size();
        for (i = 0; i < max; i++) {
            add(vec.get(i));
        }
    }
1374819
def insert_vector(indexes, val)
      new_index = @index.add(*indexes)
      # May be create +=
      (new_index.size - @index.size).times { @data << val }
      @index = new_index
    end
30844
public void insertRow(int index, Object element)
    {
        elements.add(index, element);
        fireTableRowsInserted(index, index);
    }