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

com.clickzetta.platform.arrow.writer.StructWriter Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.platform.arrow.writer;

import com.clickzetta.platform.catalyst.data.DataGetters;
import com.clickzetta.platform.catalyst.data.InternalRow;
import org.apache.arrow.vector.complex.StructVector;

import java.util.List;

public class StructWriter extends ArrowFieldWriter {

  private StructVector structVector;
  private List children;

  public StructWriter(StructVector structVector, List children) {
    super(structVector);
    this.structVector = structVector;
    this.children = children;
  }

  @Override
  public void setNull() {
    int i = 0;
    while (i < children.size()) {
      children.get(i).setNull();
      children.get(i).count += 1;
      i += 1;
    }
    structVector.setNull(count);
  }

  @Override
  void setDefaultValue() {
    int i = 0;
    structVector.setIndexDefined(count);
    while (i < children.size()) {
      children.get(i).setDefaultValue();
      children.get(i).count += 1;
      i += 1;
    }
  }

  @Override
  void setValue(DataGetters row, int ordinal) {
    InternalRow internalRow = row.getRow(ordinal, children.size());
    int i = 0;
    structVector.setIndexDefined(count);
    while (i < internalRow.getFieldCount()) {
      children.get(i).write(internalRow, i, true);
      i += 1;
    }
  }

  @Override
  public void finish() {
    super.finish();
    children.forEach(ArrowFieldWriter::finish);
  }

  @Override
  public void reset() {
    super.reset();
    children.forEach(ArrowFieldWriter::reset);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy