Java Code Examples for org.apache.avro.io.Encoder#writeArrayEnd()

The following examples show how to use org.apache.avro.io.Encoder#writeArrayEnd() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SparkValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(ArrayData array, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = array.numElements();
  encoder.setItemCount(numElements);
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    elementWriter.write((T) array.get(i, elementType), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 2
Source File: SparkValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(MapData map, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = map.numElements();
  encoder.setItemCount(numElements);
  ArrayData keyArray = map.keyArray();
  ArrayData valueArray = map.valueArray();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    keyWriter.write((K) keyArray.get(i, keyType), encoder);
    valueWriter.write((V) valueArray.get(i, valueType), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 3
Source File: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(Collection<T> array, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = array.size();
  encoder.setItemCount(numElements);
  Iterator<T> iter = array.iterator();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    elementWriter.write(iter.next(), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 4
Source File: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(Map<K, V> map, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = map.size();
  encoder.setItemCount(numElements);
  Iterator<Map.Entry<K, V>> iter = map.entrySet().iterator();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    Map.Entry<K, V> entry = iter.next();
    keyWriter.write(entry.getKey(), encoder);
    valueWriter.write(entry.getValue(), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 5
Source File: SparkValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(ArrayData array, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = array.numElements();
  encoder.setItemCount(numElements);
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    elementWriter.write((T) array.get(i, elementType), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 6
Source File: SparkValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(MapData map, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = map.numElements();
  encoder.setItemCount(numElements);
  ArrayData keyArray = map.keyArray();
  ArrayData valueArray = map.valueArray();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    keyWriter.write((K) keyArray.get(i, keyType), encoder);
    valueWriter.write((V) valueArray.get(i, valueType), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 7
Source File: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(Collection<T> array, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = array.size();
  encoder.setItemCount(numElements);
  Iterator<T> iter = array.iterator();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    elementWriter.write(iter.next(), encoder);
  }
  encoder.writeArrayEnd();
}
 
Example 8
Source File: ValueWriters.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void write(Map<K, V> map, Encoder encoder) throws IOException {
  encoder.writeArrayStart();
  int numElements = map.size();
  encoder.setItemCount(numElements);
  Iterator<Map.Entry<K, V>> iter = map.entrySet().iterator();
  for (int i = 0; i < numElements; i += 1) {
    encoder.startItem();
    Map.Entry<K, V> entry = iter.next();
    keyWriter.write(entry.getKey(), encoder);
    valueWriter.write(entry.getValue(), encoder);
  }
  encoder.writeArrayEnd();
}