Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-12 Thread Alexei Scherbakov
tuple.isNull(colName) to test for emptiness also seems useful. пн, 12 июл. 2021 г. в 18:20, Alexei Scherbakov : > +1 to make some improvements here. > > Using Optional doesn't make sense to me because it always involves boxing > (and we already have tuple.value(colName)). > > I suggest to add

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-12 Thread Alexei Scherbakov
+1 to make some improvements here. Using Optional doesn't make sense to me because it always involves boxing (and we already have tuple.value(colName)). I suggest to add methods similar to: tuple.doubleValue("field", double dfltValue) which returns default value if the field is null. ср, 7

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Ivan Daschinsky
Function basically returns two values. if value is null, it returns smth like false, NaN, otherwise ,smth like true, 4.5. Syntax is a bit weird as for me, but it is better than nothing. In golang it looks like this: if isValid, val:= getVal; isValid { } ср, 7 июл. 2021 г., 00:28

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Valentin Kulichenko
So what happens if the value is NULL? Exception? -Val On Tue, Jul 6, 2021 at 1:52 PM Ivan Daschinsky wrote: > > Out of curiosity, what would this code do if the value is NULL? What is > the > type of the 'weight' variable? > > float of course. >

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Ivan Daschinsky
> Out of curiosity, what would this code do if the value is NULL? What is the type of the 'weight' variable? float of course. https://www.c-sharpcorner.com/article/out-parameter-in-c-sharp-7/ вт, 6 июл. 2021 г., 22:30 Valentin Kulichenko : > Pavel, > > Optionals are available in Java and we

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Valentin Kulichenko
Pavel, Optionals are available in Java and we can use them. This is still boxing though, and I don't know what the performance impact would be. In addition, optional API is redundant for non-nullable fields. Perhaps, we can provide both options (e.g. having intValue() and intValueOptional()

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Ivan Daschinsky
Ah, I see, you meant Optionals family. Yep, it is worth to think about. вт, 6 июл. 2021 г., 10:06 Pavel Tupitsyn : > Ivan, > > Nothing wrong except for performance concerns. > The following code looks up the column by name twice: > > if (!tuple.isNull("weight")) >

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Pavel Tupitsyn
Ivan, Nothing wrong except for performance concerns. The following code looks up the column by name twice: if (!tuple.isNull("weight")) doSomething(tuple.floatValue("weight")) Whereas in other languages you could do it in one shot: if (tuple.TryGetFloatValue("weight", out var weight))

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Ivan Daschinsky
Sorry, but what is wrong with simple method isNull() вт, 6 июл. 2021 г., 09:55 Pavel Tupitsyn : > Val, > > > I don't think there is a significantly better way > > of doing this in Java. > > Yep looks like there is no way to return two values without boxing. > No ref, no out, no value types. > >

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-06 Thread Pavel Tupitsyn
Val, > I don't think there is a significantly better way > of doing this in Java. Yep looks like there is no way to return two values without boxing. No ref, no out, no value types. > Schema already provides this information, doesn't it? It does, though we don't have an agreement on how to

Re: Ignite 3.0 Tuple API: how to check if value is null?

2021-07-05 Thread Valentin Kulichenko
Pavel, That's a good point, but I don't think there is a significantly better way of doing this in Java. There should be a way to check if a field is nullable or not though. Schema already provides this information, doesn't it? -Val On Mon, Jul 5, 2021 at 11:03 AM Pavel Tupitsyn wrote: >

Ignite 3.0 Tuple API: how to check if value is null?

2021-07-05 Thread Pavel Tupitsyn
Igniters, Looks like Tuple API has no efficient way to tell if a value for a nullable column of primitive type is null. - Tuple#intValue() will return 0 when the actual value is null => not clear if 0 is 0 or null. - Tuple#value() works, but is more expensive due to boxing and type lookup. Any