Gets the rank given the shape info buffer
@param buffer the buffer to get the rank for
@return the rank for the shape buffer
11716
public static long length(DataBuffer buffer) {
        long ret = 1;
        val rr = buffer.asLong();
        DataBuffer shape = Shape.shapeOf(buffer);
        int rank = Shape.rank(buffer);
        for (int i = 0; i < rank; i++)
            ret *= shape.getLong(i);

        return ret;
    }
1173243
public ByteBuffer getIndicesBuffer() {
        final ByteBuffer buffer = CausticUtil.createByteBuffer(indices.size() * DataType.INT.getByteSize());
        for (int i = 0; i < indices.size(); i++) {
            buffer.putInt(indices.get(i));
        }
        buffer.flip();
        return buffer;
    }
1346482
public byte[] getLastSegment() {
    if (segments.isEmpty()) {
      return null;
    }
    BufferSegment seg = segments.get(segments.size() - 1);
    return Arrays.copyOfRange(seg.buf, seg.offset, seg.offset + seg.len);
  }
137243
public int rank(Type t) {
        t = t.unannotatedType();
        switch(t.getTag()) {
        case CLASS: {
            ClassType cls = (ClassType)t;
            if (cls.rank_field < 0) {
                Name fullname = cls.tsym.getQualifiedName();
                if (fullname == names.java_lang_Object)
                    cls.rank_field = 0;
                else {
                    int r = rank(supertype(cls));
                    for (List<Type> l = interfaces(cls);
                         l.nonEmpty();
                         l = l.tail) {
                        if (rank(l.head) > r)
                            r = rank(l.head);
                    }
                    cls.rank_field = r + 1;
                }
            }
            return cls.rank_field;
        }
        case TYPEVAR: {
            TypeVar tvar = (TypeVar)t;
            if (tvar.rank_field < 0) {
                int r = rank(supertype(tvar));
                for (List<Type> l = interfaces(tvar);
                     l.nonEmpty();
                     l = l.tail) {
                    if (rank(l.head) > r) r = rank(l.head);
                }
                tvar.rank_field = r + 1;
            }
            return tvar.rank_field;
        }
        case ERROR:
        case NONE:
            return 0;
        default:
            throw new AssertionError();
        }
    }
434426
public synchronized double get(double q) {
        // clear the buffer
        insertBatch();
        compress();

        if (sample.size() == 0) {
            return Double.NaN;
        }

        int rankMin = 0;
        int desired = (int) (q * count);

        ListIterator<Item> it = sample.listIterator();
        Item prev, cur;
        cur = it.next();
        while (it.hasNext()) {
            prev = cur;
            cur = it.next();

            rankMin += prev.g;

            if (rankMin + cur.g + cur.delta > desired
                    + (allowableError(desired) / 2)) {
                return prev.value;
            }
        }

        // edge case of wanting max value
        return sample.getLast().value;
    }
864266
public BufferedImage getBufferedImage(int width, int height) {
		BufferedImage bi = chart.createBufferedImage(width, height);
		return bi;
	}
1437
public BufferedImage getBufferedImage(int width, int height) {
        // using the new approach of Java 2D API
        BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = (Graphics2D) buf.getGraphics();
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g2d.drawImage(image, 0, 0, width, height, null);
        g2d.dispose();
        return (buf);
    }
975491
@Override
    protected WsByteBuffer[] getBuffList() {

        if (!getLink().isReconnectAllowed()) {
            // reconnects not allowed, skip the special logic below
            return super.getBuffList();
        }

        int stop = getPendingStop();
        int start = getPendingStart();
        int size = stop - start;
        if (0 == size) {
            return null;
        }
        WsByteBuffer[] buffs = getPendingBuffers();
        WsByteBuffer[] list = new WsByteBuffer[size];
        // expand the position list array if we need to
        if (this.positionList.length < buffs.length) {
            int[] newList = new int[buffs.length];
            System.arraycopy(this.positionList, 0, newList, 0, this.positionList.length);
            this.positionList = newList;
        }
        for (int x = 0, i = start; x < size; i++, x++) {
            list[x] = buffs[i];
            this.positionList[i] = buffs[i].position();
        }
        setPendingStart(stop);
        return list;
    }
1044396
@Override
  public Object get(final ByteBuffer buf, final int position)
  {
    final WritableMemory mem = WritableMemory.wrap(buf, ByteOrder.LITTLE_ENDIAN).writableRegion(position, size);
    final Lock lock = stripedLock.getAt(HllSketchBuildBufferAggregator.lockIndex(position)).readLock();
    lock.lock();
    try {
      final Union union = Union.writableWrap(mem);
      return union.getResult(tgtHllType);
    }
    finally {
      lock.unlock();
    }
  }
111725
public static boolean isVector(IntBuffer shapeInfo) {
        int rank = Shape.rank(shapeInfo);
        if (rank > 2 || rank < 1)
            return false;
        else {
            int len = Shape.length(shapeInfo);
            IntBuffer shape = Shape.shapeOf(shapeInfo);
            return shape.get(0) == len || shape.get(1) == len;
        }
    }
847018
public static int stride(IntBuffer buffer, int dimension) {
        int rank = rank(buffer);
        if (dimension >= rank)
            throw new IllegalArgumentException("Invalid dimension " + dimension + " for rank " + rank + " array");
        return buffer.get(1 + rank + dimension);
    }
384395
static int[] verticesInOrder(final int[] rank) {
        int[] vs = new int[rank.length];
        for (int v = 0; v < rank.length; v++)
            vs[rank[v]] = v;
        return vs;
    }
783115
public static int elementWiseStride(IntBuffer buffer) {
        int length2 = shapeInfoLength(buffer.get(0));
        return buffer.get(length2 - 2);
    }
907693
public static DataBuffer shapeOf(DataBuffer buffer) {
        int rank = (int) buffer.getLong(0);
        return Nd4j.createBuffer(buffer, 1, rank);
    }
1020747
public DataBuffer getUnderlyingIndicesOf(int i) {
        int from = underlyingRank() * i;
        //int to = from + underlyingRank();
        int[] res = new int[underlyingRank()];
        for(int j = 0; j< underlyingRank(); j++){
            res[j] = indices.getInt(from + j);
        }

        ///int[] arr = Arrays.copyOfRange(indices.asInt(), from, to);
        return Nd4j.getDataBufferFactory().createInt(res);
    }
460437
public double getValueForRank(int rank) {
		List<Double> scores = new ArrayList<Double>(map.values());
		java.util.Collections.sort(scores);
		return scores.get(scores.size() - rank);
	}
845901
public DataBuffer getIncludedIndices() {

        if (isScalar()) {
            return Nd4j.createBuffer(new int[] {0, 0});
        }

        List<Integer> ind = new ArrayList<>();

        for (int i = 0; i < values.length(); i++) {
            boolean isIn = true;
            int idxNotFixed = 0;
            int[] idx = getUnderlyingIndicesOf(i).asInt(); // TODO change for getIndicesOf(i)

            for (int dim = 0; dim < idx.length; dim++) {
                if (flags()[dim] == 1) {
                    if (sparseOffsets()[dim] != idx[dim]) {
                        isIn = false;
                        break;
                    }
                } else {
                    int lowerBound = sparseOffsets()[dim];
                    long upperBound = sparseOffsets()[dim] + shape()[idxNotFixed];
                    if (!(idx[dim] >= lowerBound && idx[dim] < upperBound)) {
                        isIn = false;
                        break;
                    }
                    idxNotFixed++;
                }
            }
            if (isIn) {
                int notFixedDim = 0;
                for (int dim = 0; dim < idx.length; dim++) {
                    if (flags()[dim] == 0) {
                        if (shape()[notFixedDim] == 1) {
                            ind.add(0);
                            notFixedDim++;
                        } else {
                            ind.add(idx[dim] - sparseOffsets()[dim]);
                        }
                    }
                }
            }
        }
        return Nd4j.createBuffer(Ints.toArray(ind));
    }