Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11209#discussion_r56040046
  
    --- Diff: 
sql/catalyst/src/test/java/org/apache/spark/sql/catalyst/expressions/XXH64Suite.java
 ---
    @@ -0,0 +1,159 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions;
    +
    +import java.nio.charset.StandardCharsets;
    +import java.util.HashSet;
    +import java.util.Random;
    +import java.util.Set;
    +
    +import org.apache.spark.unsafe.Platform;
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +/**
    + * Test the XXH64 function.
    + *
    + * Test constants were taken from the original implementation and the 
airlift/slice implementation.
    + */
    +public class XXH64Suite {
    +
    +  private static final XXH64 hasher = new XXH64(0);
    +
    +  private static final int SIZE = 101;
    +  private static final long PRIME = 2654435761L;
    +  private static final byte[] BUFFER = new byte[SIZE];
    +  private static final int TEST_INT = Platform.getInt(BUFFER, 
Platform.BYTE_ARRAY_OFFSET);
    +  private static final long TEST_LONG = Platform.getLong(BUFFER, 
Platform.BYTE_ARRAY_OFFSET);
    +
    +  /* Create the test data buffer. */
    +  static {
    +    long seed = PRIME;
    +    for (int i = 0; i < SIZE; i++) {
    +      BUFFER[i] = (byte)(seed >> 24);
    +      seed *= seed;
    +    }
    +  }
    +
    +  @Test
    +  public void testKnownIntegerInputs() {
    +    Assert.assertEquals(0x9256E58AA397AEF1L, hasher.hashInt(TEST_INT));
    --- End diff --
    
    Is this assertion endian independent?  I think that this assertion assumes 
little-endian. s.m.u.getInt() and s.m.u.getLong fetch data by using machine 
native endian.
    
http://java-performance.info/various-methods-of-binary-serialization-in-java/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to