Java Code Examples for org.apache.thrift.protocol.TProtocol#readMapEnd()

The following examples show how to use org.apache.thrift.protocol.TProtocol#readMapEnd() . 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: BufferedProtocolReadToWrite.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
private boolean readOneMap(TProtocol in, List<Action> buffer, MapType mapType) throws TException {
  final TMap map = in.readMapBegin();
  buffer.add(new Action() {
    @Override
    public void write(TProtocol out) throws TException {
      out.writeMapBegin(map);
    }

    @Override
    public String toDebugString() {
      return "<k=" + map.keyType + ", v=" + map.valueType + ", s=" + map.size + ">[";
    }
  });
  boolean hasFieldIgnored = false;
  for (int i = 0; i < map.size; i++) {
    hasFieldIgnored |= readOneValue(in, map.keyType, buffer, mapType.getKey().getType());
    hasFieldIgnored |= readOneValue(in, map.valueType, buffer, mapType.getValue().getType());
  }
  in.readMapEnd();
  buffer.add(MAP_END);
  return hasFieldIgnored;
}
 
Example 2
Source File: MapTypeAdapterFactory.java    From Firefly with Apache License 2.0 5 votes vote down vote up
@Override
public Map<?, ?> read(TProtocol protocol) throws TException {
    TMap tmap = protocol.readMapBegin();
    HashMap hashMap = new HashMap(tmap.size);
    for (int i = 0, n = tmap.size; i < n; i++) {
        Object key = keyTypeAdapter.read(protocol);
        Object value = valueTypeAdapter.read(protocol);
        hashMap.put(key, value);
    }
    protocol.readMapEnd();
    return hashMap;
}
 
Example 3
Source File: ProtocolReadToWrite.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
private void readOneMap(TProtocol in, TProtocol out) throws TException {
  final TMap map = in.readMapBegin();
  out.writeMapBegin(map);
  for (int i = 0; i < map.size; i++) {
    readOneValue(in, out, map.keyType);
    readOneValue(in, out, map.valueType);
  }
  in.readMapEnd();
  out.writeMapEnd();
}
 
Example 4
Source File: TypedConsumer.java    From parquet-format with Apache License 2.0 4 votes vote down vote up
@Override
final void read(TProtocol protocol, EventBasedThriftReader reader)
    throws TException {
  this.consumeMap(protocol, reader , protocol.readMapBegin());
  protocol.readMapEnd();
}
 
Example 5
Source File: TypedConsumer.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
final void read(TProtocol protocol, EventBasedThriftReader reader)
    throws TException {
  this.consumeMap(protocol, reader , protocol.readMapBegin());
  protocol.readMapEnd();
}