org.apache.thrift.protocol.TSet Java Examples

The following examples show how to use org.apache.thrift.protocol.TSet. 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 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;
}
 
Example #2
Source File: DefaultEventsVisitor.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: ProtocolReadToWrite.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #4
Source File: TSimpleJSONProtocol.java    From nettythrift with Apache License 2.0 5 votes vote down vote up
public void writeSetBegin(TSet set) throws TException {
	assertContextIsNotMapKey(SET);
	writeContext_.write();
	trans_.write(LBRACKET);
	pushWriteContext(new ListContext());
	// No metadata!
}
 
Example #5
Source File: TSimpleJSONProtocol.java    From nettythrift with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #6
Source File: SetTypeAdapterFactory.java    From Firefly with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #7
Source File: SetTypeAdapterFactory.java    From Firefly with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: ThriftRecordConverter.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
@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);
    }
  });
}
 
Example #9
Source File: EventBasedThriftReader.java    From parquet-mr with Apache License 2.0 5 votes vote down vote up
/**
 * 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 if any thrift related error occurs during the reading
 */
public void readSetContent(SetConsumer eventConsumer, TSet tSet)
    throws TException {
  for (int i = 0; i < tSet.size; i++) {
    eventConsumer.consumeElement(protocol, this, tSet.elemType);
  }
}
 
Example #10
Source File: EventBasedThriftReader.java    From parquet-format with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example #11
Source File: ParquetProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public TSet readSetBegin() throws TException {
  throw exception();
}
 
Example #12
Source File: BufferedProtocolReadToWrite.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public void writeSetBegin(TSet tSet) throws TException {
}
 
Example #13
Source File: BufferedProtocolReadToWrite.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public TSet readSetBegin() throws TException {
  return null;
}
 
Example #14
Source File: ParquetProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public void writeSetBegin(TSet set) throws TException {
  throw exception();
}
 
Example #15
Source File: ThriftSampleData.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
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();
}
 
Example #16
Source File: ParquetReadProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
public TSet readSetBegin() throws TException {
  LOG.debug("readSetBegin()");
  return next().readSetBegin();
}
 
Example #17
Source File: TReplaceListProtocol.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Override
public void writeSetBegin(TSet set) throws TException {
    if (!writeFieldBegin) {
        protocol.writeSetBegin(set);
    }
}
 
Example #18
Source File: TReplaceListProtocol.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Override
public TSet readSetBegin() throws TException {
    throw new TException("unsupported operation");
}
 
Example #19
Source File: ThriftSampleData.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
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);
  }
}
 
Example #20
Source File: MappedFileTBinaryProtocol.java    From singer with Apache License 2.0 4 votes vote down vote up
public TSet readSetBegin() throws TException {
  TSet set = new TSet(readByte(), readI32());
  checkContainerReadLength(set.size);
  return set;
}
 
Example #21
Source File: ParquetWriteProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
/**
 * {@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);
}
 
Example #22
Source File: ParquetWriteProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public void writeSetBegin(TSet set) throws TException {
  size = set.size;
  startListWrapper();
}
 
Example #23
Source File: TypedConsumer.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
public void consumeSet(TProtocol protocol, EventBasedThriftReader reader, TSet tSet) throws TException {
  reader.readSetContent(this, tSet);
}
 
Example #24
Source File: InterningProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
public TSet readSetBegin() throws TException {
  return delegate.readSetBegin();
}
 
Example #25
Source File: InterningProtocol.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
public void writeSetBegin(TSet set) throws TException {
  delegate.writeSetBegin(set);
}
 
Example #26
Source File: TypedConsumer.java    From parquet-format with Apache License 2.0 4 votes vote down vote up
public void consumeSet(TProtocol protocol, EventBasedThriftReader reader, TSet tSet) throws TException {
  reader.readSetContent(this, tSet);
}
 
Example #27
Source File: InterningProtocol.java    From parquet-format with Apache License 2.0 4 votes vote down vote up
public TSet readSetBegin() throws TException {
  return delegate.readSetBegin();
}
 
Example #28
Source File: InterningProtocol.java    From parquet-format with Apache License 2.0 4 votes vote down vote up
public void writeSetBegin(TSet set) throws TException {
  delegate.writeSetBegin(set);
}
 
Example #29
Source File: TTextProtocol.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public TSet readSetBegin() throws TException {
    final int size = readSequenceBegin();
    return new TSet(UNUSED_TYPE, size);
}
 
Example #30
Source File: TTextProtocol.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public void writeSetBegin(TSet set) throws TException {
    writeSequenceBegin();
}