-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initializes PartiQLData and PartiQLValueLoader
- Loading branch information
1 parent
23cc28c
commit 34e2adf
Showing
10 changed files
with
701 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
partiql-eval/src/main/kotlin/org/partiql/eval/PartiQLResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package org.partiql.eval | ||
|
||
import org.partiql.value.PartiQLValue | ||
import org.partiql.value.PartiQLData | ||
import org.partiql.value.PartiQLValueExperimental | ||
|
||
public sealed interface PartiQLResult { | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
public data class Value(public val value: PartiQLValue) : PartiQLResult | ||
public data class Value(public val value: PartiQLData) : PartiQLResult | ||
|
||
public data class Error(public val cause: Throwable) : PartiQLResult | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
partiql-types/src/main/java/org/partiql/value/PartiQLData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package org.partiql.value; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.util.Iterator; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.partiql.value.datetime.Date; | ||
import org.partiql.value.datetime.Time; | ||
import org.partiql.value.datetime.Timestamp; | ||
|
||
/** | ||
* Data representing a database result set, which is usually generated by executing a statement that queries the database. | ||
* <p> | ||
* A {@link PartiQLData} object maintains a cursor pointing to its current position in the underlying data. Initially the | ||
* cursor is positioned before the first value. The {@link #next()} method moves the cursor to the next value. Please use | ||
* {@link #hasNext()} before calling {@link #next()}. | ||
* | ||
* @see PartiQLValueLoader#loadSingleValue(PartiQLData) | ||
* @see PartiQLValue | ||
*/ | ||
public interface PartiQLData extends AutoCloseable, Iterator<PartiQLValueType> { | ||
|
||
/** | ||
* Positions the reader just before the contents of the current value, which must be a container (list, bag, | ||
* sexp, or struct). There's no current value immediately after stepping in, so the next thing you'll want to do is call | ||
* {@link #hasNext()} and {@link #next()} to move onto the first child value. | ||
* <p> | ||
* If the container itself is the null value, stepIn() shall fail. Please use {@link #isNullValue()} before | ||
* invoking this. | ||
* <p> | ||
* At any time {@link #stepOut()} may be called to move the cursor back to (just after) the parent value, even if | ||
* there are more children remaining. | ||
*/ | ||
public void stepIn(); | ||
|
||
/** | ||
* Positions the iterator after the current parent's value, moving up one level in the data hierarchy. There's no | ||
* current value immediately after stepping out, so the next thing you'll want to do is call {@link #hasNext()} and | ||
* {@link #next()} to move onto the following value. | ||
*/ | ||
public void stepOut(); | ||
|
||
/** | ||
* Determines whether the current value is a null value of any type (for example, null or null.int). It should be | ||
* called before calling getters that return value types (int, long, boolean, double). | ||
*/ | ||
public boolean isNullValue(); | ||
|
||
/** | ||
* Determines whether the current value is the missing value. Similarly, one can invoke {@link #getType()}. | ||
*/ | ||
public boolean isMissingValue(); | ||
|
||
/** | ||
* @return the type of the data at the cursor. | ||
*/ | ||
@NotNull | ||
public PartiQLValueType getType(); | ||
|
||
/** | ||
* @return the field name of the current value; or null if there is no valid current value or if the current value | ||
* is not a field of a struct. | ||
*/ | ||
public String getFieldName(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#STRING}, | ||
* {@link PartiQLValueType#CHAR}, or {@link PartiQLValueType#SYMBOL}. | ||
*/ | ||
@NotNull | ||
String getStringValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#BOOL}. | ||
*/ | ||
public boolean getBoolValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#BINARY}, | ||
* {@link PartiQLValueType#BLOB}, or {@link PartiQLValueType#CLOB}. | ||
*/ | ||
public byte[] getBytes(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT8} or | ||
* {@link PartiQLValueType#BYTE}. | ||
*/ | ||
public byte getByteValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#DATE}. | ||
*/ | ||
@NotNull | ||
public Date getDate(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#TIME}. | ||
*/ | ||
@NotNull | ||
public Time getTime(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#TIMESTAMP}. | ||
*/ | ||
@NotNull | ||
public Timestamp getTimestamp(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INTERVAL}. | ||
*/ | ||
@Deprecated | ||
public long getIntervalValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT16}. | ||
*/ | ||
public short getShortValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT32}. | ||
*/ | ||
public int getIntValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT64}. | ||
*/ | ||
public long getLongValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT}. | ||
*/ | ||
@NotNull | ||
public BigInteger getBigIntValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#FLOAT32}. | ||
*/ | ||
public float getFloatValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#FLOAT64}. | ||
*/ | ||
public double getDoubleValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#DECIMAL} and | ||
* {@link PartiQLValueType#DECIMAL_ARBITRARY}. | ||
*/ | ||
@NotNull | ||
public BigDecimal getBigDecimalValue(); | ||
|
||
/** | ||
* Converts a {@link PartiQLValue} into {@link PartiQLData}. | ||
*/ | ||
static PartiQLData of(PartiQLValue value) { | ||
return new PartiQLDataDefault(value); | ||
} | ||
} |
Oops, something went wrong.