本文整理了Java中org.apache.avro.io.Encoder.writeMapStart()
方法的一些代码示例,展示了Encoder.writeMapStart()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encoder.writeMapStart()
方法的具体详情如下:
包路径:org.apache.avro.io.Encoder
类名称:Encoder
方法名:writeMapStart
[英]Call this to start a new map. See #writeArrayStart for details on usage. As an example of usage, let's say you want to write a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:
out.writeMapStart();
out.setItemCount(list.size());
for (Map.Entry entry : map.entrySet()) {
out.startItem();
out.writeString(entry.getKey());
out.writeLong(entry.getValue().longField);
out.writeBoolean(entry.getValue().boolField);
}
out.writeMapEnd();
[中]调用此命令以启动新地图。有关用法的详细信息,请参见#writeArrayStart。作为一个使用示例,假设您想要编写一个记录映射,该记录由一个长字段和一个布尔字段组成。您的代码如下所示:
out.writeMapStart();
out.setItemCount(list.size());
for (Map.Entry entry : map.entrySet()) {
out.startItem();
out.writeString(entry.getKey());
out.writeLong(entry.getValue().longField);
out.writeBoolean(entry.getValue().boolField);
}
out.writeMapEnd();
代码示例来源:origin: apache/avro
@Override
public void writeMapStart() throws IOException {
e.writeMapStart();
sizeWrittenSignal.countDown();
try {
eltAddedSignal.await();
} catch (InterruptedException e) {
// ignore
}
}
代码示例来源:origin: org.apache.avro/avro
@Override
public void writeMapStart() throws IOException {
push();
parser.advance(Symbol.MAP_START);
out.writeMapStart();
}
代码示例来源:origin: apache/avro
@Override
public void writeMapStart() throws IOException {
push();
parser.advance(Symbol.MAP_START);
out.writeMapStart();
}
代码示例来源:origin: apache/avro
/** Called to write a map. May be overridden for alternate map
* representations.*/
protected void writeMap(Schema schema, Object datum, Encoder out)
throws IOException {
Schema value = schema.getValueType();
int size = getMapSize(datum);
int actualSize = 0;
out.writeMapStart();
out.setItemCount(size);
for (Map.Entry<Object,Object> entry : getMapEntries(datum)) {
out.startItem();
writeString(entry.getKey().toString(), out);
write(value, entry.getValue(), out);
actualSize++;
}
out.writeMapEnd();
if (actualSize != size) {
throw new ConcurrentModificationException("Size of map written was " +
size + ", but number of entries written was " + actualSize + ". ");
}
}
代码示例来源:origin: org.apache.avro/avro
/** Called to write a map. May be overridden for alternate map
* representations.*/
protected void writeMap(Schema schema, Object datum, Encoder out)
throws IOException {
Schema value = schema.getValueType();
int size = getMapSize(datum);
int actualSize = 0;
out.writeMapStart();
out.setItemCount(size);
for (Map.Entry<Object,Object> entry : getMapEntries(datum)) {
out.startItem();
writeString(entry.getKey().toString(), out);
write(value, entry.getValue(), out);
actualSize++;
}
out.writeMapEnd();
if (actualSize != size) {
throw new ConcurrentModificationException("Size of map written was " +
size + ", but number of entries written was " + actualSize + ". ");
}
}
代码示例来源:origin: apache/avro
out.writeIndex(1);
long size0 = this.meta.size();
out.writeMapStart();
out.setItemCount(size0);
long actualSize0 = 0;
代码示例来源:origin: apache/avro
out.writeMapStart();
out.setItemCount(size0);
long actualSize0 = 0;
out.writeMapStart();
out.setItemCount(size1);
long actualSize1 = 0;
代码示例来源:origin: apache/avro
out.writeIndex(1);
long size0 = this.meta.size();
out.writeMapStart();
out.setItemCount(size0);
long actualSize0 = 0;
代码示例来源:origin: apache/avro
break;
case MAP:
e.writeMapStart();
e.setItemCount(n.size());
Schema v = s.getValueType();
代码示例来源:origin: apache/avro
case START_OBJECT:
out.writeIndex(JsonType.OBJECT.ordinal());
out.writeMapStart();
out.setItemCount(node.size());
Iterator<String> i = node.fieldNames();
代码示例来源:origin: apache/avro
counts[stackTop]++;
cos.writeMapStart();
isArray[++stackTop] = false;
counts[stackTop] = 0;
代码示例来源:origin: org.apache.avro/avro
break;
case MAP:
e.writeMapStart();
e.setItemCount(n.size());
Schema v = s.getValueType();
代码示例来源:origin: org.apache.avro/avro
case START_OBJECT:
out.writeIndex(JsonType.OBJECT.ordinal());
out.writeMapStart();
out.setItemCount(node.size());
Iterator<String> i = node.getFieldNames();
代码示例来源: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
out.writeIndex(1);
long size0 = this.nullableMap.size();
out.writeMapStart();
out.setItemCount(size0);
long actualSize0 = 0;
代码示例来源: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: apache/avro
break;
case '{':
vw.writeMapStart();
break;
case '}':
代码示例来源:origin: cdapio/cdap
private void startMap() throws IOException {
encoder.writeMapStart();
encoder.setItemCount(numOfRequests);
mapStarted = true;
}
代码示例来源:origin: org.apache.hadoop/avro
@Override
public void writeMapStart() throws IOException {
push();
parser.advance(Symbol.MAP_START);
out.writeMapStart();
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
@Override
public void writeMapStart() throws IOException {
push();
parser.advance(Symbol.MAP_START);
out.writeMapStart();
}
内容来源于网络,如有侵权,请联系作者删除!