Validate segment value.

@param key the key
@param value the value
@param maximumNumber the maximum number
@param segmentNumber the segment number
@param test the test
@return the string
@throws IOException Signals that an I/O exception has occurred.
328505
public String validateSegmentValue(String key, T1 value, int maximumNumber,
      int segmentNumber, boolean test) throws IOException {
    if (!closed) {
      if (segmentRegistration != null) {
        if (maximumNumber > 0) {
          T1 tmpSegmentValueMaxListMin = segmentValueTopListLast
              .get(segmentName);
          T1 tmpSegmentValueBoundary = segmentValuesBoundary.get(segmentName);
          if (segmentValueTopList.size() < maximumNumber) {
            if (!test) {
              segmentKeyValueList.get(segmentName).put(key, value);
              segmentValueTopList.add(value);
              segmentValueTopListLast.put(segmentName,
                  (tmpSegmentValueMaxListMin == null) ? value
                      : lastForComputingSegment(tmpSegmentValueMaxListMin,
                          value));
              if (segmentValueTopList.size() == maximumNumber) {
                tmpSegmentValueMaxListMin = segmentValueTopListLast
                    .get(segmentName);
                segmentValueTopListLast.put(segmentName,
                    tmpSegmentValueMaxListMin);
                segmentValuesBoundary.put(segmentName,
                    boundaryForSegmentComputing(segmentName));
              }
            }
            return segmentKeys.contains(key) ? SEGMENT_KEY : SEGMENT_NEW;
          } else if (compareWithBoundary(value, tmpSegmentValueBoundary)) {
            // System.out.println(key+" "+value+" "+tmpSegmentValueBoundary);
            if (!test) {
              segmentKeyValueList.get(segmentName).put(key, value);
              if (compareWithBoundary(value, tmpSegmentValueMaxListMin)) {
                segmentValueTopList.add(value);
                segmentValueTopList.remove(tmpSegmentValueMaxListMin);
                tmpSegmentValueMaxListMin = lastForComputingSegment();
                segmentValueTopListLast.put(segmentName,
                    tmpSegmentValueMaxListMin);
                segmentValuesBoundary.put(segmentName,
                    boundaryForSegmentComputing(segmentName));
              }
            }
            return segmentKeys.contains(key) ? SEGMENT_KEY : SEGMENT_NEW;
          } else if (segmentKeys.contains(key)) {
            if (!test) {
              segmentKeyValueList.get(segmentName).put(key, value);
            }
            return SEGMENT_KEY;
          } else {
            return null;
          }
        } else {
          return null;
        }
      } else {
        return null;
      }
    } else {
      throw new IOException("already closed");
    }
  }
12665
public int getIntegerUseEval(String key) {
        String string = getStringUseEval(key);
        return Checker.isNull(string) ? null : Formatter.stringToInt(string);
    }
542343
private void validate() {

    if ((this.segments.length < 0) && (!this.snapshot)) {
      throw new IllegalArgumentException("segments.length:" + Integer.valueOf(this.segments.length));
    }
    for (int i = 0; i < this.segments.length; i++) {
      if (this.segments[i] < 0) {
        throw new IllegalArgumentException("segments[" + i + "]:" + Integer.valueOf(this.segments[i]));
      }
    }
    if (this.phaseNumber != null) {
      if (this.phaseNumber.intValue() < 0) {
        throw new IllegalArgumentException("phaseNumber:" + this.phaseNumber);
      }
      if (this.phase == null) {
        throw new IllegalArgumentException("phaseNumber (phase==null):" + this.phaseNumber);
      }
      if ((this.phase == DevelopmentPhase.RELEASE) && (this.phaseNumber.intValue() != 0)) {
        throw new IllegalArgumentException("phaseNumber (phase==RELEASE):" + this.phaseNumber);
      }
    }
  }
1161568
public EntryPosition getPosition(Object key, byte[] serializedKey) throws IOException {
      int segment = (key.hashCode() & Integer.MAX_VALUE) % segments.length;
      lock.readLock().lock();
      try {
         return IndexNode.applyOnLeaf(segments[segment], serializedKey, segments[segment].rootReadLock(), IndexNode.ReadOperation.GET_POSITION);
      } finally {
         lock.readLock().unlock();
      }
   }
867452
public void recomputeSegmentKeys() throws IOException {
    if (!closed && segmentRegistration != null) {
      if (segmentRegistration.equals(SEGMENT_SORT_ASC)
          || segmentRegistration.equals(SEGMENT_SORT_DESC)
          || segmentRegistration.equals(SEGMENT_BOUNDARY_ASC)
          || segmentRegistration.equals(SEGMENT_BOUNDARY_DESC)) {

        if (segmentRegistration.equals(SEGMENT_SORT_ASC)
            || segmentRegistration.equals(SEGMENT_SORT_DESC)) {
          segmentKeys.clear();
          // recompute boundaries
          for (Entry<String, Map<String, T1>> entry : segmentKeyValueList
              .entrySet()) {
            T1 tmpSegmentValueBoundary = boundaryForSegment(entry.getKey());
            segmentValuesBoundary.put(entry.getKey(), tmpSegmentValueBoundary);
          }
          // compute adjusted boundaries and compute keys
          for (Entry<String, Map<String, T1>> entry : segmentKeyValueList
              .entrySet()) {
            this.segmentName = entry.getKey();
            Map<String, T1> keyValueList = entry.getValue();
            T1 tmpSegmentValueBoundaryForComputing = boundaryForSegmentComputing(
                entry.getKey());
            for (Entry<String, T1> subEntry : keyValueList.entrySet()) {
              if (tmpSegmentValueBoundaryForComputing == null
                  || compareWithBoundary(subEntry.getValue(),
                      tmpSegmentValueBoundaryForComputing)) {
                if (!segmentKeys.contains(subEntry.getKey())) {
                  segmentKeys.add(subEntry.getKey());
                }
              }
            }
          }
        }

        Map<String, T1> keyValueList;
        Set<String> recomputeKeyList;
        segmentRecomputeKeyList = new LinkedHashMap<>();
        for (String key : segmentKeys) {
          for (Entry<String, Map<String, T1>> entry : segmentKeyValueList
              .entrySet()) {
            keyValueList = entry.getValue();
            if (!keyValueList.containsKey(key)) {
              if (!segmentRecomputeKeyList.containsKey(entry.getKey())) {
                recomputeKeyList = new HashSet<>();
                segmentRecomputeKeyList.put(entry.getKey(), recomputeKeyList);
              } else {
                recomputeKeyList = segmentRecomputeKeyList.get(entry.getKey());
              }
              recomputeKeyList.add(key);
            }
          }
        }
        this.segmentName = null;
      } else {
        throw new IOException(
            "not for segmentRegistration " + segmentRegistration);
      }
    } else {
      throw new IOException("already closed or no segmentRegistration ("
          + segmentRegistration + ")");
    }
  }
335603
@Override
  public Boolean getbit(final byte[] key, final long offset) {
    checkIsInMultiOrPipeline();
    client.getbit(key, offset);
    return client.getIntegerReply() == 1;
  }
501311
public int getRequiredInt(String key) {
        Optional<Integer> value = getInteger(key);
        if (value.isPresent()) {
            return value.get();
        }
        throw new IllegalStateException(String.format("required key [%s] not found", key));
    }
454847
@Override
    public final Integer optInt(final String key) {
        final int result = this.obj.optInt(key, Integer.MIN_VALUE);
        return result == Integer.MIN_VALUE ? null : result;
    }
10859
private static void validateKey(String key) {
		if (key == null || key.length() > MAX_KEY_SIZE) {
			throw new IllegalArgumentException("Invalid key - must be non null and have a length less than " + MAX_KEY_SIZE);
		}
	}
580536
public boolean containsKey(Object key) {
        if (key instanceof Number) {
            return containsKey( ((Number)key).intValue() );
        }
        else {
            return false;
        }
    }
1006258
@Override
  protected Long boundaryForSegment(String segmentName) throws IOException {
    if (segmentRegistration.equals(SEGMENT_SORT_ASC)
        || segmentRegistration.equals(SEGMENT_SORT_DESC)) {
      Long thisLast = segmentValueTopListLast.get(segmentName);
      if (thisLast == null) {
        return null;
      } else if (segmentRegistration.equals(SEGMENT_SORT_ASC)) {
        return thisLast * segmentNumber;
      } else {
        return Math.floorDiv(thisLast, segmentNumber);
      }
    } else {
      throw new IOException("can't compute boundary for segmentRegistration "
          + segmentRegistration);
    }
  }
792399
@Override
  public boolean validateSegmentBoundary(Object o) throws IOException {
    if (o instanceof Double) {
      return validateWithSegmentBoundary((Double) o);
    } else {
      throw new IOException("incorrect type");
    }
  }
25874
@Override
  public Long zcard(final byte[] key) {
    checkIsInMultiOrPipeline();
    client.zcard(key);
    return client.getIntegerReply();
  }
1184595
@Override
    public final int getInt(final String key) {
        Integer result = optInt(key);
        if (result == null) {
            throw new ObjectMissingException(this, key);
        }
        return result;
    }
369968
public T put(final int key, final T value) {
		int index = ((key & 0x7FFFFFFF) % elementKeys.length);
		T oldvalue = null;

		long entry = elementKeys[index];
		if (entry == Integer.MIN_VALUE) {
			++elementCount;
		} else {
			oldvalue = elementValues[index];
			collisions++;
		}
		elementKeys[index] = key;
		elementValues[index] = value;
		return oldvalue;
	}
836267
public V putIfAbsent( K key, V value )
  {
    if( value == null )
    {
      throw new NullPointerException();
    }
    int hash = hash( key.hashCode() );
    return segmentFor( hash ).put( key, hash, value, true );
  }
722331
@Override
	public int compare(int i, int j) {
		final int bufferNumI = i / this.indexEntriesPerSegment;
		final int segmentOffsetI = (i % this.indexEntriesPerSegment) * this.indexEntrySize;
		
		final int bufferNumJ = j / this.indexEntriesPerSegment;
		final int segmentOffsetJ = (j % this.indexEntriesPerSegment) * this.indexEntrySize;
		
		final MemorySegment segI = this.sortIndex.get(bufferNumI);
		final MemorySegment segJ = this.sortIndex.get(bufferNumJ);
		
		int val = MemorySegment.compare(segI, segJ, segmentOffsetI + OFFSET_LEN, segmentOffsetJ + OFFSET_LEN, this.numKeyBytes);
		
		if (val != 0 || this.normalizedKeyFullyDetermines) {
			return this.useNormKeyUninverted ? val : -val;
		}
		
		final long pointerI = segI.getLong(segmentOffsetI);
		final long pointerJ = segJ.getLong(segmentOffsetJ);
		
		return compareRecords(pointerI, pointerJ);
	}