Skip to content

Commit

Permalink
Initializes PQLValue and adds functionality to evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Apr 30, 2024
1 parent 607c4c0 commit d25de2d
Show file tree
Hide file tree
Showing 81 changed files with 2,437 additions and 341 deletions.
49 changes: 49 additions & 0 deletions partiql-eval/api/partiql-eval.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
public abstract interface class org/partiql/eval/PQLValue {
public static fun bagValue (Ljava/lang/Iterable;)Lorg/partiql/eval/PQLValue;
public static fun boolValue (Z)Lorg/partiql/eval/PQLValue;
public fun getBagValues ()Ljava/util/Iterator;
public fun getBinaryValue ()[B
public fun getBlobValue ()[B
public fun getBoolValue ()Z
public fun getByteValue ()B
public fun getCharValue ()Ljava/lang/String;
public fun getClobValue ()[B
public fun getDateValue ()Lorg/partiql/value/datetime/Date;
public fun getDecimalArbitraryValue ()Ljava/math/BigDecimal;
public fun getDecimalValue ()Ljava/math/BigDecimal;
public fun getFloat32Value ()F
public fun getFloat64Value ()D
public fun getInt16Value ()S
public fun getInt32Value ()I
public fun getInt64Value ()J
public fun getInt8Value ()B
public fun getIntValue ()Ljava/math/BigInteger;
public fun getIntervalValue ()J
public fun getListValues ()Ljava/util/Iterator;
public fun getSexpValues ()Ljava/util/Iterator;
public fun getStringValue ()Ljava/lang/String;
public fun getStructFields ()Ljava/util/Iterator;
public fun getSymbolValue ()Ljava/lang/String;
public fun getTimeValue ()Lorg/partiql/value/datetime/Time;
public fun getTimestampValue ()Lorg/partiql/value/datetime/Timestamp;
public abstract fun getType ()Lorg/partiql/value/PartiQLValueType;
public static fun int32Value (I)Lorg/partiql/eval/PQLValue;
public static fun int64Value (J)Lorg/partiql/eval/PQLValue;
public abstract fun isNull ()Z
public static fun listValue (Ljava/lang/Iterable;)Lorg/partiql/eval/PQLValue;
public static fun missingValue ()Lorg/partiql/eval/PQLValue;
public static fun nullValue ()Lorg/partiql/eval/PQLValue;
public static fun nullValue (Lorg/partiql/value/PartiQLValueType;)Lorg/partiql/eval/PQLValue;
public static fun of (Lorg/partiql/value/PartiQLValue;)Lorg/partiql/eval/PQLValue;
public static fun sexpValue (Ljava/lang/Iterable;)Lorg/partiql/eval/PQLValue;
public static fun stringValue (Ljava/lang/String;)Lorg/partiql/eval/PQLValue;
public static fun structValue (Ljava/lang/Iterable;)Lorg/partiql/eval/PQLValue;
public fun toPartiQLValue ()Lorg/partiql/value/PartiQLValue;
}

public abstract interface class org/partiql/eval/PartiQLEngine {
public static final field Companion Lorg/partiql/eval/PartiQLEngine$Companion;
public static fun builder ()Lorg/partiql/eval/PartiQLEngineBuilder;
Expand Down Expand Up @@ -63,3 +106,9 @@ public abstract interface class org/partiql/eval/PartiQLStatement {
public abstract interface class org/partiql/eval/PartiQLStatement$Query : org/partiql/eval/PartiQLStatement {
}

public abstract interface class org/partiql/eval/StructField {
public abstract fun getName ()Ljava/lang/String;
public abstract fun getValue ()Lorg/partiql/eval/PQLValue;
public static fun of (Ljava/lang/String;Lorg/partiql/eval/PQLValue;)Lorg/partiql/eval/StructField;
}

9 changes: 9 additions & 0 deletions partiql-eval/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ kotlin {
explicitApi = null
}

// Need to add this as we have both Java and Kotlin sources. Dokka already handles multi-language projects. If
// Javadoc is enabled, we end up overwriting index.html (causing compilation errors).
tasks.withType<Javadoc>() {
enabled = false
}
tasks.withType<Jar>() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

publish {
artifactId = "partiql-eval"
name = "PartiQL Lang Kotlin Evaluator"
Expand Down
37 changes: 37 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/BagValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

import java.util.Collections;
import java.util.Iterator;

/**
* This shall always be package-private (internal).
*/
class BagValue implements PQLValue {

@NotNull
final Iterable<PQLValue> _value;

BagValue(@NotNull Iterable<PQLValue> value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public Iterator<PQLValue> getBagValues() {
return _value.iterator();
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.BAG;
}
}
34 changes: 34 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/BinaryValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

/**
* This shall always be package-private (internal).
*/
class BinaryValue implements PQLValue {

@NotNull
final byte[] _value;

BinaryValue(@NotNull byte[] value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public byte[] getBinaryValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.BINARY;
}
}
34 changes: 34 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/BlobValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

/**
* This shall always be package-private (internal).
*/
class BlobValue implements PQLValue {

@NotNull
final byte[] _value;

BlobValue(@NotNull byte[] value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public byte[] getBlobValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.BLOB;
}
}
32 changes: 32 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/BoolValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

/**
* This shall always be package-private (internal).
*/
class BoolValue implements PQLValue {

final boolean _value;

BoolValue(boolean value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
public boolean getBoolValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.BOOL;
}
}
32 changes: 32 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/ByteValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

/**
* This shall always be package-private (internal).
*/
class ByteValue implements PQLValue {

final byte _value;

ByteValue(byte value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
public byte getByteValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.BYTE;
}
}
36 changes: 36 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/CharValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

import java.math.BigInteger;

/**
* This shall always be package-private (internal).
*/
class CharValue implements PQLValue {

@NotNull
final String _value;

CharValue(@NotNull String value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public String getCharValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.CHAR;
}
}
34 changes: 34 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/ClobValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

/**
* This shall always be package-private (internal).
*/
class ClobValue implements PQLValue {

@NotNull
final byte[] _value;

ClobValue(@NotNull byte[] value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public byte[] getClobValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.CLOB;
}
}
38 changes: 38 additions & 0 deletions partiql-eval/src/main/java/org/partiql/eval/DateValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;
import org.partiql.value.datetime.Date;
import org.partiql.value.datetime.Time;

import java.util.Objects;

/**
* This shall always be package-private (internal).
*/
class DateValue implements PQLValue {

@NotNull
final Date _value;

DateValue(@NotNull Date value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public Date getDateValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.DATE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.partiql.eval;

import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValueType;

import java.math.BigDecimal;

/**
* This shall always be package-private (internal).
*/
class DecimalArbitraryValue implements PQLValue {

@NotNull
final BigDecimal _value;

DecimalArbitraryValue(@NotNull BigDecimal value) {
_value = value;
}

@Override
public boolean isNull() {
return false;
}

@Override
@NotNull
public BigDecimal getDecimalArbitraryValue() {
return _value;
}

@NotNull
@Override
public PartiQLValueType getType() {
return PartiQLValueType.DECIMAL_ARBITRARY;
}
}
Loading

0 comments on commit d25de2d

Please sign in to comment.