org.apache.avro.io.Encoder.writeFloat()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.apache.avro.io.Encoder.writeFloat()方法的一些代码示例,展示了Encoder.writeFloat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encoder.writeFloat()方法的具体详情如下:
包路径:org.apache.avro.io.Encoder
类名称:Encoder
方法名:writeFloat

Encoder.writeFloat介绍

[英]Write a float.
[中]写一个浮点数。

代码示例

代码示例来源:origin: apache/avro

@Override
void writeInternal(Encoder e) throws IOException {
 for (int i = 0; i < sourceData.length;i+=4) {
  e.writeFloat(sourceData[i]);
  e.writeFloat(sourceData[i+1]);
  e.writeFloat(sourceData[i+2]);
  e.writeFloat(sourceData[i+3]);
 }
}

代码示例来源:origin: apache/avro

@Override
 protected void write(Object object, Encoder out) throws IOException {
  out.writeFloat(UNSAFE.getFloat(object, offset));
 }
}

代码示例来源:origin: apache/avro

@Override
public void writeFloat(float f) throws IOException {
 parser.advance(Symbol.FLOAT);
 out.writeFloat(f);
}

代码示例来源:origin: apache/avro

@Override
public void writeFloat(float f) throws IOException { e.writeFloat(f); }
@Override

代码示例来源:origin: org.apache.avro/avro

@Override
 protected void write(Object object, Encoder out) throws IOException {
  out.writeFloat(UNSAFE.getFloat(object, offset));
 }
}

代码示例来源:origin: org.apache.avro/avro

@Override
public void writeFloat(float f) throws IOException {
 parser.advance(Symbol.FLOAT);
 out.writeFloat(f);
}

代码示例来源:origin: org.apache.avro/avro

static void writeArray(float[] data, Encoder out) throws IOException {
 int size = data.length;
 out.setItemCount(size);
 for (int i = 0; i < size; i++) {
  out.startItem();
  out.writeFloat(data[i]);
 }
}

代码示例来源:origin: apache/avro

static void writeArray(float[] data, Encoder out) throws IOException {
 int size = data.length;
 out.setItemCount(size);
 for (int i = 0; i < size; i++) {
  out.startItem();
  out.writeFloat(data[i]);
 }
}

代码示例来源:origin: apache/avro

@Override
 void writeInternal(Encoder e) throws IOException {
  int items = sourceData.length/4;
  e.writeMapStart();
  e.setItemCount(items);
  Utf8 foo = new Utf8("foo");
  for (int i = 0; i < sourceData.length;i+=4) {
   e.startItem();
   e.writeString(foo);
   e.writeFloat(sourceData[i]);
   e.writeFloat(sourceData[i+1]);
   e.writeFloat(sourceData[i+2]);
   e.writeFloat(sourceData[i+3]);
  }
  e.writeMapEnd();
 }
}

代码示例来源:origin: apache/avro

@Override
 void writeInternal(Encoder e) throws IOException {
  int items = sourceData.length/4;
  e.writeArrayStart();
  e.setItemCount(1);
  e.startItem();
  e.writeArrayStart();
  e.setItemCount(items);
  for (int i = 0; i < sourceData.length;i+=4) {
   e.startItem();
   e.writeFloat(sourceData[i]);
   e.writeFloat(sourceData[i+1]);
   e.writeFloat(sourceData[i+2]);
   e.writeFloat(sourceData[i+3]);
  }
  e.writeArrayEnd();
  e.writeArrayEnd();
 }
}

代码示例来源:origin: org.apache.avro/avro

/** Called to write data.*/
protected void writeWithoutConversion(Schema schema, Object datum, Encoder out)
 throws IOException {
 try {
  switch (schema.getType()) {
  case RECORD: writeRecord(schema, datum, out); break;
  case ENUM:   writeEnum(schema, datum, out);   break;
  case ARRAY:  writeArray(schema, datum, out);  break;
  case MAP:    writeMap(schema, datum, out);    break;
  case UNION:
   int index = resolveUnion(schema, datum);
   out.writeIndex(index);
   write(schema.getTypes().get(index), datum, out);
   break;
  case FIXED:   writeFixed(schema, datum, out);   break;
  case STRING:  writeString(schema, datum, out);  break;
  case BYTES:   writeBytes(datum, out);           break;
  case INT:     out.writeInt(((Number)datum).intValue()); break;
  case LONG:    out.writeLong((Long)datum);       break;
  case FLOAT:   out.writeFloat((Float)datum);     break;
  case DOUBLE:  out.writeDouble((Double)datum);   break;
  case BOOLEAN: out.writeBoolean((Boolean)datum); break;
  case NULL:    out.writeNull();                  break;
  default: error(schema,datum);
  }
 } catch (NullPointerException e) {
  throw npe(e, " of "+schema.getFullName());
 }
}

代码示例来源:origin: apache/avro

/** Called to write data.*/
protected void writeWithoutConversion(Schema schema, Object datum, Encoder out)
 throws IOException {
 try {
  switch (schema.getType()) {
  case RECORD: writeRecord(schema, datum, out); break;
  case ENUM:   writeEnum(schema, datum, out);   break;
  case ARRAY:  writeArray(schema, datum, out);  break;
  case MAP:    writeMap(schema, datum, out);    break;
  case UNION:
   int index = resolveUnion(schema, datum);
   out.writeIndex(index);
   write(schema.getTypes().get(index), datum, out);
   break;
  case FIXED:   writeFixed(schema, datum, out);   break;
  case STRING:  writeString(schema, datum, out);  break;
  case BYTES:   writeBytes(datum, out);           break;
  case INT:     out.writeInt(((Number)datum).intValue()); break;
  case LONG:    out.writeLong((Long)datum);       break;
  case FLOAT:   out.writeFloat((Float)datum);     break;
  case DOUBLE:  out.writeDouble((Double)datum);   break;
  case BOOLEAN: out.writeBoolean((Boolean)datum); break;
  case NULL:    out.writeNull();                  break;
  default: error(schema,datum);
  }
 } catch (NullPointerException e) {
  throw npe(e, " of "+schema.getFullName());
 }
}

代码示例来源:origin: apache/avro

if (!n.isNumber())
  throw new AvroTypeException("Non-numeric default value for float: "+n);
 e.writeFloat((float) n.doubleValue());
 break;
case DOUBLE:

代码示例来源:origin: org.apache.avro/avro

if (!n.isNumber())
  throw new AvroTypeException("Non-numeric default value for float: "+n);
 e.writeFloat((float) n.getDoubleValue());
 break;
case DOUBLE:

代码示例来源:origin: apache/avro

e.writeFixed(bytes);
e.writeFixed(bytes, 7, 2);
e.writeFloat(1.0f);
e.writeFloat(r.nextFloat());
e.writeFloat(Float.POSITIVE_INFINITY);
e.writeFloat(Float.MIN_NORMAL);
e.writeIndex(-2);
e.writeInt(0);

代码示例来源:origin: apache/avro

case 'F':
 float f = (Float) values[p++];
 vw.writeFloat(f);
 break;
case 'D':

代码示例来源:origin: Netflix/iceberg

@Override
 public void write(Float f, Encoder encoder) throws IOException {
  encoder.writeFloat(f);
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro

@Override
public void writeFloat(float f) throws IOException {
 parser.advance(Symbol.FLOAT);
 out.writeFloat(f);
}

代码示例来源:origin: org.apache.hadoop/avro

@Override
public void writeFloat(float f) throws IOException {
 parser.advance(Symbol.FLOAT);
 out.writeFloat(f);
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

static void writeArray(float[] data, Encoder out) throws IOException {
 int size = data.length;
 out.setItemCount(size);
 for (int i = 0; i < size; i++) {
  out.startItem();
  out.writeFloat(data[i]);
 }
}

相关文章