Java 类org.apache.thrift.protocol.TSet 实例源码

项目:parquet-mr    文件:DefaultEventsVisitor.java   
@Override
public Void visit(final ThriftType.SetType setType, Void v) {
  dummyEvents.add(new ParquetProtocol("readSetBegin()") {
    @Override
    public TSet readSetBegin() throws TException {
      return new TSet();
    }
  });

  dummyEvents.add(new ParquetProtocol("readSetEnd()") {
    @Override
    public void readSetEnd() throws TException {
    }
  });

  return null;
}
项目:parquet-mr    文件:BufferedProtocolReadToWrite.java   
private boolean readOneSet(TProtocol in, List<Action> buffer, SetType expectedType) throws TException {
  final TSet set = in.readSetBegin();
  buffer.add(new Action() {
    @Override
    public void write(TProtocol out) throws TException {
      out.writeSetBegin(set);
    }

    @Override
    public String toDebugString() {
      return "<e=" + set.elemType + ", s=" + set.size + ">{*";
    }
  });

  boolean hasFieldsIgnored = readCollectionElements(in, set.size, set.elemType, buffer, expectedType.getValues().getType());
  in.readSetEnd();
  buffer.add(SET_END);
  return hasFieldsIgnored;
}
项目:nettythrift    文件:TSimpleJSONProtocol.java   
public void writeSetBegin(TSet set) throws TException {
    assertContextIsNotMapKey(SET);
    writeContext_.write();
    trans_.write(LBRACKET);
    pushWriteContext(new ListContext());
    // No metadata!
}
项目:nettythrift    文件:TSimpleJSONProtocol.java   
public TSet readSetBegin() throws TException {
    BaseArray prevStruct = structStack.peek();
    BaseArray obj = prevStruct.getArray();
    structStack.push(obj);

    SetMetaData lm = (SetMetaData) obj.getMetaData();
    return new TSet(lm.elemMetaData.type, obj.length());
}
项目:Firefly    文件:SetTypeAdapterFactory.java   
@Override
public void write(Set set, TProtocol protocol) throws TException {
    protocol.writeSetBegin(new TSet(valueTypeAdapter.getTType(), set.size()));
    for (Object o : set) {
        valueTypeAdapter.write(o, protocol);
    }
    protocol.writeSetEnd();
}
项目:Firefly    文件:SetTypeAdapterFactory.java   
@Override
public Set read(TProtocol protocol) throws TException {
    TSet tset = protocol.readSetBegin();
    HashSet hashSet = new HashSet(tset.size);
    for (int i = 0, n = tset.size; i < n; i++) {
        hashSet.add(valueTypeAdapter.read(protocol));
    }
    protocol.readSetEnd();
    return hashSet;
}
项目:parquet-format    文件:EventBasedThriftReader.java   
/**
 * reads the set content (elements) from the underlying protocol and passes the events to the set event consumer
 * @param eventConsumer the consumer
 * @param tSet the set descriptor
 * @throws TException
 */
public void readSetContent(SetConsumer eventConsumer, TSet tSet)
    throws TException {
  for (int i = 0; i < tSet.size; i++) {
    eventConsumer.consumeElement(protocol, this, tSet.elemType);
  }
}
项目:parquet-mr    文件:ThriftRecordConverter.java   
@Override
void collectionStart(final int count, final byte type) {
  parentEvents.add(new ParquetProtocol("readSetBegin()") {
    @Override
    public TSet readSetBegin() throws TException {
      return new TSet(type, count);
    }
  });
}
项目:parquet-mr    文件:ProtocolReadToWrite.java   
private void readOneSet(TProtocol in, TProtocol out) throws TException {
  final TSet set = in.readSetBegin();
  out.writeSetBegin(set);
  readCollectionElements(in, out, set.size, set.elemType);
  in.readSetEnd();
  out.writeSetEnd();
}
项目:pinpoint    文件:TReplaceListProtocol.java   
@Override
public TSet readSetBegin() throws TException {
    throw new TException("unsupported operation");
}
项目:ThriftMongoBridge    文件:TBSONProtocol.java   
public TSet readSetBegin() throws TException {
    StructContext context = (StructContext) peekContext();
    if(context.fieldsStack.isEmpty()) {
     return EMPTY_SET;
   }
   String fieldName = context.fieldsStack.peek();

   ListContext listContext = new ListContext();
   BasicDBList dbList = (BasicDBList) context.dbObject.get(fieldName);

   listContext.dbList = dbList;
   listContext.thriftObject = getThriftObject(context.thriftObject, fieldName);
   pushContext(listContext);
   return new TSet(TType.SET, dbList.size());
}
项目:human_readable_json_protocol    文件:HumanReadableJsonProtocol.java   
@Override
public TSet readSetBegin() throws TException {
    return new TSet((Byte) params.pollFirst(), (Integer) params.pollFirst());
}
项目:human_readable_json_protocol    文件:HumanReadableJsonProtocol.java   
@Override
public void writeSetBegin(TSet tSet) throws TException {
    oprot.writeSetBegin(tSet);
}
项目:human_readable_json_protocol    文件:TSimpleJSONProtocol.java   
public void writeSetBegin(TSet set) throws TException {
    this.assertContextIsNotMapKey("set");
    this.writeContext_.write();
    this.trans_.write(LBRACKET);
    this.pushWriteContext(new TSimpleJSONProtocol.ListContext());
}
项目:human_readable_json_protocol    文件:TSimpleJSONProtocol.java   
public TSet readSetBegin() throws TException {
    return EMPTY_SET;
}
项目:armeria    文件:TTextProtocol.java   
@Override
public void writeSetBegin(TSet set) throws TException {
    writeSequenceBegin(set.size);
}
项目:armeria    文件:TTextProtocol.java   
@Override
public TSet readSetBegin() throws TException {
    int size = readSequenceBegin();
    return new TSet(UNUSED_TYPE, size);
}
项目:apm-agent    文件:TReplaceListProtocol.java   
@Override
public void writeSetBegin(TSet set) throws TException {
    if (!writeFieldBegin) {
        protocol.writeSetBegin(set);
    }
}
项目:apm-agent    文件:TReplaceListProtocol.java   
@Override
public TSet readSetBegin() throws TException {
    throw new TException("unsupported operation");
}
项目:parquet-format    文件:InterningProtocol.java   
public void writeSetBegin(TSet set) throws TException {
  delegate.writeSetBegin(set);
}
项目:parquet-format    文件:InterningProtocol.java   
public TSet readSetBegin() throws TException {
  return delegate.readSetBegin();
}
项目:parquet-format    文件:TypedConsumer.java   
public void consumeSet(TProtocol protocol, EventBasedThriftReader reader, TSet tSet) throws TException {
  reader.readSetContent(this, tSet);
}
项目:parquet-mr    文件:ParquetWriteProtocol.java   
@Override
public void writeSetBegin(TSet set) throws TException {
  size = set.size;
  startListWrapper();
}
项目:parquet-mr    文件:ParquetWriteProtocol.java   
/**
 * {@inheritDoc}
 * @see org.apache.parquet.thrift.ParquetProtocol#writeSetBegin(org.apache.thrift.protocol.TSet)
 */
@Override
public void writeSetBegin(TSet set) throws TException {
  LOG.debug("writeSetBegin({})", set);
  currentProtocol.writeSetBegin(set);
}
项目:parquet-mr    文件:BufferedProtocolReadToWrite.java   
@Override
public void writeSetBegin(TSet tSet) throws TException {
}
项目:parquet-mr    文件:BufferedProtocolReadToWrite.java   
@Override
public TSet readSetBegin() throws TException {
  return null;
}
项目:parquet-mr    文件:ParquetProtocol.java   
@Override
public void writeSetBegin(TSet set) throws TException {
  throw exception();
}
项目:parquet-mr    文件:ParquetProtocol.java   
@Override
public TSet readSetBegin() throws TException {
  throw exception();
}
项目:parquet-mr    文件:ParquetReadProtocol.java   
public TSet readSetBegin() throws TException {
  LOG.debug("readSetBegin()");
  return next().readSetBegin();
}
项目:pinpoint    文件:TReplaceListProtocol.java   
@Override
public void writeSetBegin(TSet set) throws TException {
    if (!writeFieldBegin) {
        protocol.writeSetBegin(set);
    }
}
项目:pinot    文件:ThriftSampleData.java   
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);
    }

}
项目:pinot    文件:ThriftSampleData.java   
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();
}
项目:ThriftMongoBridge    文件:TBSONProtocol.java   
/**
 * A Set have the same serialization of a thrift List
 */
public void writeSetBegin(TSet set) throws TException {
    pushContext(new ListContext());
}
项目:voldemort    文件:MockMessage.java   
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();
}