org.apache.thrift.protocol.TList Java Examples
The following examples show how to use
org.apache.thrift.protocol.TList.
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 |
private boolean readOneList(TProtocol in, List<Action> buffer, ListType expectedType) throws TException { final TList list = in.readListBegin(); buffer.add(new Action() { @Override public void write(TProtocol out) throws TException { out.writeListBegin(list); } @Override public String toDebugString() { return "<e=" + list.elemType + ", s=" + list.size + ">{"; } }); boolean hasFieldsIgnored = readCollectionElements(in, list.size, list.elemType, buffer, expectedType.getValues().getType()); in.readListEnd(); buffer.add(LIST_END); return hasFieldsIgnored; }
Example #2
Source File: DefaultEventsVisitor.java From parquet-mr with Apache License 2.0 | 6 votes |
@Override public Void visit(final ThriftType.ListType listType, Void v) { dummyEvents.add(new ParquetProtocol("readListBegin()") { @Override public TList readListBegin() throws TException { return new TList(); } }); dummyEvents.add(new ParquetProtocol("readListEnd()") { @Override public void readListEnd() throws TException { } }); return null; }
Example #3
Source File: Consumers.java From parquet-format with Apache License 2.0 | 6 votes |
/** * To consume a list of elements * @param c the type of the list content * @param consumer the consumer that will receive the list * @return a ListConsumer that can be passed to the DelegatingFieldConsumer */ public static <T extends TBase<T,? extends TFieldIdEnum>> ListConsumer listOf(Class<T> c, final Consumer<List<T>> consumer) { class ListConsumer implements Consumer<T> { List<T> list; @Override public void consume(T t) { list.add(t); } } final ListConsumer co = new ListConsumer(); return new DelegatingListElementsConsumer(struct(c, co)) { @Override public void consumeList(TProtocol protocol, EventBasedThriftReader reader, TList tList) throws TException { co.list = new ArrayList<T>(); super.consumeList(protocol, reader, tList); consumer.consume(co.list); } }; }
Example #4
Source File: Consumers.java From parquet-mr with Apache License 2.0 | 6 votes |
/** * To consume a list of elements * @param c the class of the list content * @param consumer the consumer that will receive the list * @param <T> the type of the list content * @return a ListConsumer that can be passed to the DelegatingFieldConsumer */ public static <T extends TBase<T,? extends TFieldIdEnum>> ListConsumer listOf(Class<T> c, final Consumer<List<T>> consumer) { class ListConsumer implements Consumer<T> { List<T> list; @Override public void consume(T t) { list.add(t); } } final ListConsumer co = new ListConsumer(); return new DelegatingListElementsConsumer(struct(c, co)) { @Override public void consumeList(TProtocol protocol, EventBasedThriftReader reader, TList tList) throws TException { co.list = new ArrayList<T>(); super.consumeList(protocol, reader, tList); consumer.consume(co.list); } }; }
Example #5
Source File: ProtocolReadToWrite.java From parquet-mr with Apache License 2.0 | 5 votes |
private void readOneList(TProtocol in, TProtocol out) throws TException { final TList list = in.readListBegin(); out.writeListBegin(list); readCollectionElements(in, out, list.size, list.elemType); in.readListEnd(); out.writeListEnd(); }
Example #6
Source File: TSimpleJSONProtocol.java From nettythrift with Apache License 2.0 | 5 votes |
public void writeListBegin(TList list) throws TException { assertContextIsNotMapKey(LIST); writeContext_.write(); trans_.write(LBRACKET); pushWriteContext(new ListContext()); // No metadata! }
Example #7
Source File: TSimpleJSONProtocol.java From nettythrift with Apache License 2.0 | 5 votes |
public TList readListBegin() throws TException { BaseArray prevStruct = structStack.peek(); BaseArray obj = prevStruct.getArray(); structStack.push(obj); ListMetaData lm = (ListMetaData) obj.getMetaData(); return new TList(lm.elemMetaData.type, obj.length()); }
Example #8
Source File: InternalScribeCodec.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
public static void writeLogRequest( byte[] category, List<byte[]> encodedSpans, int seqid, TBinaryProtocol oprot) throws TException { oprot.writeMessageBegin(new TMessage("Log", TMessageType.CALL, seqid)); oprot.writeFieldBegin(MESSAGES_FIELD_DESC); oprot.writeListBegin(new TList(TType.STRUCT, encodedSpans.size())); for (byte[] encodedSpan : encodedSpans) write(category, encodedSpan, oprot); oprot.writeFieldStop(); }
Example #9
Source File: ListTypeAdapterFactory.java From Firefly with Apache License 2.0 | 5 votes |
@Override public void write(List list, TProtocol protocol) throws TException { protocol.writeListBegin(new TList(valueTypeAdapter.getTType(), list.size())); for (Object o : list) { valueTypeAdapter.write(o, protocol); } protocol.writeListEnd(); }
Example #10
Source File: ListTypeAdapterFactory.java From Firefly with Apache License 2.0 | 5 votes |
@Override public List read(TProtocol protocol) throws TException { TList tlist = protocol.readListBegin(); ArrayList arrayList = new ArrayList(tlist.size); for (int i = 0, n = tlist.size; i < n; i++) { arrayList.add(valueTypeAdapter.read(protocol)); } protocol.readListEnd(); return arrayList; }
Example #11
Source File: ThriftRecordConverter.java From parquet-mr with Apache License 2.0 | 5 votes |
@Override void collectionStart(final int count, final byte type) { parentEvents.add(new ParquetProtocol("readListBegin()") { @Override public TList readListBegin() throws TException { return new TList(type, count); } }); }
Example #12
Source File: TReplaceListProtocol.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void writeListBegin(TList list) throws TException { if (!writeFieldBegin) { protocol.writeListBegin(list); return; } if (writeListDepth == 0 && currentField != null) { List<ByteArrayOutput> outputs = replaceFields.get(currentField.name); if (outputs == null) { throw new TException("not found replace field - " + currentField.name); } final TList replaceList = new TList(list.elemType, outputs.size()); protocol.writeListBegin(replaceList); for (ByteArrayOutput output : outputs) { try { final OutputStream out = ((ByteArrayOutputStreamTransport) getTransport()).getByteArrayOutputStream(); output.writeTo(out); } catch (IOException e) { throw new TException(e); } } } writeListDepth++; }
Example #13
Source File: EventBasedThriftReader.java From parquet-mr with Apache License 2.0 | 5 votes |
/** * reads the list content (elements) from the underlying protocol and passes the events to the list event consumer * @param eventConsumer the consumer * @param tList the list descriptor * @throws TException if any thrift related error occurs during the reading */ public void readListContent(ListConsumer eventConsumer, TList tList) throws TException { for (int i = 0; i < tList.size; i++) { eventConsumer.consumeElement(protocol, this, tList.elemType); } }
Example #14
Source File: EventBasedThriftReader.java From parquet-format with Apache License 2.0 | 5 votes |
/** * reads the list content (elements) from the underlying protocol and passes the events to the list event consumer * @param eventConsumer the consumer * @param tList the list descriptor * @throws TException */ public void readListContent(ListConsumer eventConsumer, TList tList) throws TException { for (int i = 0; i < tList.size; i++) { eventConsumer.consumeElement(protocol, this, tList.elemType); } }
Example #15
Source File: ParquetProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public TList readListBegin() throws TException { throw exception(); }
Example #16
Source File: BufferedProtocolReadToWrite.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public void writeListBegin(TList tList) throws TException { }
Example #17
Source File: BufferedProtocolReadToWrite.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public TList readListBegin() throws TException { return null; }
Example #18
Source File: ParquetProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public void writeListBegin(TList list) throws TException { throw exception(); }
Example #19
Source File: ThriftSampleData.java From incubator-pinot with Apache License 2.0 | 4 votes |
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 #20
Source File: ParquetReadProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
public TList readListBegin() throws TException { LOG.debug("readListBegin()"); return next().readListBegin(); }
Example #21
Source File: TReplaceListProtocol.java From pinpoint with Apache License 2.0 | 4 votes |
@Override public TList readListBegin() throws TException { throw new TException("unsupported operation"); }
Example #22
Source File: ThriftSampleData.java From incubator-pinot with Apache License 2.0 | 4 votes |
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 #23
Source File: MappedFileTBinaryProtocol.java From singer with Apache License 2.0 | 4 votes |
public TList readListBegin() throws TException { TList list = new TList(readByte(), readI32()); checkContainerReadLength(list.size); return list; }
Example #24
Source File: ParquetWriteProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} * @see org.apache.parquet.thrift.ParquetProtocol#writeListBegin(org.apache.thrift.protocol.TList) */ @Override public void writeListBegin(TList list) throws TException { if (LOG.isDebugEnabled()) LOG.debug("writeListBegin("+toString(list)+")"); currentProtocol.writeListBegin(list); }
Example #25
Source File: ParquetWriteProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
private String toString(TList list) { return "<TList elemType:" + list.elemType + " size:" + list.size + ">"; }
Example #26
Source File: ParquetWriteProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public void writeListBegin(TList list) throws TException { size = list.size; startListWrapper(); }
Example #27
Source File: TypedConsumer.java From parquet-mr with Apache License 2.0 | 4 votes |
public void consumeList(TProtocol protocol, EventBasedThriftReader reader, TList tList) throws TException { reader.readListContent(this, tList); }
Example #28
Source File: InterningProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
public TList readListBegin() throws TException { return delegate.readListBegin(); }
Example #29
Source File: InterningProtocol.java From parquet-mr with Apache License 2.0 | 4 votes |
public void writeListBegin(TList list) throws TException { delegate.writeListBegin(list); }
Example #30
Source File: TypedConsumer.java From parquet-format with Apache License 2.0 | 4 votes |
public void consumeList(TProtocol protocol, EventBasedThriftReader reader, TList tList) throws TException { reader.readListContent(this, tList); }