Record Class UpsertResultado

java.lang.Object
java.lang.Record
br.com.xadm.ingestao.UpsertResultado
Record Components:
enviadas - linhas enviadas ao banco
inseridas - linhas efetivamente inseridas
atualizadas - linhas efetivamente atualizadas (0 se a engine não distingue)
removidas - linhas removidas por delete seletivo (0 se não se aplica)

public record UpsertResultado(int enviadas, int inseridas, int atualizadas, int removidas) extends Record
Métrica de um upsert em lote — superconjunto que serve as duas técnicas: executeBatch (onpetro, que só conhece enviadas/efetivas) e COPY+CTE RETURNING xmax=0 (vantroba, que separa inseridas/atualizadas/removidas).

Engines que não distinguem insert de update reportam inseridas = efetivas, atualizadas = 0, removidas = 0. Engines finos preenchem os quatro campos.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final UpsertResultado
    Resultado vazio (nenhuma linha enviada).
  • Constructor Summary

    Constructors
    Constructor
    Description
    UpsertResultado(int enviadas, int inseridas, int atualizadas, int removidas)
    Creates an instance of a UpsertResultado record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the atualizadas record component.
    coarse(int enviadas, int efetivas)
    Fábrica para engines que só sabem "quantas linhas mudaram" (executeBatch).
    int
    Returns the value of the enviadas record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns as linhas enviadas que não resultaram em alteração (idempotentes).
    int
    Returns the value of the inseridas record component.
    Soma duas métricas (acumular por tabela num processamento).
    int
    Returns the value of the removidas record component.
    final String
    Returns a string representation of this record class.
    int
    Returns o total de linhas efetivamente alteradas (inseridas + atualizadas + removidas).

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • VAZIO

      public static final UpsertResultado VAZIO
      Resultado vazio (nenhuma linha enviada).
  • Constructor Details

    • UpsertResultado

      public UpsertResultado(int enviadas, int inseridas, int atualizadas, int removidas)
      Creates an instance of a UpsertResultado record class.
      Parameters:
      enviadas - the value for the enviadas record component
      inseridas - the value for the inseridas record component
      atualizadas - the value for the atualizadas record component
      removidas - the value for the removidas record component
  • Method Details

    • coarse

      public static UpsertResultado coarse(int enviadas, int efetivas)
      Fábrica para engines que só sabem "quantas linhas mudaram" (executeBatch).
      Parameters:
      enviadas - linhas enviadas
      efetivas - linhas afetadas (viram inseridas; sem separar update)
      Returns:
      métrica coarse-grained
    • totalAlteracoes

      public int totalAlteracoes()
      Returns o total de linhas efetivamente alteradas (inseridas + atualizadas + removidas).
      Returns:
      o total de linhas efetivamente alteradas (inseridas + atualizadas + removidas)
    • inalteradas

      public int inalteradas()
      Returns as linhas enviadas que não resultaram em alteração (idempotentes).
      Returns:
      as linhas enviadas que não resultaram em alteração (idempotentes)
    • mais

      public UpsertResultado mais(UpsertResultado outra)
      Soma duas métricas (acumular por tabela num processamento).
      Parameters:
      outra - métrica a somar
      Returns:
      nova métrica com os campos somados
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • enviadas

      public int enviadas()
      Returns the value of the enviadas record component.
      Returns:
      the value of the enviadas record component
    • inseridas

      public int inseridas()
      Returns the value of the inseridas record component.
      Returns:
      the value of the inseridas record component
    • atualizadas

      public int atualizadas()
      Returns the value of the atualizadas record component.
      Returns:
      the value of the atualizadas record component
    • removidas

      public int removidas()
      Returns the value of the removidas record component.
      Returns:
      the value of the removidas record component