@Override public TMap readMapBegin() throws TException { getCurrentContext().read(); JsonNode curElem = getCurrentContext().getCurrentChild(); if (getCurrentContext().isMapKey()) { try { curElem = OBJECT_MAPPER.readTree(curElem.asText()); } catch (IOException e) { throw new TException("Could not parse map key, is it valid json?", e); } } if (!curElem.isObject()) { throw new TException("Expected JSON Object!"); } pushContext(new MapContext(curElem)); return new TMap(UNUSED_TYPE, UNUSED_TYPE, curElem.size()); }
@Override public Void visit(ThriftType.MapType mapType, Void v) { dummyEvents.add(new ParquetProtocol("readMapBegin()") { @Override public TMap readMapBegin() throws TException { return new TMap(); } }); dummyEvents.add(new ParquetProtocol("readMapEnd()") { @Override public void readMapEnd() throws TException { } }); return null; }
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; }
public void writeMapBegin(TMap map) throws TException { assertContextIsNotMapKey(MAP); writeContext_.write(); trans_.write(LBRACE); pushWriteContext(new MapContext()); // No metadata! }
public TMap readMapBegin() throws TException { BaseArray prevStruct = structStack.peek(); BaseArray obj = prevStruct.getArray(); structStack.push(obj); MapMetaData mm = (MapMetaData) obj.getMetaData(); return new TMap(mm.keyMetaData.type, mm.valueMetaData.type, obj.length()); }
@Override public void write(Map<?, ?> map, TProtocol protocol) throws TException { protocol.writeMapBegin(new TMap(keyTypeAdapter.getTType(), valueTypeAdapter.getTType(), map.size())); for (Map.Entry entry : map.entrySet()) { keyTypeAdapter.write(entry.getKey(), protocol); valueTypeAdapter.write(entry.getValue(), protocol); } protocol.writeMapEnd(); }
@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; }
/** * reads the map content (key values) from the underlying protocol and passes the events to the map event consumer * @param eventConsumer the consumer * @param tMap the map descriptor * @throws TException */ public void readMapContent(MapConsumer eventConsumer, TMap tMap) throws TException { for (int i = 0; i < tMap.size; i++) { eventConsumer.consumeEntry(protocol, this, tMap.keyType, tMap.valueType); } }
@Override public void end() { final int count = child.getCount(); parentEvents.add(new ParquetProtocol("readMapBegin()") { @Override public TMap readMapBegin() throws TException { return new TMap(keyType, valueType, count); } }); parentEvents.addAll(mapEvents); mapEvents.clear(); parentEvents.add(readMapEnd); }
@Override public void writeMapBegin(TMap map) throws TException { start(); recordConsumer.startGroup(); countToConsume = map.size; if (countToConsume > 0) { recordConsumer.startField(mapContent.getType().getName(), 0); currentProtocol = keyProtocol; } }
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(); }
public TMap readMapBegin() throws TException { StructContext context = (StructContext) peekContext(); if(context.fieldsStack.isEmpty()) { return EMPTY_MAP; } String fieldName = context.fieldsStack.peek(); MapContext mapContext = new MapContext(TType.VOID); BasicDBObject dbMap = (BasicDBObject) context.dbObject.get(fieldName); mapContext.setDbMap(dbMap); mapContext.thriftObject = getThriftObject(context.thriftObject, fieldName); pushContext(mapContext); return new TMap(TType.STRING, TType.STRING,dbMap.size()); }
@Override public TMap readMapBegin() throws TException { return new TMap((Byte) params.pollFirst(), (Byte) params.pollFirst(), (Integer) params.pollFirst()); }
@Override public void writeMapBegin(TMap tMap) throws TException { oprot.writeStructBegin(null); }
public void writeMapBegin(TMap map) throws TException { this.assertContextIsNotMapKey("map"); this.writeContext_.write(); this.trans_.write(LBRACE); this.pushWriteContext(new TSimpleJSONProtocol.MapContext()); }
public TMap readMapBegin() throws TException { return EMPTY_MAP; }
@Override public void writeMapBegin(TMap map) throws TException { writeJsonObjectBegin(new MapContext(null)); }
@Override public void writeMapBegin(TMap map) throws TException { if (!writeFieldBegin) { protocol.writeMapBegin(map); } }
@Override public TMap readMapBegin() throws TException { throw new TException("unsupported operation"); }
public void writeMapBegin(TMap map) throws TException { delegate.writeMapBegin(map); }
public TMap readMapBegin() throws TException { return delegate.readMapBegin(); }
public void consumeMap(TProtocol protocol, EventBasedThriftReader reader, TMap tMap) throws TException { reader.readMapContent(this, tMap); }
private String toString(TMap map) { return "<TMap keyType:" + map.keyType + " valueType:" + map.valueType + " size:" + map.size + ">"; }
/** * {@inheritDoc} * @see org.apache.parquet.thrift.ParquetProtocol#writeMapBegin(org.apache.thrift.protocol.TMap) */ @Override public void writeMapBegin(TMap map) throws TException { if (LOG.isDebugEnabled()) LOG.debug("writeMapBegin("+toString(map)+")"); currentProtocol.writeMapBegin(map); }
@Override public void writeMapBegin(TMap tMap) throws TException { }
@Override public TMap readMapBegin() throws TException { return null; }
@Override public void writeMapBegin(TMap map) throws TException { throw exception(); }
@Override public TMap readMapBegin() throws TException { throw exception(); }
public TMap readMapBegin() throws TException { LOG.debug("readMapBegin()"); return next().readMapBegin(); }
public void read(TProtocol prot, ThriftSampleData struct) throws TException { TTupleProtocol iprot = (TTupleProtocol)prot; BitSet incoming = iprot.readBitSet(7); if (incoming.get(0)) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } if (incoming.get(1)) { struct.name = iprot.readString(); struct.setNameIsSet(true); } if (incoming.get(2)) { struct.created_at = iprot.readI64(); struct.setCreated_atIsSet(true); } if (incoming.get(3)) { struct.active = iprot.readBool(); struct.setActiveIsSet(true); } int _i25; if (incoming.get(4)) { TList _list16 = new TList((byte)6, iprot.readI32()); struct.groups = new ArrayList(_list16.size); for(_i25 = 0; _i25 < _list16.size; ++_i25) { short _elem17 = iprot.readI16(); struct.groups.add(_elem17); } struct.setGroupsIsSet(true); } String _elem24; if (incoming.get(5)) { TMap _map19 = new TMap((byte)11, (byte)10, iprot.readI32()); struct.map_values = new HashMap(2 * _map19.size); for(int _i22 = 0; _i22 < _map19.size; ++_i22) { _elem24 = iprot.readString(); long _val21 = iprot.readI64(); struct.map_values.put(_elem24, _val21); } struct.setMap_valuesIsSet(true); } if (incoming.get(6)) { TSet _set23 = new TSet((byte)11, iprot.readI32()); struct.set_values = new HashSet(2 * _set23.size); for(_i25 = 0; _i25 < _set23.size; ++_i25) { _elem24 = iprot.readString(); struct.set_values.add(_elem24); } struct.setSet_valuesIsSet(true); } }
public void write(TProtocol oprot, ThriftSampleData struct) throws TException { struct.validate(); oprot.writeStructBegin(ThriftSampleData.STRUCT_DESC); if (struct.isSetId()) { oprot.writeFieldBegin(ThriftSampleData.ID_FIELD_DESC); oprot.writeI32(struct.id); oprot.writeFieldEnd(); } if (struct.name != null && struct.isSetName()) { oprot.writeFieldBegin(ThriftSampleData.NAME_FIELD_DESC); oprot.writeString(struct.name); oprot.writeFieldEnd(); } if (struct.isSetCreated_at()) { oprot.writeFieldBegin(ThriftSampleData.CREATED_AT_FIELD_DESC); oprot.writeI64(struct.created_at); oprot.writeFieldEnd(); } if (struct.isSetActive()) { oprot.writeFieldBegin(ThriftSampleData.ACTIVE_FIELD_DESC); oprot.writeBool(struct.active); oprot.writeFieldEnd(); } Iterator var3; if (struct.groups != null) { oprot.writeFieldBegin(ThriftSampleData.GROUPS_FIELD_DESC); oprot.writeListBegin(new TList((byte)6, struct.groups.size())); var3 = struct.groups.iterator(); while(var3.hasNext()) { short _iter10 = ((Short)var3.next()).shortValue(); oprot.writeI16(_iter10); } oprot.writeListEnd(); oprot.writeFieldEnd(); } if (struct.map_values != null) { oprot.writeFieldBegin(ThriftSampleData.MAP_VALUES_FIELD_DESC); oprot.writeMapBegin(new TMap((byte)11, (byte)10, struct.map_values.size())); var3 = struct.map_values.entrySet().iterator(); while(var3.hasNext()) { Entry<String, Long> _iter11 = (Entry)var3.next(); oprot.writeString((String)_iter11.getKey()); oprot.writeI64(((Long)_iter11.getValue()).longValue()); } oprot.writeMapEnd(); oprot.writeFieldEnd(); } if (struct.set_values != null) { oprot.writeFieldBegin(ThriftSampleData.SET_VALUES_FIELD_DESC); oprot.writeSetBegin(new TSet((byte)11, struct.set_values.size())); var3 = struct.set_values.iterator(); while(var3.hasNext()) { String _iter12 = (String)var3.next(); oprot.writeString(_iter12); } oprot.writeSetEnd(); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
public void writeMapBegin(TMap map) throws TException { MapContext c = new MapContext(map.keyType); pushContext(c); }
public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if(this.name != null) { oprot.writeFieldBegin(NAME_FIELD_DESC); oprot.writeString(this.name); oprot.writeFieldEnd(); } if(this.mappings != null) { oprot.writeFieldBegin(MAPPINGS_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.I64, TType.MAP, this.mappings.size())); for(Map.Entry<Long, Map<String, Integer>> _iter14: this.mappings.entrySet()) { oprot.writeI64(_iter14.getKey()); { oprot.writeMapBegin(new TMap(TType.STRING, TType.I32, _iter14.getValue() .size())); for(Map.Entry<String, Integer> _iter15: _iter14.getValue().entrySet()) { oprot.writeString(_iter15.getKey()); oprot.writeI32(_iter15.getValue()); } oprot.writeMapEnd(); } } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } if(this.intList != null) { oprot.writeFieldBegin(INT_LIST_FIELD_DESC); { oprot.writeListBegin(new TList(TType.I16, this.intList.size())); for(short _iter16: this.intList) { oprot.writeI16(_iter16); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if(this.strSet != null) { oprot.writeFieldBegin(STR_SET_FIELD_DESC); { oprot.writeSetBegin(new TSet(TType.STRING, this.strSet.size())); for(String _iter17: this.strSet) { oprot.writeString(_iter17); } oprot.writeSetEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }