use of org.projectnessie.model.ImmutableDeltaLakeTable.Builder in project nessie by projectnessie.
the class TableCommitMetaStoreWorker method toStoreGlobalState.
@Override
public ByteString toStoreGlobalState(Content content) {
ObjectTypes.Content.Builder builder = ObjectTypes.Content.newBuilder().setId(content.getId());
if (content instanceof IcebergTable) {
IcebergTable state = (IcebergTable) content;
ObjectTypes.IcebergMetadataPointer.Builder stateBuilder = ObjectTypes.IcebergMetadataPointer.newBuilder().setMetadataLocation(state.getMetadataLocation());
builder.setIcebergMetadataPointer(stateBuilder);
} else if (content instanceof IcebergView) {
IcebergView state = (IcebergView) content;
ObjectTypes.IcebergMetadataPointer.Builder stateBuilder = ObjectTypes.IcebergMetadataPointer.newBuilder().setMetadataLocation(state.getMetadataLocation());
builder.setIcebergMetadataPointer(stateBuilder);
} else {
throw new IllegalArgumentException("Unknown type " + content);
}
return builder.build().toByteString();
}
use of org.projectnessie.model.ImmutableDeltaLakeTable.Builder in project nessie by projectnessie.
the class TableCommitMetaStoreWorker method valueFromStore.
@Override
public Content valueFromStore(ByteString onReferenceValue, Optional<ByteString> globalState) {
ObjectTypes.Content content = parse(onReferenceValue);
Optional<ObjectTypes.Content> globalContent = globalState.map(TableCommitMetaStoreWorker::parse);
switch(content.getObjectTypeCase()) {
case DELTA_LAKE_TABLE:
Builder builder = ImmutableDeltaLakeTable.builder().id(content.getId()).addAllMetadataLocationHistory(content.getDeltaLakeTable().getMetadataLocationHistoryList()).addAllCheckpointLocationHistory(content.getDeltaLakeTable().getCheckpointLocationHistoryList());
if (content.getDeltaLakeTable().getLastCheckpoint() != null) {
builder.lastCheckpoint(content.getDeltaLakeTable().getLastCheckpoint());
}
return builder.build();
case ICEBERG_REF_STATE:
ObjectTypes.Content global = globalContent.orElseThrow(TableCommitMetaStoreWorker::noIcebergMetadataPointer);
if (!global.hasIcebergMetadataPointer()) {
throw noIcebergMetadataPointer();
}
return ImmutableIcebergTable.builder().metadataLocation(global.getIcebergMetadataPointer().getMetadataLocation()).snapshotId(content.getIcebergRefState().getSnapshotId()).schemaId(content.getIcebergRefState().getSchemaId()).specId(content.getIcebergRefState().getSpecId()).sortOrderId(content.getIcebergRefState().getSortOrderId()).id(content.getId()).build();
case ICEBERG_VIEW_STATE:
ObjectTypes.Content globalView = globalContent.orElseThrow(TableCommitMetaStoreWorker::noIcebergMetadataPointer);
if (!globalView.hasIcebergMetadataPointer()) {
throw noIcebergMetadataPointer();
}
ObjectTypes.IcebergViewState view = content.getIcebergViewState();
return ImmutableIcebergView.builder().metadataLocation(globalView.getIcebergMetadataPointer().getMetadataLocation()).versionId(view.getVersionId()).schemaId(view.getSchemaId()).dialect(view.getDialect()).sqlText(view.getSqlText()).id(content.getId()).build();
case NAMESPACE:
ObjectTypes.Namespace namespace = content.getNamespace();
return ImmutableNamespace.builder().id(content.getId()).name(namespace.getName()).build();
case OBJECTTYPE_NOT_SET:
default:
throw new IllegalArgumentException("Unknown type " + content.getObjectTypeCase());
}
}
Aggregations