use of org.apache.thrift.protocol.TMap in project voldemort by voldemort.
the class MockMessage method read.
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true) {
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch(field.id) {
case // NAME
1:
if (field.type == TType.STRING) {
this.name = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case // MAPPINGS
2:
if (field.type == TType.MAP) {
{
TMap _map0 = iprot.readMapBegin();
this.mappings = new HashMap<Long, Map<String, Integer>>(2 * _map0.size);
for (int _i1 = 0; _i1 < _map0.size; ++_i1) {
long _key2;
Map<String, Integer> _val3;
_key2 = iprot.readI64();
{
TMap _map4 = iprot.readMapBegin();
_val3 = new HashMap<String, Integer>(2 * _map4.size);
for (int _i5 = 0; _i5 < _map4.size; ++_i5) {
String _key6;
int _val7;
_key6 = iprot.readString();
_val7 = iprot.readI32();
_val3.put(_key6, _val7);
}
iprot.readMapEnd();
}
this.mappings.put(_key2, _val3);
}
iprot.readMapEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case // INT_LIST
3:
if (field.type == TType.LIST) {
{
TList _list8 = iprot.readListBegin();
this.intList = new ArrayList<Short>(_list8.size);
for (int _i9 = 0; _i9 < _list8.size; ++_i9) {
short _elem10;
_elem10 = iprot.readI16();
this.intList.add(_elem10);
}
iprot.readListEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case // STR_SET
4:
if (field.type == TType.SET) {
{
TSet _set11 = iprot.readSetBegin();
this.strSet = new HashSet<String>(2 * _set11.size);
for (int _i12 = 0; _i12 < _set11.size; ++_i12) {
String _elem13;
_elem13 = iprot.readString();
this.strSet.add(_elem13);
}
iprot.readSetEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked
// in the validate method
validate();
}
use of org.apache.thrift.protocol.TMap in project voldemort by voldemort.
the class MockMessage method write.
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();
}
use of org.apache.thrift.protocol.TMap in project hive by apache.
the class TCTLSeparatedProtocol method readMapBegin.
@Override
public TMap readMapBegin() throws TException {
assert (!inner);
TMap map = new TMap();
if (columns[index] == null || columns[index].equals(nullString)) {
index++;
if (returnNulls) {
return null;
}
} else if (columns[index].isEmpty()) {
index++;
} else {
fields = mapPattern.split(columns[index++]);
map = new TMap(ORDERED_TYPE, ORDERED_TYPE, fields.length / 2);
}
innerIndex = 0;
inner = true;
isMap = true;
return map;
}
use of org.apache.thrift.protocol.TMap in project hive by apache.
the class DynamicSerDeTypeMap method deserialize.
@Override
public Map<Object, Object> deserialize(Object reuse, TProtocol iprot) throws SerDeException, TException, IllegalAccessException {
HashMap<Object, Object> deserializeReuse;
if (reuse != null) {
deserializeReuse = (HashMap<Object, Object>) reuse;
deserializeReuse.clear();
} else {
deserializeReuse = new HashMap<Object, Object>();
}
TMap themap = iprot.readMapBegin();
if (themap == null) {
return null;
}
// themap might be reused by the Protocol.
int mapSize = themap.size;
for (int i = 0; i < mapSize; i++) {
Object key = getKeyType().deserialize(null, iprot);
Object value = getValueType().deserialize(null, iprot);
deserializeReuse.put(key, value);
}
// in theory, the below call isn't needed in non thrift_mode, but let's not
// get too crazy
iprot.readMapEnd();
return deserializeReuse;
}
use of org.apache.thrift.protocol.TMap in project commons by twitter.
the class TTextProtocol method readMapBegin.
@Override
public TMap readMapBegin() throws TException {
getCurrentContext().read();
JsonElement curElem = getCurrentContext().getCurrentChild();
if (getCurrentContext().isMapKey()) {
curElem = new JsonStreamParser(curElem.getAsString()).next();
}
if (!curElem.isJsonObject()) {
throw new TException("Expected JSON Object!");
}
pushContext(new MapContext(curElem.getAsJsonObject()));
return new TMap(UNUSED_TYPE, UNUSED_TYPE, curElem.getAsJsonObject().entrySet().size());
}
Aggregations