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

The following examples show how to use org.apache.avro.io.Encoder#writeLong() . 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: PigAvroDatumWriter.java    From Cubert with Apache License 2.0 5 votes vote down vote up
/**
 * Write long. Users can cast integer into long.
 * 
 */
protected void writeLong(Object datum, Encoder out) throws IOException {
    long num;
    if (datum instanceof Integer) {
        num = ((Integer) datum).longValue();
    } else if (datum instanceof Long) {
        num = (Long) datum;
    } else
        throw new IOException("Cannot convert to long:" + datum.getClass());

    out.writeLong(num);
}
 
Example 2
Source File: PigAvroDatumWriter.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * Write long. Users can cast integer into long.
 * 
 */
protected void writeLong(Object datum, Encoder out) throws IOException {
    long num;
    if (datum instanceof Integer) {
        num = ((Integer) datum).longValue();
    } else if (datum instanceof Long) {
        num = (Long) datum;
    } else
        throw new IOException("Cannot convert to long:" + datum.getClass());

    out.writeLong(num);
}
 
Example 3
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(LocalTime time, Encoder encoder) throws IOException {
  encoder.writeLong(time.toNanoOfDay() / 1000);
}
 
Example 4
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(LocalDateTime timestamp, Encoder encoder) throws IOException {
  encoder.writeLong(ChronoUnit.MICROS.between(EPOCH, timestamp.atOffset(ZoneOffset.UTC)));
}
 
Example 5
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(OffsetDateTime timestamptz, Encoder encoder) throws IOException {
  encoder.writeLong(ChronoUnit.MICROS.between(EPOCH, timestamptz));
}
 
Example 6
Source File: ValueWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Long l, Encoder encoder) throws IOException {
  encoder.writeLong(l);
}
 
Example 7
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(LocalTime time, Encoder encoder) throws IOException {
  encoder.writeLong(time.toNanoOfDay() / 1000);
}
 
Example 8
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(LocalDateTime timestamp, Encoder encoder) throws IOException {
  encoder.writeLong(ChronoUnit.MICROS.between(EPOCH, timestamp.atOffset(ZoneOffset.UTC)));
}
 
Example 9
Source File: GenericWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(OffsetDateTime timestamptz, Encoder encoder) throws IOException {
  encoder.writeLong(ChronoUnit.MICROS.between(EPOCH, timestamptz));
}
 
Example 10
Source File: ValueWriters.java    From iceberg with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Long l, Encoder encoder) throws IOException {
  encoder.writeLong(l);
}