com.clickzetta.platform.client.api.ArrowSuccessMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickzetta-java Show documentation
Show all versions of clickzetta-java Show documentation
The java SDK for clickzetta's Lakehouse
package com.clickzetta.platform.client.api;
import com.google.common.collect.Lists;
import cz.proto.ingestion.Ingestion;
import cz.proto.ingestion.v2.IngestionV2;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class ArrowSuccessMessage implements Message {
IngestionV2.MutateRequest request;
IngestionV2.MutateResponse response;
final String sessionId;
final String schemaName;
final String tableName;
public ArrowSuccessMessage(String sessionId,
IngestionV2.MutateRequest request,
IngestionV2.MutateResponse response) {
this.sessionId = sessionId;
this.request = request;
this.response = response;
this.schemaName = request.getTableIdent().getSchemaName();
this.tableName = request.getTableIdent().getTableName();
}
@Override
public String getSessionId() {
return sessionId;
}
@Override
public long getBatchId() {
return request.getBatchId();
}
@Override
public long getTimestamp() {
return request.getWriteTimestamp();
}
@Override
public List getSchemaName() {
return Lists.newArrayList(schemaName);
}
@Override
public List getTableName() {
return Lists.newArrayList(tableName);
}
@Override
public long getTotalRowsCounts() {
return request.getDataBlock().getNumRows();
}
@Override
public List getRowStates() {
return response.getRowStatusListList()
.stream().map(mutateRowStatus -> {
Ingestion.Code code;
switch (mutateRowStatus.getCode()) {
case SUCCESS: {
code = Ingestion.Code.SUCCESS;
break;
}
case FAILED: {
code = Ingestion.Code.FAILED;
break;
}
case THROTTLED: {
code = Ingestion.Code.THROTTLED;
break;
}
default:
throw new UnsupportedOperationException();
}
return Ingestion.MutateRowStatus.newBuilder()
.setCode(code)
.setMessage(mutateRowStatus.getErrorMessage())
.setRowIndex(mutateRowStatus.getRowIndex()).build();
}).sorted(Comparator.comparingInt(Ingestion.MutateRowStatus::getRowIndex)).collect(Collectors.toList());
}
@Override
public int getErrorRowsCounts() {
return 0;
}
@Override
public List getErrorRows() {
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy