@Override
    public int compareTo(RowBasedKey other) {
      final int timeCompare = Longs.compare(timestamp, other.getTimestamp());
      if (timeCompare != 0) {
        return timeCompare;
      }

      for (int i = 0; i < dimensions.length; i++) {
        final int cmp = dimensions[i].compareTo(other.getDimensions()[i]);
        if (cmp != 0) {
          return cmp;
        }
      }

      return 0;
    }
    @Override
    public ByteBuffer toByteBuffer(RowBasedKey key) {
      keyBuffer.rewind();

      if (fudgeTimestamp == null) {
        keyBuffer.putLong(key.getTimestamp());
      }

      for (int i = 0; i < key.getDimensions().length; i++) {
        final int id = addToDictionary(key.getDimensions()[i]);
        if (id < 0) {
          return null;
        }
        keyBuffer.putInt(id);
      }

      keyBuffer.flip();
      return keyBuffer;
    }