From 5c9c4776cd3dfb634ec9292eb73682f4b987413e Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 13 May 2015 14:13:10 +0200 Subject: [PATCH] Internal: remove dependency on hppc:esoteric. The esoteric classifier contains in particular maps that take bytes or doubles as keys. In the byte case, we can just use integer, and in the double case we can use their long bits instead. --- pom.xml | 7 ------- .../index/mapper/core/NumberFieldMapper.java | 2 -- .../percolator/PercolatorService.java | 6 +++--- .../index/fielddata/LongFieldDataTests.java | 16 ++++++++-------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index a396fa4f8c9..83e45062a88 100644 --- a/pom.xml +++ b/pom.xml @@ -229,13 +229,6 @@ 0.7.1 - - com.carrotsearch - hppc - 0.7.1 - esoteric - - joda-time joda-time diff --git a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java index 088be23c111..05f4044d142 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java @@ -19,9 +19,7 @@ package org.elasticsearch.index.mapper.core; -import com.carrotsearch.hppc.DoubleHashSet; import com.carrotsearch.hppc.LongArrayList; -import com.carrotsearch.hppc.LongHashSet; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.NumericTokenStream; diff --git a/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 3edab192d33..9fd56f11778 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.percolator; -import com.carrotsearch.hppc.ByteObjectHashMap; +import com.carrotsearch.hppc.IntObjectHashMap; import com.google.common.collect.Lists; import org.apache.lucene.index.LeafReaderContext; @@ -109,7 +109,7 @@ public class PercolatorService extends AbstractComponent { public final static String TYPE_NAME = ".percolator"; private final IndicesService indicesService; - private final ByteObjectHashMap percolatorTypes; + private final IntObjectHashMap percolatorTypes; private final PageCacheRecycler pageCacheRecycler; private final BigArrays bigArrays; private final ClusterService clusterService; @@ -153,7 +153,7 @@ public class PercolatorService extends AbstractComponent { single = new SingleDocumentPercolatorIndex(cache); multi = new MultiDocumentPercolatorIndex(cache); - percolatorTypes = new ByteObjectHashMap<>(6); + percolatorTypes = new IntObjectHashMap<>(6); percolatorTypes.put(countPercolator.id(), countPercolator); percolatorTypes.put(queryCountPercolator.id(), queryCountPercolator); percolatorTypes.put(matchPercolator.id(), matchPercolator); diff --git a/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java b/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java index 2b293bd088f..09a24a4283c 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/LongFieldDataTests.java @@ -19,9 +19,7 @@ package org.elasticsearch.index.fielddata; -import com.carrotsearch.hppc.DoubleHashSet; import com.carrotsearch.hppc.LongHashSet; -import com.carrotsearch.hppc.cursors.DoubleCursor; import com.carrotsearch.hppc.cursors.LongCursor; import org.apache.lucene.document.Document; @@ -37,7 +35,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; /** * Tests for all integer types (byte, short, int, long). @@ -348,7 +348,7 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { final SortedNumericDocValues data = atomicFieldData.getLongValues(); final SortedNumericDoubleValues doubleData = atomicFieldData.getDoubleValues(); final LongHashSet set = new LongHashSet(); - final DoubleHashSet doubleSet = new DoubleHashSet(); + final LongHashSet doubleSet = new LongHashSet(); for (int i = 0; i < values.size(); ++i) { final LongHashSet v = values.get(i); @@ -365,17 +365,17 @@ public class LongFieldDataTests extends AbstractNumericFieldDataTests { } assertThat(set, equalTo(v)); - final DoubleHashSet doubleV = new DoubleHashSet(); + final LongHashSet doubleV = new LongHashSet(); for (LongCursor c : v) { - doubleV.add(c.value); + doubleV.add(Double.doubleToLongBits(c.value)); } doubleSet.clear(); doubleData.setDocument(i); numValues = doubleData.count(); double prev = 0; for (int j = 0; j < numValues; j++) { - double current; - doubleSet.add(current = doubleData.valueAt(j)); + double current = doubleData.valueAt(j); + doubleSet.add(Double.doubleToLongBits(current)); if (j > 0) { assertThat(prev, lessThan(current)); }