Returns the index within this byte-array of the first occurrence of the
specified(search bytes) byte array.<br>
Starting the search at the specified index<br>

@param srcBytes
@param searchBytes
@param startIndex
@return
320306
public int indexOf(byte[] srcBytes, byte[] searchBytes, int startIndex) {
		final int endIndex = srcBytes.length - 1;
		return indexOf(srcBytes, searchBytes, startIndex, endIndex);
	}
333445
public int firstIndexOf(String name) {
    Integer index =
        (Strings.isDoubleQuoted(name))
            ? byCaseSensitiveName.get(Strings.unDoubleQuote(name))
            : byCaseInsensitiveName.get(name.toLowerCase());
    return (index == null) ? -1 : index;
  }
1018419
public int indexOf(BinaryString subStr, int start) {
		ensureMaterialized();
		subStr.ensureMaterialized();
		if (subStr.sizeInBytes == 0) {
			return 0;
		}
		if (inFirstSegment()) {
			// position in byte
			int byteIdx = 0;
			// position is char
			int charIdx = 0;
			while (byteIdx < sizeInBytes && charIdx < start) {
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			}
			do {
				if (byteIdx + subStr.sizeInBytes > sizeInBytes) {
					return -1;
				}
				if (SegmentsUtil.equals(segments, offset + byteIdx,
					subStr.segments, subStr.offset, subStr.sizeInBytes)) {
					return charIdx;
				}
				byteIdx += numBytesForFirstByte(getByteOneSegment(byteIdx));
				charIdx++;
			} while (byteIdx < sizeInBytes);

			return -1;
		} else {
			return indexOfSlow(subStr, start);
		}
	}
55386
public Scan getResultScan(String tableName, String famName,
             ByteBuffer startKey, ByteBuffer endKey) throws IOException {
	 logger.debug("AbstractHBaseUtils Begin of getResultScan(" + tableName + ", " + famName + ")");
         Scan scan = new Scan();
         scan.addFamily(Bytes.toBytes(famName));
         // For a range scan, set start / stop id or just start.
         if (startKey != null)
             scan.setStartRow(Bytes.toBytes(startKey));
         if (endKey != null)
             scan.setStopRow(Bytes.toBytes(endKey));
         return scan;
     }
232879
public static int searchPath(byte[] source, byte[] destination, SearchPathCallback callback) {
        if (caseInsensitiveEquals(source, destination)) return -1;

        ObjPtr<SearchPathQueue> bfsQueue = new ObjPtr<SearchPathQueue>();
        SearchPathQueue queue = new SearchPathQueue();
        queue.encoding = source;

        ObjPtr<SearchPathQueue> bfsLastQueue = queue.next;
        bfsQueue.p = queue;

        CaseInsensitiveBytesHash<byte[]> bfsVisited = new CaseInsensitiveBytesHash<byte[]>();
        bfsVisited.put(source, NULL_STRING);

        while (bfsQueue.p != null) {
            queue = bfsQueue.p;
            bfsQueue.p = queue.next.p;
            if (bfsQueue.p == null) bfsLastQueue = bfsQueue;

            CaseInsensitiveBytesHash<Entry> table2 = transcoders.get(queue.encoding);
            if (table2 == null) continue;

            Entry entry = table2.get(destination);
            if (entry != null) {
                bfsVisited.put(destination, queue.encoding);
                byte[] enc = destination;
                int depth, pathLength = 0;
                while (true) {
                    byte[] tmp = bfsVisited.get(enc);
                    if (tmp == NULL_STRING) break;
                    pathLength++;
                    enc = tmp;

                }
                depth = pathLength;
                enc = destination;
                while (true) {
                    byte[] tmp = bfsVisited.get(enc);
                    if (tmp == NULL_STRING) break;
                    callback.call(tmp, enc, --depth);
                    enc = tmp;
                }
                return pathLength;
            } else {
                byte[] bfsBaseEnc = queue.encoding;

                for (Hash.HashEntry<Entry> o : (Iterable<Hash.HashEntry<Entry>>)table2.entryIterator()) {
                    CaseInsensitiveBytesHash.CaseInsensitiveBytesHashEntry<Entry> e = (CaseInsensitiveBytesHash.CaseInsensitiveBytesHashEntry<Entry>) o;
                    byte[] dname = e.bytes;
                    if (bfsVisited.get(dname) == null) {
                        SearchPathQueue q = new SearchPathQueue();
                        q.encoding = dname;
                        q.next.p = null;
                        bfsLastQueue.p = q;
                        bfsLastQueue = q.next;

                        bfsVisited.putDirect(dname, bfsBaseEnc);
                    }
                }

                bfsBaseEnc = null;
            }

        } // while
        return -1;
    }
525842
public int getRowIndex(String searchElement, int startRowIndex) {
        int index = -1;
        if (ready()) {
            String path = getGridCell(startRowIndex).getXPath();
            WebLocator currentElement = new WebLocator().setElPath(path);
            while (currentElement.isElementPresent()) {
                String option = currentElement.getText();
                //LOGGER.debug("row[" + i + "]" + option);
                if (option != null && option.contains(searchElement)) {
                    LOGGER.debug("The '" + searchElement + "' element index is " + startRowIndex);
                    index = startRowIndex;
                    break;
                }
                startRowIndex++;
                path = getGridCell(startRowIndex).getXPath();
                currentElement.setElPath(path);
            }
            if (index == -1) {
                LOGGER.warn("The element '" + searchElement + "' was not found.");
            }
        } else {
            LOGGER.warn("getRowIndex : grid is not ready for use: " + toString());
        }
        return index;
    }
1188811
private static final int previousSpaceIndex(StringBuffer sb, int seek) {
    seek--;
    while (seek > 0) {
      if (sb.charAt(seek) == ' ') {
        while (seek > 0 && sb.charAt(seek - 1) == ' ')
          seek--;
        return seek;
      }
      seek--;
    }
    return 0;
  }
319392
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public static Pdu parse(byte[] bytes, int startIndex) {
        Pdu pdu = null;
        if (bytes.length-startIndex >= 2) {
            byte length = bytes[startIndex];
            if (length > 0) {
                byte type = bytes[startIndex + 1];
                int firstIndex = startIndex + 2;
                if (firstIndex < bytes.length) {
                    pdu = new Pdu();
                    // The End index is the startIndex + the length, because the first byte is the
                    // length field and the length field does not include the length field itself in
                    // the count
                    pdu.mEndIndex = startIndex + length;
                    if (pdu.mEndIndex >= bytes.length) {
                        pdu.mEndIndex = bytes.length - 1;
                    }
                    pdu.mType = type;
                    pdu.mDeclaredLength = length;
                    pdu.mStartIndex = firstIndex;
                    pdu.mBytes = bytes;
                }
            }
        }
        return pdu;
    }
1112314
@Override public long indexOf(byte b, long fromIndex) {
    if (fromIndex < 0) throw new IllegalArgumentException("fromIndex < 0");

    Segment s = head;
    if (s == null) return -1L;
    long offset = 0L;
    do {
      int segmentByteCount = s.limit - s.pos;
      if (fromIndex >= segmentByteCount) {
        fromIndex -= segmentByteCount;
      } else {
        byte[] data = s.data;
        for (int pos = (int) (s.pos + fromIndex), limit = s.limit; pos < limit; pos++) {
          if (data[pos] == b) return offset + pos - s.pos;
        }
        fromIndex = 0;
      }
      offset += segmentByteCount;
      s = s.next;
    } while (s != head);
    return -1L;
  }
988928
void initResultIndex() {

        int startIndex = 0;
        if ((m_pageIndex > 0) && (m_pageSize > 0)) {
            startIndex = (m_pageIndex - 1) * m_pageSize;
        }

        m_resultIndex = startIndex > m_resultSize ? m_resultSize : startIndex;
    }
1039886
public static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value) {
        if (fromIndex <= toIndex) {
            return firstIndexOf(buffer, fromIndex, toIndex, value);
        } else {
            return lastIndexOf(buffer, fromIndex, toIndex, value);
        }
    }
953827
public static int bytesHighFirstToInt(byte[] bytes, int start)
    {
        int num = bytes[start + 3] & 0xFF;
        num |= ((bytes[start + 2] << 8) & 0xFF00);
        num |= ((bytes[start + 1] << 16) & 0xFF0000);
        num |= ((bytes[start] << 24) & 0xFF000000);
        return num;
    }
1316894
public byte[] getBytesAt(int index,int size){ 
        _checkForReadAt(index,size);
       byte[] dst = new byte[size];
       int i=0;
       int j=index;
       while (i<size) {
           dst[i++] =  _buf.get(j++);
       }
       return dst;
    }
1109188
@Nullable
  public static String getFirstToken (@Nullable final String sStr, final char cSearch)
  {
    final int nIndex = getIndexOf (sStr, cSearch);
    return nIndex == StringHelper.STRING_NOT_FOUND ? sStr : sStr.substring (0, nIndex);
  }
1336014
public ContentInfo findMatch(byte[] bytes) {
		if (bytes.length == 0) {
			return ContentInfo.EMPTY_INFO;
		}
		// first do the start byte ones
		int index = (0xFF & bytes[0]);
		if (index < firstByteEntryLists.length && firstByteEntryLists[index] != null) {
			ContentInfo info = findMatch(bytes, firstByteEntryLists[index]);
			if (info != null) {
				// this seems to be right to return even if only a partial match here
				return info;
			}
		}
		return findMatch(bytes, entryList);
	}
1191517
public List<Integer> searchBigBytes(byte[] srcBytes, byte[] searchBytes, int numOfThreads) {

		if (numOfThreads == 0) {
			numOfThreads = 1;
		}

		final int sizeOfSrcBytes = srcBytes.length;
		final int sizeOfSearchBytes = searchBytes.length;

		final int bytesToReadBlockSize = (srcBytes.length - (sizeOfSearchBytes)) / numOfThreads;

		final int threadPoolSize;

		if (maxNumOfThreads == THREADS_NO_LIMIT) {
			threadPoolSize = numOfThreads;
		} else {
			threadPoolSize = maxNumOfThreads;
		}

		final ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);

		final List<Future<List<Integer>>> futureList = new ArrayList<Future<List<Integer>>>();

		for (int i = 0; i < numOfThreads; i++) {

			final int offset = bytesToReadBlockSize * i;
			final int readLeng;

			if (i == numOfThreads - 1) {
				// if it's the last element.
				readLeng = sizeOfSrcBytes - offset - 1;
			} else {
				// else , add the overlapping part size to blockSize
				readLeng = bytesToReadBlockSize + sizeOfSearchBytes;
			}

			final Future<List<Integer>> future = executorService.submit(new BinarySearchTask(srcBytes, searchBytes, offset, readLeng));

			futureList.add(future);
		}
		executorService.shutdown();

		// Remove duplicate indexes
		final List<Integer> resultIndexList = new CopyOnWriteArrayList<Integer>();

		for (Future<List<Integer>> future : futureList) {

			try {
				List<Integer> rawIndexList = future.get();

				for (int i = 0; i < rawIndexList.size(); i++) {

					Integer integer = rawIndexList.get(i);

					if (resultIndexList.contains(integer)) {
						// if already exists , skip
					} else {
						resultIndexList.add(integer);
					}
				}
			} catch (InterruptedException e) {
			} catch (ExecutionException e) {
			}

		}

		// Sort in ascending order
		resultIndexList.sort(new Comparator<Integer>() {

			public int compare(Integer num1, Integer num2) {
				if (num1 > num2) {
					return 1;
				} else if (num1 < num2) {
					return -1;
				}
				return 0;
			}
		});

		return resultIndexList;
	}
281227
public static int getNumSetBits(ByteBuffer bfBuffer, int start)
  {
    ByteBuffer view = bfBuffer.duplicate().order(ByteOrder.BIG_ENDIAN);
    view.position(start);
    int numLongs = view.getInt(1 + start);
    int setBits = 0;
    for (int i = 0, pos = START_OF_SERIALIZED_LONGS + start; i < numLongs; i++, pos += Long.BYTES) {
      setBits += Long.bitCount(view.getLong(pos));
    }
    return setBits;
  }