public void removeRecordIndex(Long oldValue, Long recordId) {
   ConcurrentMap<Long, Record> records = mapRecords.get(oldValue);
   if (records != null) {
     records.remove(recordId);
     if (records.size() == 0) {
       mapRecords.remove(oldValue);
       sortedSet.remove(oldValue);
     }
   }
 }
 public void newRecordIndex(Long newValue, Record record) {
   long recordId = record.getId();
   ConcurrentMap<Long, Record> records = mapRecords.get(newValue);
   if (records == null) {
     records = new ConcurrentHashMap<Long, Record>(1, 0.75f, 1);
     mapRecords.put(newValue, records);
     sortedSet.add(newValue);
   }
   records.put(recordId, record);
 }
 public void getSubRecordsBetween(MultiResultSet results, Long from, Long to) {
   Set<Long> values = sortedSet.subSet(from, to);
   for (Long value : values) {
     ConcurrentMap<Long, Record> records = mapRecords.get(value);
     if (records != null) {
       results.addResultSet(value, records.values());
     }
   }
   // to wasn't included so include now
   ConcurrentMap<Long, Record> records = mapRecords.get(to);
   if (records != null) {
     results.addResultSet(to, records.values());
   }
 }
  public void getSubRecords(
      MultiResultSet results, PredicateType predicateType, Long searchedValue) {
    Set<Long> values = null;
    boolean notEqual = false;
    switch (predicateType) {
      case LESSER:
        values = sortedSet.headSet(searchedValue, false);
        break;
      case LESSER_EQUAL:
        values = sortedSet.headSet(searchedValue, true);
        break;
      case GREATER:
        values = sortedSet.tailSet(searchedValue, false);
        break;
      case GREATER_EQUAL:
        values = sortedSet.tailSet(searchedValue, true);
        break;
      case NOT_EQUAL:
        values = sortedSet;
        notEqual = true;
        break;
    }

    if (values != null) {
      for (Long value : values) {
        if (notEqual && searchedValue.longValue() == value.longValue()) {
          // skip this value if predicateType is NOT_EQUAL
          continue;
        }
        ConcurrentMap<Long, Record> records = mapRecords.get(value);
        if (records != null) {
          results.addResultSet(value, records.values());
        }
      }
    }
  }