All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickzetta.platform.client.api.ArrowFailureMessage Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.platform.client.api;

import com.clickzetta.platform.arrow.ArrowTable;
import cz.proto.ingestion.v2.IngestionV2;

import java.util.*;
import java.util.stream.Collectors;

public class ArrowFailureMessage extends ArrowSuccessMessage {

  private final ArrowTable table;

  public ArrowFailureMessage(
      String sessionId,
      ArrowTable table,
      IngestionV2.MutateRequest request,
      IngestionV2.MutateResponse response) {
    super(sessionId, request, response);
    this.table = table;
  }

  @Override
  public int getErrorRowsCounts() {
    if (response.getRowStatusListCount() > 0) {
      return (int) response.getRowStatusListList().stream()
          .filter(mutateRowStatus -> mutateRowStatus.getCode() != IngestionV2.Code.SUCCESS).count();
    }
    return 0;
  }

  @Override
  public List getErrorRows() {
    if (response.getRowStatusListCount() > 0) {
      List errorRowStatus = response.getRowStatusListList()
          .stream().filter(mutateRowStatus -> mutateRowStatus.getCode() != IngestionV2.Code.SUCCESS)
          .sorted(Comparator.comparingInt(IngestionV2.MutateRowStatus::getRowIndex))
          .collect(Collectors.toList());
      return decodeArrowRow(request, errorRowStatus);
    }
    return null;
  }

  private List decodeArrowRow(IngestionV2.MutateRequest request, List errorRowStatus) {
    return new ArrayList<>();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy