-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializes PartiQLCursor and PartiQLValueLoader #1467
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3824d2f
Initializes PartiQLCursor and PartiQLValueLoader
johnedquinn f312566
Renames PartiQLResult.Value#value to cursor
johnedquinn 9d636d4
Updates signatures to use JVM names
johnedquinn 6870f4d
Clears cache and re-runs apiDump
johnedquinn f80b8b4
Removes java.sql.Clob and java.sql.Blob
johnedquinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 cursor: 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
250 changes: 250 additions & 0 deletions
250
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,250 @@ | ||
package org.partiql.value; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.sql.Blob; | ||
import java.sql.Clob; | ||
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 #isNull()} 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() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* 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() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* 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 isNull(); | ||
|
||
/** | ||
* Determines whether the current value is the missing value. Similarly, one can invoke {@link #getType()}. | ||
*/ | ||
public boolean isMissing(); | ||
|
||
/** | ||
* @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 applicable to the following types: | ||
* {@link PartiQLValueType#STRING}, | ||
* {@link PartiQLValueType#SYMBOL}, | ||
* {@link PartiQLValueType#CHAR} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
@NotNull | ||
String getString() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#BOOL} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
public boolean getBoolean() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#BINARY} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
* @deprecated BINARY doesn't exist in SQL or Ion. This is subject to deletion. | ||
*/ | ||
@Deprecated | ||
@NotNull | ||
public byte[] getBytes() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#BLOB} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
*/ | ||
@NotNull | ||
public Blob getBlob() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#CLOB} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
*/ | ||
@NotNull | ||
public Clob getClob() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#BYTE}, | ||
* {@link PartiQLValueType#INT8} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
* @deprecated BYTE is not present in SQL or Ion. This is subject to deletion. | ||
*/ | ||
@Deprecated | ||
public byte getByte() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#DATE} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
@NotNull | ||
public Date getDate() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#TIME} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
@NotNull | ||
public Time getTime() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#TIMESTAMP} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
@NotNull | ||
public Timestamp getTimestamp() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#INT16} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
public short getShort() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#INT32} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
public int getInt() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#INT64}, | ||
* {@link PartiQLValueType#INTERVAL} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
*/ | ||
// TODO: Internal note: This is WRONG for INTERVAL. Though, it already exists as such, therefore, this propagates | ||
// this weird behavior. Eventually, we'll need to add real support for INTERVAL. | ||
public long getLong() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#INT} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
* @apiNote <b>! ! ! EXPERIMENTAL ! ! !</b> This is an experimental API under development by the PartiQL maintainers. | ||
* Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice. | ||
*/ | ||
@NotNull | ||
public BigInteger getBigInteger() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#FLOAT32} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
public float getFloat() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#FLOAT64} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
public double getDouble() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* This is applicable to the following types: | ||
* {@link PartiQLValueType#DECIMAL}, | ||
* {@link PartiQLValueType#DECIMAL_ARBITRARY} | ||
* @return a value representing the applicable PartiQL value | ||
* @throws UnsupportedOperationException when this method is not applicable to the type returned by {@link PartiQLCursor#getType()} | ||
* @throws NullPointerException if this method is invoked when {@link PartiQLCursor#isNull()} returns true | ||
*/ | ||
@NotNull | ||
public BigDecimal getBigDecimal() throws UnsupportedOperationException, NullPointerException; | ||
|
||
/** | ||
* Converts a {@link PartiQLValue} into {@link PartiQLCursor}. | ||
*/ | ||
static PartiQLCursor of(PartiQLValue value) { | ||
return new PartiQLCursorDefault(value); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these are necessary considering you can use
getBytes()
. I would remove them for the time being so this package has to java.sql dependency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. Just updated to remove for now.