com.yandex.ydb.core.Operations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-jdbc-uberjar Show documentation
Show all versions of ydb-sdk-jdbc-uberjar Show documentation
JDBC client implementation over Table client, single jar
package com.yandex.ydb.core;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.yandex.ydb.OperationProtos.Operation;
import com.yandex.ydb.StatusCodesProtos.StatusIds;
/**
* @author Sergey Polovko
*/
public final class Operations {
private Operations() {}
public static Status status(Operation operation) {
if (operation.getStatus() == StatusIds.StatusCode.SUCCESS && operation.getIssuesCount() == 0) {
return Status.SUCCESS;
}
StatusCode code = StatusCode.fromProto(operation.getStatus());
return Status.of(code, Issue.fromPb(operation.getIssuesList()));
}
public static M unpackResult(Operation operation, Class clazz) {
try {
return operation.getResult().unpack(clazz);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException("cannot unpack result of operation: " + operation.getId(), e);
}
}
}