当前位置: 首页>>代码示例>>Java>>正文


Java TStruct类代码示例

本文整理汇总了Java中org.apache.thrift.protocol.TStruct的典型用法代码示例。如果您正苦于以下问题:Java TStruct类的具体用法?Java TStruct怎么用?Java TStruct使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TStruct类属于org.apache.thrift.protocol包,在下文中一共展示了TStruct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeRequest

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request)
    throws IOException {
    Invocation invocation = (Invocation) request.getData();
    TProtocol protocol = newProtocol(channel.getUrl(), buffer);
    try {
        protocol.writeMessageBegin(new TMessage(
            invocation.getMethodName(), TMessageType.CALL, 
            thriftSeq.getAndIncrement()));
        protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args"));
        for(int i = 0; i < invocation.getParameterTypes().length; i++) {
            Class<?> type = invocation.getParameterTypes()[i];

        }
    } catch (TException e) {
        throw new IOException(e.getMessage(), e);
    }

}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:ThriftNativeCodec.java

示例2: writeMessage

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
private void writeMessage(PMessage<?,?> message, TProtocol protocol) throws TException, SerializerException {
    PMessageDescriptor<?, ?> type = message.descriptor();

    protocol.writeStructBegin(new TStruct(message.descriptor()
                                                 .getQualifiedName()));

    for (PField field : type.getFields()) {
        if (!message.has(field.getId())) {
            continue;
        }

        protocol.writeFieldBegin(new TField(field.getName(),
                                            forType(field.getDescriptor().getType()),
                                            (short) field.getId()));

        writeTypedValue(message.get(field.getId()), field.getDescriptor(), protocol);

        protocol.writeFieldEnd();
    }

    protocol.writeFieldStop();
    protocol.writeStructEnd();
}
 
开发者ID:morimekta,项目名称:providence,代码行数:24,代码来源:TProtocolSerializer.java

示例3: encodeRequest

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request)
        throws IOException {
    Invocation invocation = (Invocation) request.getData();
    TProtocol protocol = newProtocol(channel.getUrl(), buffer);
    try {
        protocol.writeMessageBegin(new TMessage(
                invocation.getMethodName(), TMessageType.CALL,
                thriftSeq.getAndIncrement()));
        protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args"));
        for (int i = 0; i < invocation.getParameterTypes().length; i++) {
            Class<?> type = invocation.getParameterTypes()[i];

        }
    } catch (TException e) {
        throw new IOException(e.getMessage(), e);
    }

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:19,代码来源:ThriftNativeCodec.java

示例4: write

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public void write(TProtocol oprot) throws TException {
  TStruct struct = new TStruct("TApplicationException");
  TField field = new TField();
  oprot.writeStructBegin(struct);
  if (getMessage() != null) {
    field.name = "message";
    field.type = TType.STRING;
    field.id = 1;
    oprot.writeFieldBegin(field);
    oprot.writeString(getMessage());
    oprot.writeFieldEnd();
  }
  field.name = "type";
  field.type = TType.I32;
  field.id = 2;
  oprot.writeFieldBegin(field);
  oprot.writeI32(type_);
  oprot.writeFieldEnd();
  oprot.writeFieldStop();
  oprot.writeStructEnd();

}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:23,代码来源:TApplicationException.java

示例5: readStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public TStruct readStructBegin() {
	BaseArray prevStruct = structStack.peek();
	if (prevStruct != null) {
		BaseArray e = prevStruct.getArray();
		structStack.push(e);
	} else {
		structStack.push(msgStruct);
	}
	return ANONYMOUS_STRUCT;
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:11,代码来源:TSimpleJSONProtocol.java

示例6: readStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
@Override
public TStruct readStructBegin() throws TException {
    if (err != null) {
        throw err;
    }
    return new TStruct();
}
 
开发者ID:degupta,项目名称:human_readable_json_protocol,代码行数:8,代码来源:HumanReadableJsonProtocol.java

示例7: readStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
@Override
public TStruct readStructBegin() throws TException {
  if (structLevel == 1) {
    if (topLevelStructToBeRecorded == topLevelStruct)
      rememberingTransport.startRemeberingReadBytes();
  }
  structLevel++;
  return super.readStructBegin();
}
 
开发者ID:diqube,项目名称:diqube,代码行数:10,代码来源:TicketUtil.java

示例8: main

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public static void main(String[] args) throws TException {
    TTransport trans = new TSimpleFileTransport("data.comp", false, true);
    TProtocol proto = new TCompactProtocol(trans);			

    Trade trade = new Trade();
    trade.symbol = "F";
    trade.price = 13.10;
    trade.size = 2500;

    proto.writeStructBegin(new TStruct());

    proto.writeFieldBegin(new TField("symbol", 
                                     TType.STRING, 
                                     (short) 1));
    proto.writeString(trade.symbol);
    proto.writeFieldEnd();

    proto.writeFieldBegin(new TField("price", 
                                     TType.DOUBLE, 
                                     (short) 2));
    proto.writeDouble(trade.price);
    proto.writeFieldEnd();

    proto.writeFieldBegin(new TField("size", 
                                     TType.I32, 
                                     (short) 3));
    proto.writeI32(trade.size);
    proto.writeFieldEnd();

    proto.writeFieldStop();
    proto.writeStructEnd();
    
    System.out.println("Wrote trade to file");
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:35,代码来源:CompFileWrite.java

示例9: main

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public static void main(String[] args) throws TException {
    TTransport trans = new TSimpleFileTransport("data", true, false);
    TProtocol proto = new TBinaryProtocol(trans);		

    Trade trade_read = new Trade();
    TField field = new TField();

    TStruct struct_obj = proto.readStructBegin();		
    while(true) {						
        field = proto.readFieldBegin();			
        if (field.id == TType.STOP) {				
            break;
        }
        switch(field.id) {					
        case 1:
            trade_read.symbol = proto.readString();	
            break;
        case 2:
            trade_read.price = proto.readDouble();
            break;
        case 3:
            trade_read.size = proto.readI32();
            break;
        default:
            TProtocolUtil.skip(proto,field.type);	
            break;
        }
        proto.readFieldEnd();				
    }
    proto.readStructEnd();				

    System.out.println("Trade: " + trade_read.symbol + " " +
                       trade_read.size + " @ " + trade_read.price);
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:35,代码来源:BinFileRead.java

示例10: StructConverter

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
private StructConverter(List<TProtocol> events, GroupType parquetSchema, ThriftField field) {
  this.events = events;
  this.name = field.getName();
  this.tStruct = new TStruct(name);
  this.thriftType = (StructType)field.getType();
  this.schemaSize = parquetSchema.getFieldCount();
  this.converters = new Converter[this.schemaSize];
  List<ThriftField> thriftChildren = thriftType.getChildren();
  for (int i = 0; i < schemaSize; i++) {
    Type schemaType = parquetSchema.getType(i);
    String fieldName = schemaType.getName();
    ThriftField matchingThrift = null;
    for (ThriftField childField: thriftChildren) {
      String thriftChildName = childField.getName();
      if (thriftChildName != null && thriftChildName.equalsIgnoreCase(fieldName)) {
        matchingThrift = childField;
        break;
      }
    }
    if (matchingThrift == null) {
    	// this means the file did not contain that field
      // it will never be populated in this instance
      // other files might populate it
    	continue;
    }
    if (schemaType.isPrimitive()) {
    	converters[i] = new PrimitiveFieldHandler(newConverter(events, schemaType, matchingThrift).asPrimitiveConverter(), matchingThrift, events);
    } else {
    	converters[i] = new GroupFieldhandler(newConverter(events, schemaType, matchingThrift).asGroupConverter(), matchingThrift, events);
    }
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:33,代码来源:ThriftRecordConverter.java

示例11: readOneStruct

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
private void readOneStruct(TProtocol in, TProtocol out) throws TException {
  final TStruct struct = in.readStructBegin();
  out.writeStructBegin(struct);
  TField field;
  while ((field = in.readFieldBegin()).type != TType.STOP) {
    out.writeFieldBegin(field);
    readOneValue(in, out, field.type);
    in.readFieldEnd();
    out.writeFieldEnd();
  }
  out.writeFieldStop();
  in.readStructEnd();
  out.writeStructEnd();
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:15,代码来源:ProtocolReadToWrite.java

示例12: readStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public TStruct readStructBegin() throws TException {
	try {
		DBObject dbObject = null;
		Object thriftObject = null;

		if(!isContextEmpty()) {
			Context currentContext = peekContext();

			if (currentContext instanceof ListContext) {
				dbObject = (DBObject) ((ListContext) currentContext).next();
				thriftObject = ((ListContext) peekContext()).thriftObject;
			} else if (currentContext instanceof MapContext) {
				dbObject = (DBObject) ((MapContext) currentContext).next();
				thriftObject = ((MapContext) peekContext()).thriftObject;
			} else {
				return ANONYMOUS_STRUCT;
			}
		} else {
			thriftObject = threadSafeTBase.get();
			dbObject = getDBObject();
		}
     StructContext context = new StructContext(thriftObject.getClass().getSimpleName());
		context.setDbObject(dbObject);
		context.thriftObject = thriftObject;
		pushContext(context);

		return ANONYMOUS_STRUCT;
	} catch (Exception exp) {
     throw new TException("Unexpected readStructBegin", exp);
	}
}
 
开发者ID:BreizhBeans,项目名称:ThriftMongoBridge,代码行数:32,代码来源:TBSONProtocol.java

示例13: writeStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
public void writeStructBegin(TStruct struct) throws TException {
	writeContext_.write();
	trans_.write(LBRACE);
	pushWriteContext(new StructContext());
}
 
开发者ID:houkx,项目名称:nettythrift,代码行数:6,代码来源:TSimpleJSONProtocol.java

示例14: getTStruct

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
@Override
protected TStruct getTStruct() {
	return STRUCT_DESC;
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:5,代码来源:ArgsThriftBase.java

示例15: writeStructBegin

import org.apache.thrift.protocol.TStruct; //导入依赖的package包/类
@Override
public void writeStructBegin(TStruct tStruct) throws TException {
    oprot.writeStructBegin(tStruct);
}
 
开发者ID:degupta,项目名称:human_readable_json_protocol,代码行数:5,代码来源:HumanReadableJsonProtocol.java


注:本文中的org.apache.thrift.protocol.TStruct类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。