3
3
import kotlin .NotImplementedError ;
4
4
import kotlin .Pair ;
5
5
import org .jetbrains .annotations .NotNull ;
6
- import org .partiql .spi .BindingName ;
7
6
import org .partiql .value .PartiQL ;
8
7
import org .partiql .value .PartiQLValue ;
9
8
import org .partiql .value .PartiQLValueType ;
@@ -347,7 +346,7 @@ default Iterator<StructField> getFields() {
347
346
* {@link #isNull()} returns false before attempting to invoke this method.
348
347
*/
349
348
@ NotNull
350
- default Iterable < StructField > get (@ NotNull String name ) {
349
+ default PQLValue get (@ NotNull String name ) {
351
350
throw new UnsupportedOperationException ();
352
351
}
353
352
@@ -361,7 +360,7 @@ default Iterable<StructField> get(@NotNull String name) {
361
360
* {@link #isNull()} returns false before attempting to invoke this method.
362
361
*/
363
362
@ NotNull
364
- default Iterable < StructField > getInsensitive (@ NotNull String name ) {
363
+ default PQLValue getInsensitive (@ NotNull String name ) {
365
364
throw new UnsupportedOperationException ();
366
365
}
367
366
@@ -420,35 +419,13 @@ default PartiQLValue toPartiQLValue() {
420
419
case INTERVAL :
421
420
return this .isNull () ? PartiQL .intervalValue (null ) : PartiQL .intervalValue (this .getIntervalValue ());
422
421
case BAG :
423
- return this .isNull () ? PartiQL .bagValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .bagValue (
424
- new IterableFromIteratorSupplier <>(() -> new PQLToPartiQLIterator (this .iterator ()))
425
- );
422
+ return this .isNull () ? PartiQL .bagValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .bagValue (new PQLToPartiQLIterable (this ));
426
423
case LIST :
427
- return this .isNull () ? PartiQL .listValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .listValue (
428
- new IterableFromIteratorSupplier <>(() -> new PQLToPartiQLIterator (this .iterator ()))
429
- );
424
+ return this .isNull () ? PartiQL .listValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .listValue (new PQLToPartiQLIterable (this ));
430
425
case SEXP :
431
- return this .isNull () ? PartiQL .sexpValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .sexpValue (
432
- new IterableFromIteratorSupplier <>(() -> new PQLToPartiQLIterator (this .iterator ()))
433
- );
426
+ return this .isNull () ? PartiQL .sexpValue ((Iterable <? extends PartiQLValue >) null ) : PartiQL .sexpValue (new PQLToPartiQLIterable (this ));
434
427
case STRUCT :
435
- return this .isNull () ? PartiQL .structValue ((Iterable <? extends Pair <String , ? extends PartiQLValue >>) null ) : PartiQL .structValue (
436
- new IterableFromIteratorSupplier <>(() -> {
437
- Iterator <StructField > _fields = this .getFields ();
438
- return new Iterator <Pair <String , PartiQLValue >>() {
439
- @ Override
440
- public boolean hasNext () {
441
- return _fields .hasNext ();
442
- }
443
-
444
- @ Override
445
- public Pair <String , PartiQLValue > next () {
446
- StructField field = _fields .next ();
447
- return new Pair <>(field .getName (), field .getValue ().toPartiQLValue ());
448
- }
449
- };
450
- })
451
- );
428
+ return this .isNull () ? PartiQL .structValue ((Iterable <? extends Pair <String , ? extends PartiQLValue >>) null ) : PartiQL .structValue (new PQLToPartiQLStruct (this ));
452
429
case NULL :
453
430
return PartiQL .nullValue ();
454
431
case MISSING :
@@ -480,9 +457,8 @@ static PQLValue of(PartiQLValue value) {
480
457
org .partiql .value .Int8Value int8Value = (org .partiql .value .Int8Value ) value ;
481
458
return new Int8Value (Objects .requireNonNull (int8Value .getValue ()));
482
459
case STRUCT :
483
- @ SuppressWarnings ("unchecked" )
484
- org .partiql .value .StructValue <PartiQLValue > STRUCTValue = (org .partiql .value .StructValue <PartiQLValue >) value ;
485
- return new StructValue (new StructFieldIterableWrapper (Objects .requireNonNull (STRUCTValue .getEntries ())));
460
+ @ SuppressWarnings ("unchecked" ) org .partiql .value .StructValue <PartiQLValue > STRUCTValue = (org .partiql .value .StructValue <PartiQLValue >) value ;
461
+ return new StructValue (new PartiQLToPQLStruct (Objects .requireNonNull (STRUCTValue )));
486
462
case STRING :
487
463
org .partiql .value .StringValue STRINGValue = (org .partiql .value .StringValue ) value ;
488
464
return new StringValue (Objects .requireNonNull (STRINGValue .getValue ()));
@@ -496,26 +472,23 @@ static PQLValue of(PartiQLValue value) {
496
472
org .partiql .value .Int16Value INT16Value = (org .partiql .value .Int16Value ) value ;
497
473
return new Int16Value (Objects .requireNonNull (INT16Value .getValue ()));
498
474
case SEXP :
499
- @ SuppressWarnings ("unchecked" )
500
- org .partiql .value .SexpValue <PartiQLValue > sexpValue = (org .partiql .value .SexpValue <PartiQLValue >) value ;
501
- return new SexpValue (new PartiQLValueIterableWrapper (Objects .requireNonNull (sexpValue )));
475
+ @ SuppressWarnings ("unchecked" ) org .partiql .value .SexpValue <PartiQLValue > sexpValue = (org .partiql .value .SexpValue <PartiQLValue >) value ;
476
+ return new SexpValue (new PartiQLToPQLIterable (Objects .requireNonNull (sexpValue )));
502
477
case LIST :
503
- @ SuppressWarnings ("unchecked" )
504
- org .partiql .value .ListValue <PartiQLValue > LISTValue = (org .partiql .value .ListValue <PartiQLValue >) value ;
505
- return new ListValue (new PartiQLValueIterableWrapper (Objects .requireNonNull (LISTValue )));
478
+ @ SuppressWarnings ("unchecked" ) org .partiql .value .ListValue <PartiQLValue > LISTValue = (org .partiql .value .ListValue <PartiQLValue >) value ;
479
+ return new ListValue (new PartiQLToPQLIterable (Objects .requireNonNull (LISTValue )));
506
480
case BOOL :
507
481
org .partiql .value .BoolValue BOOLValue = (org .partiql .value .BoolValue ) value ;
508
482
return new BoolValue (Objects .requireNonNull (BOOLValue .getValue ()));
509
483
case INT :
510
484
org .partiql .value .IntValue INTValue = (org .partiql .value .IntValue ) value ;
511
485
return new IntValue (Objects .requireNonNull (INTValue .getValue ()));
512
486
case BAG :
513
- @ SuppressWarnings ("unchecked" )
514
- org .partiql .value .BagValue <PartiQLValue > BAGValue = (org .partiql .value .BagValue <PartiQLValue >) value ;
515
- return new BagValue (new PartiQLValueIterableWrapper (Objects .requireNonNull (BAGValue )));
487
+ @ SuppressWarnings ("unchecked" ) org .partiql .value .BagValue <PartiQLValue > BAGValue = (org .partiql .value .BagValue <PartiQLValue >) value ;
488
+ return new BagValue (new PartiQLToPQLIterable (Objects .requireNonNull (BAGValue )));
516
489
case BINARY :
517
490
org .partiql .value .BinaryValue BINARYValue = (org .partiql .value .BinaryValue ) value ;
518
- return new BinaryValue (Objects .requireNonNull (BINARYValue .getValue ().toByteArray ()));
491
+ return new BinaryValue (Objects .requireNonNull (Objects . requireNonNull ( BINARYValue .getValue () ).toByteArray ()));
519
492
case DATE :
520
493
org .partiql .value .DateValue DATEValue = (org .partiql .value .DateValue ) value ;
521
494
return new DateValue (Objects .requireNonNull (DATEValue .getValue ()));
0 commit comments