Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.partiql.spi.stream;

import org.jetbrains.annotations.NotNull;
import org.partiql.types.PType;
import org.partiql.value.datetime.Date;
import org.partiql.value.datetime.Time;
import org.partiql.value.datetime.Timestamp;

import java.math.BigDecimal;

/**
* This is a PartiQL value stream sink.
* <br>
* Developer Note:
* - There should be a method for every Datum *java* value and all PType arguments.
* - Method names are derived from PType.Kind as pascal case.
*/
public interface PSink {

default void close() {
// no-op
}

default void finish() {
// no-op
}

default void flush() {
// no-op
}

void writeNull();

void writeMissing();

void writeBool(boolean value);

void writeTinyint(byte value);

void writeSmallint(short value);

void writeInt(int value);

void writeBigint(long value);

void writeNumeric(@NotNull BigDecimal value);

void writeNumeric(@NotNull BigDecimal value, int precision);

void writeNumeric(@NotNull BigDecimal value, int precision, int scale);

void writeDecimal(@NotNull BigDecimal value);

void writeDecimal(@NotNull BigDecimal value, int precision);

void writeDecimal(@NotNull BigDecimal value, int precision, int scale);

void writeReal(float value);

void writeDouble(double value);

void writeChar(@NotNull String value, int length);

void writeVarchar(@NotNull String value, int length);

void writeString(@NotNull String value);

void writeBlob(@NotNull byte[] value, int length);

void writeClob(@NotNull byte[] value, int length);

void writeDate(@NotNull Date value);

void writeTime(@NotNull Time value, int precision);

void writeTimez(@NotNull Time value, int precision);

void writeTimestamp(@NotNull Timestamp value, int precision);

void writeTimestampz(@NotNull Timestamp value, int precision);

<T> void writeVariant(@NotNull T value);

void writeVariant(@NotNull String value, @NotNull String encoding);

void writeVariant(@NotNull byte[] value, @NotNull String encoding);

void writeField(@NotNull String name);

void stepIn(@NotNull PType container);

void stepOut();
}
86 changes: 86 additions & 0 deletions partiql-spi/src/main/java/org/partiql/spi/stream/PSource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package org.partiql.spi.stream;

import org.jetbrains.annotations.NotNull;
import org.partiql.types.PType;
import org.partiql.value.datetime.Date;
import org.partiql.value.datetime.Time;
import org.partiql.value.datetime.Timestamp;

import java.math.BigDecimal;

/**
* This is a PartiQL value stream source.
* <br>
* Developer Note:
* - There should be a method for every Datum *java* value and all PType arguments.
* - Method names are derived from PType.Kind as pascal case.
*/
public interface PSource {

default void close() {
// no-op
}

/**
* Positions the source to the next value, return its type.
*/
PType next();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotate as nullable


void readNull();

void readMissing();
Comment on lines +29 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely not necessary as these have no effect


boolean readBool();

byte readTinyint();

short readSmallint();

int readInt();

long readBigint();

@NotNull
BigDecimal readDecimal();

Comment on lines +43 to +45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing

@NotNull
BigDecimal readNumeric();

float readReal();

double readDouble();

@NotNull
String readChar();

@NotNull
String readVarchar();

@NotNull
String readString();

@NotNull
byte[] readBlob();

@NotNull
byte[] readClob();

@NotNull
Date readDate();

@NotNull
Time readTime();

@NotNull
Time readTimez();

@NotNull
Timestamp readTimestamp();

@NotNull
Timestamp readTimestampz();

@NotNull
String readField(@NotNull String name);

void stepIn();

void stepOut();
}
Empty file.
Empty file.
Loading