You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2019/06/13 10:59:12 UTC

[lucene-solr] branch branch_8x updated (8995f21 -> 79fd320)

This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 8995f21  SOLR-13546: Fix typo 'hightlight' in webapp query interface (#704)
     new 28ef51b  SOLR-8754: add tests for org.apache.solr.util.hll.NumberUtilTest (#15)
     new 79fd320  SOLR-8754: CHANGES

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   |   2 +
 .../org/apache/solr/util/hll/NumberUtilTest.java   | 117 +++++++++++++++++++++
 2 files changed, 119 insertions(+)
 create mode 100644 solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java


[lucene-solr] 02/02: SOLR-8754: CHANGES

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 79fd32091eb9a0702af465bdf763fd6c28bfa366
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Thu Jun 13 12:57:39 2019 +0200

    SOLR-8754: CHANGES
    
    (cherry picked from commit bc97c4caa0f556d54d6daf0cba2b71bd2706cbec)
---
 solr/CHANGES.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b8b1144..97aa2c3 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -116,6 +116,8 @@ Other Changes
 
 * SOLR-13235: Split Collections API Ref Guide page into several smaller child pages (Cassandra Targett)
 
+* SOLR-8754: Adding test cases for org.apache.solr.util.hll.NumberUtilTest (Benoit Vanalderweireldt via janhoy)
+
 ==================  8.1.2 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.


[lucene-solr] 01/02: SOLR-8754: add tests for org.apache.solr.util.hll.NumberUtilTest (#15)

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 28ef51bff3bc7ded06c07b96c346f2f7bc64d76f
Author: Benoit Vanalderweireldt <be...@gmail.com>
AuthorDate: Thu Jun 13 12:57:13 2019 +0200

    SOLR-8754: add tests for org.apache.solr.util.hll.NumberUtilTest (#15)
    
    (cherry picked from commit 2c10b1de19725ac30a342f9b551f9b6ad155b093)
---
 .../org/apache/solr/util/hll/NumberUtilTest.java   | 117 +++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java b/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java
new file mode 100644
index 0000000..24cf7a0
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.solr.util.hll;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+/**
+ * Tests {@link NumberUtil}
+ */
+public class NumberUtilTest {
+
+  final static byte[] ALL_PRINTABLE_ASCII_CHARS = new byte[] { ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*',
+      '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A',
+      'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+      'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+      'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '', };
+
+  final static byte[] ALL_WORD_CHARAC_ASCII_CHARS = new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
+      'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+      'Y', 'Z' };
+
+  final static byte[] ALL_NUMBER_CHARAC_ASCII_CHARS = new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
+
+  final static byte[] ALL_LETTER_ASCII_CHARS = new byte[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
+      'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
+
+  final static String ALL_NUMBER_ASCII_CHARS_IN_HEX = "30313233343536373839";
+  final static String ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX = "4142434445464748494A4B4C4D4E4F" + "505152535455565758595A";
+  final static String ALL_LOW_LETTERS_ASCII_CHARS_IN_HEX = "6162636465666768696A6B6C6D6E6F" + "707172737475767778797A";
+
+  final static String ALL_PRINTABLE_ASCII_CHARS_IN_HEX = "202122232425262728292A2B2C2D2E2F"
+      + ALL_NUMBER_ASCII_CHARS_IN_HEX + "3A3B3C3D3E3F" + "40" + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX + "5B5C5D5E5F" + "60"
+      + ALL_LOW_LETTERS_ASCII_CHARS_IN_HEX + "7B7C7D7E7F";
+
+  /**
+   * Test {@link NumberUtil#log2(double)}.
+   */
+  @Test
+  public void testLog2() {
+    final double log2Result = NumberUtil.log2(2d);
+    assertTrue(log2Result == 1);
+  }
+
+  /**
+   * Test {@link NumberUtil#toHex(byte[], int, int)}
+   */
+  @Test
+  public void TestToHex() {
+    assertTrue(ALL_PRINTABLE_ASCII_CHARS_IN_HEX
+        .equals(NumberUtil.toHex(ALL_PRINTABLE_ASCII_CHARS, 0, ALL_PRINTABLE_ASCII_CHARS.length)));
+  }
+
+  /**
+   * Test {@link NumberUtil#toHex(byte[], int, int)}
+   */
+  @Test
+  public void TestToHexWithOffset() {
+    assertTrue(ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX
+        .equals(NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 10, ALL_PRINTABLE_ASCII_CHARS.length)));
+  }
+
+  /**
+   * Test {@link NumberUtil#toHex(byte[], int, int)}
+   */
+  @Test
+  public void TestToHexWithCountt() {
+    assertTrue(ALL_NUMBER_ASCII_CHARS_IN_HEX.equals(NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 0, 10)));
+  }
+
+  /**
+   * Test {@link NumberUtil#fromHex(String, int, int)}
+   */
+  @Test
+  public void TestFromHex() {
+    assertTrue(
+        Arrays
+            .equals(
+                NumberUtil.fromHex(ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX
+                    + ALL_LOW_LETTERS_ASCII_CHARS_IN_HEX, 0, ALL_WORD_CHARAC_ASCII_CHARS.length * 2),
+        ALL_WORD_CHARAC_ASCII_CHARS));
+  }
+
+  /**
+   * Test {@link NumberUtil#fromHex(String, int, int)}
+   */
+  @Test
+  public void TestFromHexWithOffset() {
+    assertTrue(Arrays.equals(NumberUtil.fromHex(ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX, 20,
+        ALL_LETTER_ASCII_CHARS.length * 2), ALL_LETTER_ASCII_CHARS));
+  }
+
+  /**
+   * Test {@link NumberUtil#fromHex(String, int, int)}
+   */
+  @Test
+  public void TestFromHexWithCount() {
+    assertTrue(Arrays.equals(NumberUtil.fromHex(ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX, 0,
+        20), ALL_NUMBER_CHARAC_ASCII_CHARS));
+  }
+}