本文整理汇总了Java中org.apache.thrift.protocol.TList类的典型用法代码示例。如果您正苦于以下问题:Java TList类的具体用法?Java TList怎么用?Java TList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TList类属于org.apache.thrift.protocol包,在下文中一共展示了TList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listOf
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
/**
* 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);
}
};
}
示例2: visit
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@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;
}
示例3: readOneList
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
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;
}
示例4: writeListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
public void writeListBegin(TList list) throws TException {
assertContextIsNotMapKey(LIST);
writeContext_.write();
trans_.write(LBRACKET);
pushWriteContext(new ListContext());
// No metadata!
}
示例5: readListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
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());
}
示例6: write
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@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();
}
示例7: read
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@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;
}
示例8: writeListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@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++;
}
示例9: readListContent
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
/**
* 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);
}
}
示例10: collectionStart
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@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);
}
});
}
示例11: readOneList
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
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();
}
示例12: readListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
public TList readListBegin() throws TException {
StructContext context = (StructContext) peekContext();
if(context.fieldsStack.isEmpty()) {
return EMPTY_LIST;
}
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 TList(TType.LIST, dbList.size());
}
示例13: readListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@Override
public TList readListBegin() throws TException {
return new TList((Byte) params.pollFirst(), (Integer) params.pollFirst());
}
示例14: writeListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
@Override
public void writeListBegin(TList tList) throws TException {
oprot.writeListBegin(tList);
}
示例15: writeListBegin
import org.apache.thrift.protocol.TList; //导入依赖的package包/类
public void writeListBegin(TList list) throws TException {
this.assertContextIsNotMapKey("list");
this.writeContext_.write();
this.trans_.write(LBRACKET);
this.pushWriteContext(new TSimpleJSONProtocol.ListContext());
}