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

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

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

Encoder.writeIndex介绍

[英]Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this:

out.writeIndex(1); 
out.writeLong(record.longField); 
out.writeBoolean(record.boolField);

[中]调用此方法以写入联合的标记。作为一个使用示例,假设您想要编写一个联合,其第二个分支是一个由长字段和布尔字段组成的记录。您的代码如下所示:

out.writeIndex(1); 
out.writeLong(record.longField); 
out.writeBoolean(record.boolField);

代码示例

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

@Override
 public void writeIndex(int unionIndex) throws IOException { e.writeIndex(unionIndex); }
};

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

out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeString(this.serverProtocol);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeFixed(this.serverHash.bytes(), 0, 16);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 long size0 = this.meta.size();
 out.writeMapStart();

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

out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeString(this.clientProtocol);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 long size0 = this.meta.size();
 out.writeMapStart();

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 out.writeString(this.name);
 if (this.value == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeString(this.value);
 }
}

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 if (this.id == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeString(this.id);
 }
 out.writeString(this.useragent);
}

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 if (this.this$ == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeString(this.this$);
 }
 out.writeString(this.String);
}

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 if (this.kind == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeEnum(this.kind.ordinal());
 }
 if (this.value == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeString(this.value);
 }
}

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

@Override
public void writeIndex(int unionIndex) throws IOException {
 parser.advance(Symbol.UNION);
 Symbol.Alternative top = (Symbol.Alternative) parser.popSymbol();
 parser.pushSymbol(top.getSymbol(unionIndex));
 out.writeIndex(unionIndex);
}

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

@Override
public void writeIndex(int unionIndex) throws IOException {
 parser.advance(Symbol.UNION);
 Symbol.Alternative top = (Symbol.Alternative) parser.popSymbol();
 parser.pushSymbol(top.getSymbol(unionIndex));
 out.writeIndex(unionIndex);
}

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 if (this.kind == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeEnum(this.kind.ordinal());
 }
 if (this.value == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  out.writeString(this.value);
 }
}

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

@Override protected void customEncode(org.apache.avro.io.Encoder out)
 throws java.io.IOException
{
 out.writeLong(this.timestamp);
 if (this.connection == null) {
  out.writeIndex(0);
  out.writeNull();
 } else {
  out.writeIndex(1);
  this.connection.customEncode(out);
 }
 this.httpRequest.customEncode(out);
}

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

switch(node.asToken()) {
case VALUE_NUMBER_INT:
 out.writeIndex(JsonType.LONG.ordinal());
 out.writeLong(node.longValue());
 break;
case VALUE_NUMBER_FLOAT:
 out.writeIndex(JsonType.DOUBLE.ordinal());
 out.writeDouble(node.doubleValue());
 break;
case VALUE_STRING:
 out.writeIndex(JsonType.STRING.ordinal());
 out.writeString(node.textValue());
 break;
case VALUE_TRUE:
 out.writeIndex(JsonType.BOOLEAN.ordinal());
 out.writeBoolean(true);
 break;
case VALUE_FALSE:
 out.writeIndex(JsonType.BOOLEAN.ordinal());
 out.writeBoolean(false);
 break;
case VALUE_NULL:
 out.writeIndex(JsonType.NULL.ordinal());
 out.writeNull();
 break;
case START_ARRAY:
 out.writeIndex(JsonType.ARRAY.ordinal());
 out.writeArrayStart();
 out.setItemCount(node.size());

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

switch(node.asToken()) {
case VALUE_NUMBER_INT:
 out.writeIndex(JsonType.LONG.ordinal());
 out.writeLong(node.getLongValue());
 break;
case VALUE_NUMBER_FLOAT:
 out.writeIndex(JsonType.DOUBLE.ordinal());
 out.writeDouble(node.getDoubleValue());
 break;
case VALUE_STRING:
 out.writeIndex(JsonType.STRING.ordinal());
 out.writeString(node.getTextValue());
 break;
case VALUE_TRUE:
 out.writeIndex(JsonType.BOOLEAN.ordinal());
 out.writeBoolean(true);
 break;
case VALUE_FALSE:
 out.writeIndex(JsonType.BOOLEAN.ordinal());
 out.writeBoolean(false);
 break;
case VALUE_NULL:
 out.writeIndex(JsonType.NULL.ordinal());
 out.writeNull();
 break;
case START_ARRAY:
 out.writeIndex(JsonType.ARRAY.ordinal());
 out.writeArrayStart();
 out.setItemCount(node.size());

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

out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeString(this.nullableString);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeLong(this.nullableLong);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeInt(this.nullableInt);
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 long size0 = this.nullableMap.size();
 out.writeMapStart();
 out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);

代码示例来源: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

out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeEnum(this.typeEnum.ordinal());

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

out.writeIndex(0);
 out.writeNull();
} else {
 out.writeIndex(1);
 out.writeEnum(this.typeEnum.ordinal());

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

e.writeFloat(Float.POSITIVE_INFINITY);
e.writeFloat(Float.MIN_NORMAL);
e.writeIndex(-2);
e.writeInt(0);
e.writeInt(-1);

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

case 'U':
  vw.writeIndex(extractInt(cs));
  break;

相关文章