-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initializes PartiQLCursor and PartiQLValueLoader
- Loading branch information
1 parent
4f89c2d
commit 3824d2f
Showing
11 changed files
with
815 additions
and
14 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.PartiQLCursor | ||
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: PartiQLCursor) : 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
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
187 changes: 187 additions & 0 deletions
187
partiql-types/src/main/java/org/partiql/value/PartiQLCursor.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,187 @@ | ||
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 PartiQLCursor} 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#load(PartiQLCursor) | ||
* @see PartiQLValue | ||
*/ | ||
public interface PartiQLCursor 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}. | ||
*/ | ||
@NotNull | ||
String getStringValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#CHAR}. | ||
*/ | ||
@NotNull | ||
String getCharValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#SYMBOL}. | ||
*/ | ||
@NotNull | ||
String getSymbolValue(); | ||
|
||
/** | ||
* 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}. | ||
*/ | ||
public byte[] getBinaryValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#BLOB}. | ||
*/ | ||
public byte[] getBlobValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#CLOB}. | ||
*/ | ||
public byte[] getClobValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#BYTE}. | ||
*/ | ||
public byte getByteValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#DATE}. | ||
*/ | ||
@NotNull | ||
public Date getDateValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#TIME}. | ||
*/ | ||
@NotNull | ||
public Time getTimeValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#TIMESTAMP}. | ||
*/ | ||
@NotNull | ||
public Timestamp getTimestampValue(); | ||
|
||
/** | ||
* 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#INT8}. | ||
*/ | ||
public byte getInt8Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT16}. | ||
*/ | ||
public short getInt16Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT32}. | ||
*/ | ||
public int getInt32Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT64}. | ||
*/ | ||
public long getInt64Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#INT}. | ||
*/ | ||
@NotNull | ||
public BigInteger getIntValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#FLOAT32}. | ||
*/ | ||
public float getFloat32Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#FLOAT64}. | ||
*/ | ||
public double getFloat64Value(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#DECIMAL}. | ||
*/ | ||
@NotNull | ||
public BigDecimal getDecimalValue(); | ||
|
||
/** | ||
* This is only applicable when the current value's type is {@link PartiQLValueType#DECIMAL_ARBITRARY}. | ||
*/ | ||
@NotNull | ||
public BigDecimal getDecimalArbitraryValue(); | ||
|
||
/** | ||
* Converts a {@link PartiQLValue} into {@link PartiQLCursor}. | ||
*/ | ||
static PartiQLCursor of(PartiQLValue value) { | ||
return new PartiQLCursorDefault(value); | ||
} | ||
} |
Oops, something went wrong.