/**
  * It writes the primitive value to the Parquet RecordConsumer.
  *
  * @param value The writable object that contains the primitive value.
  */
 private void writePrimitive(final Writable value) {
   if (value == null) {
     return;
   }
   if (value instanceof DoubleWritable) {
     recordConsumer.addDouble(((DoubleWritable) value).get());
   } else if (value instanceof BooleanWritable) {
     recordConsumer.addBoolean(((BooleanWritable) value).get());
   } else if (value instanceof FloatWritable) {
     recordConsumer.addFloat(((FloatWritable) value).get());
   } else if (value instanceof IntWritable) {
     recordConsumer.addInteger(((IntWritable) value).get());
   } else if (value instanceof LongWritable) {
     recordConsumer.addLong(((LongWritable) value).get());
   } else if (value instanceof ShortWritable) {
     recordConsumer.addInteger(((ShortWritable) value).get());
   } else if (value instanceof ByteWritable) {
     recordConsumer.addInteger(((ByteWritable) value).get());
   } else if (value instanceof HiveDecimalWritable) {
     throw new UnsupportedOperationException("HiveDecimalWritable writing not implemented");
   } else if (value instanceof BytesWritable) {
     recordConsumer.addBinary((Binary.fromByteArray(((BytesWritable) value).getBytes())));
   } else if (value instanceof TimestampWritable) {
     Timestamp ts = ((TimestampWritable) value).getTimestamp();
     NanoTime nt = NanoTimeUtils.getNanoTime(ts);
     nt.writeValue(recordConsumer);
   } else {
     throw new IllegalArgumentException("Unknown value type: " + value + " " + value.getClass());
   }
 }
Beispiel #2
0
 @Override
 public void writeValue(RecordConsumer recordConsumer) {
   recordConsumer.addFloat(value);
 }