-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add long flavored script field #59721
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.runtimefields.fielddata; | ||
|
||
import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues; | ||
import org.elasticsearch.xpack.runtimefields.LongScriptFieldScript; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
public final class ScriptLongDocValues extends AbstractSortedNumericDocValues { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use SortingNumericDocValues? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd force me to copy the longs from one array to the other rather than just sort. We already have to copy string because of BytesRef vs String stuff. But here I don't have to copy unless I want to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, makes sense then |
||
private final LongScriptFieldScript script; | ||
private int cursor; | ||
|
||
ScriptLongDocValues(LongScriptFieldScript script) { | ||
this.script = script; | ||
} | ||
|
||
@Override | ||
public boolean advanceExact(int docId) { | ||
script.runForDoc(docId); | ||
if (script.count() == 0) { | ||
return false; | ||
} | ||
Arrays.sort(script.values(), 0, script.count()); | ||
cursor = 0; | ||
return true; | ||
} | ||
|
||
@Override | ||
public long nextValue() throws IOException { | ||
return script.values()[cursor++]; | ||
} | ||
|
||
@Override | ||
public int docValueCount() { | ||
return script.count(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! that was my bad after all :D