-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
these changes include usage of BucketedSort and ability to order the lines by both ascending and descending time/sort order.
- Loading branch information
Showing
14 changed files
with
476 additions
and
212 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
70 changes: 70 additions & 0 deletions
70
.../src/main/java/org/elasticsearch/xpack/core/common/search/aggregations/MissingHelper.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,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.common.search.aggregations; | ||
|
||
import org.elasticsearch.common.lease.Releasable; | ||
import org.elasticsearch.common.util.BigArrays; | ||
import org.elasticsearch.common.util.BitArray; | ||
|
||
/** | ||
* Helps long-valued {@link org.elasticsearch.search.sort.BucketedSort.ExtraData} track "empty" slots. It attempts to have | ||
* very low CPU overhead and no memory overhead when there *aren't* empty | ||
* values. | ||
*/ | ||
public class MissingHelper implements Releasable { | ||
private final BigArrays bigArrays; | ||
private BitArray tracker; | ||
|
||
public MissingHelper(BigArrays bigArrays) { | ||
this.bigArrays = bigArrays; | ||
} | ||
|
||
public void markMissing(long index) { | ||
if (tracker == null) { | ||
tracker = new BitArray(index, bigArrays); | ||
} | ||
tracker.set(index); | ||
} | ||
|
||
public void markNotMissing(long index) { | ||
if (tracker == null) { | ||
return; | ||
} | ||
tracker.clear(index); | ||
} | ||
|
||
public void swap(long lhs, long rhs) { | ||
if (tracker == null) { | ||
return; | ||
} | ||
boolean backup = tracker.get(lhs); | ||
if (tracker.get(rhs)) { | ||
tracker.set(lhs); | ||
} else { | ||
tracker.clear(lhs); | ||
} | ||
if (backup) { | ||
tracker.set(rhs); | ||
} else { | ||
tracker.clear(rhs); | ||
} | ||
} | ||
|
||
public boolean isEmpty(long index) { | ||
if (tracker == null) { | ||
return false; | ||
} | ||
return tracker.get(index); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
if (tracker != null) { | ||
tracker.close(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.