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

com.clickzetta.platform.arrow.writer.ArrayWriter 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.InternalArray;
import org.apache.arrow.vector.complex.ListVector;

public class ArrayWriter extends ArrowFieldWriter {

  private ListVector listVector;
  private ArrowFieldWriter elementWriter;

  public ArrayWriter(ListVector listVector, ArrowFieldWriter elementWriter) {
    super(listVector);
    this.listVector = listVector;
    this.elementWriter = elementWriter;
  }

  @Override
  public void setNull() {
    listVector.setNull(count);
  }

  @Override
  void setDefaultValue() {
    listVector.startNewValue(count);
    listVector.endValue(count, 0);
  }

  @Override
  void setValue(DataGetters row, int ordinal) {
    InternalArray array = row.getArray(ordinal);
    int length = array.size();
    listVector.startNewValue(count);
    int i = 0;
    while (i < length) {
      elementWriter.write(array, i, true);
      i += 1;
    }
    listVector.endValue(count, length);
  }

  @Override
  public void finish() {
    super.finish();
    elementWriter.finish();
  }

  @Override
  public void reset() {
    super.reset();
    elementWriter.reset();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy