Skip to content
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

Script: ulong via fields API (#76519) #76613

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

stu-elastic
Copy link
Contributor

@stu-elastic stu-elastic commented Aug 17, 2021

Exposes unsigned long via the fields API.

Unsigned longs default to java signed longs. That means the upper range
appears negative. Consumers should use Long.compareUnsigned(long, long)
Long.divideUnsigned(long, long) and Long.remainderUnsigned(long, long)
to correctly work with values known to be unsigned long.

Alternatively, users may treat the unsigned long type as BigInteger using
the field API, field('ul').as(Field.BigInteger).getValue(BigInteger.ZERO).

field('ul').as(Field.BigInteger).getValue(BigInteger.valueOf(1000))
field('ul').getValue(1000L)

This change also implements the beginning of the converters for the fields
API. The following conversions have been added:

ulong <-> BigInteger
long <-> BigInteger
double -> BigInteger
String (parsed as long or double) -> BigInteger
double -> long
String (parsed as long or double) -> long
Date (epoch milliseconds) -> long
Nano Date (epoch nanoseconds) -> long
boolean (1L for true, 0L for false) -> long

Backport: aea8bff

Exposes unsigned long via the fields API.

Unsigned longs default to java signed longs.  That means the upper range
appears negative.  Consumers should use `Long.compareUnsigned(long, long)`
`Long.divideUnsigned(long, long)` and `Long.remainderUnsigned(long, long)`
to correctly work with values known to be unsigned long.

Alternatively, users may treat the unsigned long type as `BigInteger` using
the field API, `field('ul').as(Field.BigInteger).getValue(BigInteger.ZERO)`.
```
field('ul').as(Field.BigInteger).getValue(BigInteger.valueOf(1000))
field('ul').getValue(1000L)
```

This change also implements the beginning of the converters for the fields
API.  The following conversions have been added:
```
ulong <-> BigInteger
long <-> BigInteger
double -> BigInteger
String (parsed as long or double) -> BigInteger
double -> long
String (parsed as long or double) -> long
Date (epoch milliseconds) -> long
Nano Date (epoch nanoseconds) -> long
boolean (1L for true, 0L for false) -> long
```

Backport: aea8bff
@stu-elastic stu-elastic added >enhancement :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache backport v7.15.0 labels Aug 17, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Aug 17, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@stu-elastic stu-elastic merged commit 5491d94 into elastic:7.x Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement Team:Core/Infra Meta label for core/infra team v7.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants