@Override
 public int hashCode() {
   int result = shard.hashCode();
   result = 31 * result + (int) (readerVersion ^ (readerVersion >>> 32));
   result = 31 * result + value.hashCode();
   return result;
 }
  public void testHashCode() throws IOException {
    // empty content must have hash 1 (JDK compat)
    BytesReference pbr = newBytesReference(0);
    assertEquals(Arrays.hashCode(BytesRef.EMPTY_BYTES), pbr.hashCode());

    // test with content
    pbr = newBytesReference(randomIntBetween(0, PAGE_SIZE * randomIntBetween(2, 5)));
    int jdkHash = Arrays.hashCode(pbr.toBytes());
    int pbrHash = pbr.hashCode();
    assertEquals(jdkHash, pbrHash);

    // test hashes of slices
    int sliceFrom = randomIntBetween(0, pbr.length());
    int sliceLength = randomIntBetween(pbr.length() - sliceFrom, pbr.length() - sliceFrom);
    BytesReference slice = pbr.slice(sliceFrom, sliceLength);
    int sliceJdkHash = Arrays.hashCode(slice.toBytes());
    int sliceHash = slice.hashCode();
    assertEquals(sliceJdkHash, sliceHash);
  }