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

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

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

Encoder.writeDouble介绍

[英]Write a double.
[中]写一个双精度。

代码示例

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

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

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

@Override
public void writeDouble(double d) throws IOException {
 parser.advance(Symbol.DOUBLE);
 out.writeDouble(d);
}

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

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

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

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

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

@Override
public void writeDouble(double d) throws IOException {
 parser.advance(Symbol.DOUBLE);
 out.writeDouble(d);
}

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

@Override
public void writeDouble(double d) throws IOException { e.writeDouble(d); }
@Override

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

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

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

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

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

@Override
void writeInternal(Encoder e) throws IOException {
 for (int i = 0; i < sourceData.length; i++) {
  Rec r = sourceData[i];
  e.writeDouble(r.f1);
  e.writeDouble(r.f2);
  e.writeDouble(r.f3);
  e.writeInt(r.f4);
  e.writeInt(r.f5);
  e.writeInt(r.f6);
 }
}
@Override

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

@Override
void writeInternal(Encoder e) throws IOException {
 for (int i = 0; i < sourceData.length; i++) {
  GenericRecord rec = sourceData[i];
  GenericRecord inner;
  inner = (GenericRecord)rec.get(0);
  e.writeDouble((Double)inner.get(0));
  inner = (GenericRecord)rec.get(1);
  e.writeDouble((Double)inner.get(0));
  inner = (GenericRecord)rec.get(2);
  e.writeDouble((Double)inner.get(0));
  e.writeInt((Integer)rec.get(3));
  e.writeInt((Integer)rec.get(4));
  e.writeInt((Integer)rec.get(5));
 }
}
@Override

代码示例来源: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 double: "+n);
 e.writeDouble(n.doubleValue());
 break;
case BOOLEAN:

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

case VALUE_NUMBER_FLOAT:
 out.writeIndex(JsonType.DOUBLE.ordinal());
 out.writeDouble(node.doubleValue());
 break;
case VALUE_STRING:

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

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

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

static void generateComplexData(Encoder e) throws IOException {
 e.writeArrayStart();
 e.setItemCount(1);
 e.startItem();
 e.writeInt(1);
 e.writeArrayEnd();
 e.writeMapStart();
 e.setItemCount(2);
 e.startItem();
 e.writeString("foo");
 e.writeInt(-1);
 e.writeDouble(33.3);
 e.startItem();
 e.writeString("bar");
 e.writeInt(1);
 e.writeDouble(-33.3);
 e.writeMapEnd();
 e.flush();
}

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

case VALUE_NUMBER_FLOAT:
 out.writeIndex(JsonType.DOUBLE.ordinal());
 out.writeDouble(node.getDoubleValue());
 break;
case VALUE_STRING:

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

e.writeBytes(bb);
e.writeBytes(bb);
e.writeDouble(0.0);
e.writeDouble(-0.0);
e.writeDouble(Double.NaN);
e.writeDouble(r.nextDouble());
e.writeDouble(Double.NEGATIVE_INFINITY);
e.writeEnum(65);
e.writeFixed(bytes);

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

case 'D':
 double d = (Double) values[p++];
 vw.writeDouble(d);
 break;
case 'S':

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

@Override
public void writeDouble(double d) throws IOException {
 parser.advance(Symbol.DOUBLE);
 out.writeDouble(d);
}

相关文章