-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated p/c queries from id cache to field data. Changed p/c queries…
… to use paging data structures (BytesRefHash, BigFloatArray, BigIntArray) instead of hppc maps / sets. Also removed the id cache. Closes #4930
- Loading branch information
Showing
71 changed files
with
2,184 additions
and
1,700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/main/java/org/elasticsearch/common/util/BigFloatArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch 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.elasticsearch.common.util; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.apache.lucene.util.ArrayUtil; | ||
import org.apache.lucene.util.RamUsageEstimator; | ||
import org.elasticsearch.cache.recycler.PageCacheRecycler; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.elasticsearch.common.util.BigArrays.FLOAT_PAGE_SIZE; | ||
|
||
/** | ||
* Float array abstraction able to support more than 2B values. This implementation slices data into fixed-sized blocks of | ||
* configurable length. | ||
*/ | ||
final class BigFloatArray extends AbstractBigArray implements FloatArray { | ||
|
||
private float[][] pages; | ||
|
||
/** Constructor. */ | ||
public BigFloatArray(long size, PageCacheRecycler recycler, boolean clearOnResize) { | ||
super(FLOAT_PAGE_SIZE, recycler, clearOnResize); | ||
this.size = size; | ||
pages = new float[numPages(size)][]; | ||
for (int i = 0; i < pages.length; ++i) { | ||
pages[i] = newFloatPage(i); | ||
} | ||
} | ||
|
||
@Override | ||
public float set(long index, float value) { | ||
final int pageIndex = pageIndex(index); | ||
final int indexInPage = indexInPage(index); | ||
final float[] page = pages[pageIndex]; | ||
final float ret = page[indexInPage]; | ||
page[indexInPage] = value; | ||
return ret; | ||
} | ||
|
||
@Override | ||
public float increment(long index, float inc) { | ||
final int pageIndex = pageIndex(index); | ||
final int indexInPage = indexInPage(index); | ||
return pages[pageIndex][indexInPage] += inc; | ||
} | ||
|
||
public float get(long index) { | ||
final int pageIndex = pageIndex(index); | ||
final int indexInPage = indexInPage(index); | ||
return pages[pageIndex][indexInPage]; | ||
} | ||
|
||
@Override | ||
protected int numBytesPerElement() { | ||
return RamUsageEstimator.NUM_BYTES_FLOAT; | ||
} | ||
|
||
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */ | ||
public void resize(long newSize) { | ||
final int numPages = numPages(newSize); | ||
if (numPages > pages.length) { | ||
pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF)); | ||
} | ||
for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) { | ||
pages[i] = newFloatPage(i); | ||
} | ||
for (int i = numPages; i < pages.length && pages[i] != null; ++i) { | ||
pages[i] = null; | ||
releasePage(i); | ||
} | ||
this.size = newSize; | ||
} | ||
|
||
@Override | ||
public void fill(long fromIndex, long toIndex, float value) { | ||
Preconditions.checkArgument(fromIndex <= toIndex); | ||
final int fromPage = pageIndex(fromIndex); | ||
final int toPage = pageIndex(toIndex - 1); | ||
if (fromPage == toPage) { | ||
Arrays.fill(pages[fromPage], indexInPage(fromIndex), indexInPage(toIndex - 1) + 1, value); | ||
} else { | ||
Arrays.fill(pages[fromPage], indexInPage(fromIndex), pages[fromPage].length, value); | ||
for (int i = fromPage + 1; i < toPage; ++i) { | ||
Arrays.fill(pages[i], value); | ||
} | ||
Arrays.fill(pages[toPage], 0, indexInPage(toIndex - 1) + 1, value); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.