Examples of TMap


Examples of com.facebook.presto.hive.shaded.org.apache.thrift.protocol.TMap

  }

  @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;
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.thrift.protocol.TMap

      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;
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.thrift.protocol.TMap

    MapObjectInspector moi = (MapObjectInspector) oi;
    ObjectInspector koi = moi.getMapKeyObjectInspector();
    ObjectInspector voi = moi.getMapValueObjectInspector();

    Map<?, ?> map = moi.getMap(o);
    serializeMap = new TMap(keyType.getType(), valueType.getType(), map.size());
    oprot.writeMapBegin(serializeMap);

    for (Object element : map.entrySet()) {
      Map.Entry it = (Map.Entry) element;
      Object key = it.getKey();
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.apache.thrift.protocol.TMap

   * calling this method again.
   */
  @Override
  public TMap readMapBegin() throws TException {
    stackLevel++;
    tmap = new TMap(ORDERED_TYPE, ORDERED_TYPE, readI32());
    if (tmap.size == 0 && lastPrimitiveWasNull()) {
      return null;
    }
    return tmap;
  }
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

                    }
                    break;
                case 2: // MAPPINGS
                    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();
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

            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());
                        }
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

    prot.readFieldBegin();
    assertTrue(prot.readString().equals(bar));
    prot.readFieldEnd();

    prot.readFieldBegin();
    TMap mapHeader = prot.readMapBegin();
    assertTrue(mapHeader.size == 2);

    assertTrue(prot.readI32() == 22);
    assertTrue(prot.readString().equals(value));
    assertTrue(prot.readI32() == 24);
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

    prot.writeFieldBegin(new TField());
    prot.writeString("hello world!");
    prot.writeFieldEnd();

    prot.writeFieldBegin(new TField());
    prot.writeMapBegin(new TMap());
    prot.writeString("key1");
    prot.writeString("val1");
    prot.writeString("key2");
    prot.writeString("val2");
    prot.writeString("key3");
    prot.writeString("val3");
    prot.writeMapEnd();
    prot.writeFieldEnd();

    prot.writeFieldBegin(new TField());
    prot.writeListBegin(new TList());
    prot.writeString("elem1");
    prot.writeString("elem2");
    prot.writeListEnd();
    prot.writeFieldEnd();

   
    prot.writeFieldBegin(new TField());
    prot.writeString("bye!");
    prot.writeFieldEnd();

    prot.writeStructEnd();
    trans.flush();
    byte b[] = new byte[3*1024];
    int len = trans.read(b,0,b.length);
    String test = new String(b, 0, len);

    String testRef = "100348.55234.22hello world!key1val1key2val2key3val3elem1elem2bye!";
    assertTrue(test.equals(testRef));

    trans = new TMemoryBuffer(1023);
    trans.write(b, 0, len);

    //
    // read back!
    //

    prot = new TCTLSeparatedProtocol(trans, 10);
    prot.initialize(new Configuration(), new Properties());
   
    // 100 is the start
    prot.readStructBegin();
    prot.readFieldBegin();
    assertTrue(prot.readI32() == 100);
    prot.readFieldEnd();

    // let's see if doubles work ok
    prot.readFieldBegin();
    TList l = prot.readListBegin();
    assertTrue(l.size == 2);
    assertTrue(prot.readDouble() == 348.55);
    assertTrue(prot.readDouble() == 234.22);
    prot.readListEnd();
    prot.readFieldEnd();

    // nice message
    prot.readFieldBegin();
    assertTrue(prot.readString().equals("hello world!"));
    prot.readFieldEnd();

    // 3 element map
    prot.readFieldBegin();
    TMap m = prot.readMapBegin();
    assertTrue(m.size == 3);
    assertTrue(prot.readString().equals("key1"));
    assertTrue(prot.readString().equals("val1"));
    assertTrue(prot.readString().equals("key2"));
    assertTrue(prot.readString().equals("val2"));
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

    prot.writeFieldBegin(new TField());
    prot.writeString(null);
    prot.writeFieldEnd();

    prot.writeFieldBegin(new TField());
    prot.writeMapBegin(new TMap());
    prot.writeString(null);
    prot.writeString(null);
    prot.writeString("key2");
    prot.writeString(null);
    prot.writeString(null);
    prot.writeString("val3");
    prot.writeMapEnd();
    prot.writeFieldEnd();

    prot.writeStructEnd();

    byte b[] = new byte[3*1024];
    int len = trans.read(b,0,b.length);
    String written = new String(b,0,len);

    String testRef = "\\N\\N100\\N\\N\\Nkey2\\N\\Nval3";

    assertTrue(testRef.equals(written));

    trans = new TMemoryBuffer(1023);
    trans.write(b, 0, len);

    prot = new TCTLSeparatedProtocol(trans, 3);
    prot.initialize(new Configuration(), new Properties());
   
    prot.readStructBegin();

    prot.readFieldBegin();
    String ret = prot.readString();
    prot.readFieldEnd();

    assertNull(ret);

    prot.readFieldBegin();
    ret = prot.readString();
    prot.readFieldEnd();
   
    assertNull(ret);

    prot.readFieldBegin();
    int ret1 = prot.readI32();
    prot.readFieldEnd();

    assertTrue(ret1 == 100);


    prot.readFieldBegin();
    ret1 = prot.readI32();
    prot.readFieldEnd();

    prot.readFieldBegin();
    TMap map =  prot.readMapBegin();

    assertTrue(map.size == 3);

    assertNull(prot.readString());
    assertNull(prot.readString());
View Full Code Here

Examples of org.apache.thrift.protocol.TMap

    prot.readFieldBegin();
    assertTrue(prot.readString().equals(bar));
    prot.readFieldEnd();

    prot.readFieldBegin();
    TMap mapHeader = prot.readMapBegin();
    assertTrue(mapHeader.size == 2);

    assertTrue(prot.readI32() == 22);
    assertTrue(prot.readString().equals(value));
    assertTrue(prot.readI32() == 24);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.