MetadataIndexNode { int binarySearchInChildren(String key) { int low = 0; int high = children.size() - 1; while (low <= high) { int mid = (low + high) >>> 1; MetadataIndexEntry midVal = children.get(mid); int cmp = midVal.getName().compareTo(key); if (cmp < 0) { low = mid + 1; } else if (cmp > 0) { high = mid - 1; } else { return mid; } } return low == 0 ? low : low - 1; } MetadataIndexNode(MetadataIndexNodeType nodeType);  MetadataIndexNode(List<MetadataIndexEntry> children, long endOffset,
      MetadataIndexNodeType nodeType); List<MetadataIndexEntry> getChildren(); long getEndOffset(); void setEndOffset(long endOffset); MetadataIndexNodeType getNodeType(); void addEntry(MetadataIndexEntry metadataIndexEntry); int serializeTo(OutputStream outputStream); static MetadataIndexNode deserializeFrom(ByteBuffer buffer); Pair<MetadataIndexEntry, Long> getChildIndexEntry(String key);  }
@Test public void testBinarySearchInChildren() { List<MetadataIndexEntry> list = new ArrayList<>(); list.add(new MetadataIndexEntry("s0", -1L)); list.add(new MetadataIndexEntry("s5", -1L)); list.add(new MetadataIndexEntry("s10", -1L)); list.add(new MetadataIndexEntry("s15", -1L)); list.add(new MetadataIndexEntry("s20", -1L)); MetadataIndexNode metadataIndexNode = new MetadataIndexNode(list, -1L, MetadataIndexNodeType.LEAF_MEASUREMENT); Assert.assertEquals(0, metadataIndexNode.binarySearchInChildren("s0")); Assert.assertEquals(2, metadataIndexNode.binarySearchInChildren("s10")); Assert.assertEquals(2, metadataIndexNode.binarySearchInChildren("s13")); Assert.assertEquals(4, metadataIndexNode.binarySearchInChildren("s23")); }