Skip to content

Commit

Permalink
accommodate the latest specifications of serde at blob and clob
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jan 23, 2025
1 parent dd9db7a commit 6b40f7e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public final class BlobReferenceForSql implements BlobReference {
final SqlCommon.LargeObjectReference largeObjectReference;
Response response;

public BlobReferenceForSql(long objectId) {
public BlobReferenceForSql(long provider, long objectId) {
largeObjectReference = SqlCommon.LargeObjectReference.newBuilder()
.setProvider(SqlCommon.LargeObjectProvider.SQL)
.setProvider(SqlCommon.LargeObjectProvider.forNumber((int) provider))
.setObjectId(objectId)
.build();
this.response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public final class ClobReferenceForSql implements ClobReference {
final SqlCommon.LargeObjectReference largeObjectReference;
Response response;

public ClobReferenceForSql(long objectId) {
public ClobReferenceForSql(long provider, long objectId) {
largeObjectReference = SqlCommon.LargeObjectReference.newBuilder()
.setProvider(SqlCommon.LargeObjectProvider.SQL)
.setProvider(SqlCommon.LargeObjectProvider.forNumber((int) provider))
.setObjectId(objectId)
.build();
this.response = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ public DateTimeInterval fetchDateTimeIntervalValue() throws IOException, Interru
@Override
public BlobReference fetchBlob() throws IOException, InterruptedException {
requireColumnType(EntryType.BLOB);
var value = new BlobReferenceForSql(input.readBlob());
var value = input.readBlob();
columnConsumed();
return value;
}

@Override
public ClobReference fetchClob() throws IOException, InterruptedException {
requireColumnType(EntryType.CLOB);
var value = new ClobReferenceForSql(input.readClob());
var value = input.readClob();
columnConsumed();
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tsurugidb.tsubakuro.sql.BlobReference;
import com.tsurugidb.tsubakuro.sql.ClobReference;
import com.tsurugidb.tsubakuro.sql.impl.BlobReferenceForSql;
import com.tsurugidb.tsubakuro.sql.impl.ClobReferenceForSql;

/**
* {@link ValueInput} from {@link InputStream}.
* @see StreamBackedValueOutput
Expand Down Expand Up @@ -535,17 +540,21 @@ public DateTimeInterval readDateTimeInterval() throws IOException {
}

@Override
public long readBlob() throws IOException {
public BlobReference readBlob() throws IOException {
require(EntryType.BLOB);
clearHeaderInfo();
return readIntBody();
var provider = read8();
var objectId = read8();
return new BlobReferenceForSql(provider, objectId);
}

@Override
public long readClob() throws IOException {
public ClobReference readClob() throws IOException {
require(EntryType.CLOB);
clearHeaderInfo();
return readIntBody();
var provider = read8();
var objectId = read8();
return new ClobReferenceForSql(provider, objectId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

import javax.annotation.Nonnull;

import com.tsurugidb.tsubakuro.sql.BlobReference;
import com.tsurugidb.tsubakuro.sql.ClobReference;

/**
* Retrieves SQL values.
*/
Expand Down Expand Up @@ -245,7 +248,7 @@ default boolean[] readBit() throws IOException, InterruptedException {
* @throws IllegalStateException if the next entry is inconsistent value type
* @see #peekType()
*/
default long readBlob() throws IOException, InterruptedException {
default BlobReference readBlob() throws IOException, InterruptedException {
throw new UnsupportedOperationException();
}

Expand All @@ -257,7 +260,7 @@ default long readBlob() throws IOException, InterruptedException {
* @throws IllegalStateException if the next entry is inconsistent value type
* @see #peekType()
*/
default long readClob() throws IOException, InterruptedException {
default ClobReference readClob() throws IOException, InterruptedException {
throw new UnsupportedOperationException();
}

Expand Down

0 comments on commit 6b40f7e

Please sign in to comment.