本文整理汇总了Java中org.apache.thrift.protocol.TType.VOID属性的典型用法代码示例。如果您正苦于以下问题:Java TType.VOID属性的具体用法?Java TType.VOID怎么用?Java TType.VOID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.thrift.protocol.TType
的用法示例。
在下文中一共展示了TType.VOID属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFieldBegin
public TField readFieldBegin() throws TException {
StructContext context = (StructContext) peekContext();
if(context.fieldsStack.isEmpty()) {
// Empty stack -> returns a TType.STOP
return new TField();
}
String fieldName = context.fieldsStack.peek();
TField currentField = getTField(context.thriftObject, fieldName);
//currentField.id
// IF the field is skiped change the type to void
Map<Class<?>, List<Short>> filter = threadSafeFieldIds.get();
if(filter!=null) {
List<Short> fieldsFiltered = filter.get(context.thriftObject.getClass());
if(fieldsFiltered != null && fieldsFiltered.contains(currentField.id)) {
return new TField(currentField.name, TType.VOID, currentField.id);
}
}
// If the field is a struct push a struct context in the stack
if (currentField.type == TType.STRUCT) {
StructContext structContext = new StructContext(fieldName);
structContext.setDbObject((DBObject) context.dbObject.get(fieldName));
structContext.thriftObject = getThriftObject(context.thriftObject, fieldName);
pushContext(structContext);
}
return currentField;
}
示例2: readMapBegin
public TMap readMapBegin() throws TException {
StructContext context = (StructContext) peekContext();
if(context.fieldsStack.isEmpty()) {
return EMPTY_MAP;
}
String fieldName = context.fieldsStack.peek();
MapContext mapContext = new MapContext(TType.VOID);
BasicDBObject dbMap = (BasicDBObject) context.dbObject.get(fieldName);
mapContext.setDbMap(dbMap);
mapContext.thriftObject = getThriftObject(context.thriftObject, fieldName);
pushContext(mapContext);
return new TMap(TType.STRING, TType.STRING,dbMap.size());
}
示例3: toTypeSignature
@VisibleForTesting
static TypeSignature toTypeSignature(FieldValueMetaData fieldValueMetaData) {
if (fieldValueMetaData instanceof StructMetaData) {
return TypeSignature.ofNamed(((StructMetaData) fieldValueMetaData).structClass);
}
if (fieldValueMetaData instanceof EnumMetaData) {
return TypeSignature.ofNamed(((EnumMetaData) fieldValueMetaData).enumClass);
}
if (fieldValueMetaData instanceof ListMetaData) {
return TypeSignature.ofList(toTypeSignature(((ListMetaData) fieldValueMetaData).elemMetaData));
}
if (fieldValueMetaData instanceof SetMetaData) {
return TypeSignature.ofSet(toTypeSignature(((SetMetaData) fieldValueMetaData).elemMetaData));
}
if (fieldValueMetaData instanceof MapMetaData) {
return TypeSignature.ofMap(toTypeSignature(((MapMetaData) fieldValueMetaData).keyMetaData),
toTypeSignature(((MapMetaData) fieldValueMetaData).valueMetaData));
}
if (fieldValueMetaData.isBinary()) {
return BINARY;
}
switch (fieldValueMetaData.type) {
case TType.VOID:
return VOID;
case TType.BOOL:
return BOOL;
case TType.BYTE:
return I8;
case TType.DOUBLE:
return DOUBLE;
case TType.I16:
return I16;
case TType.I32:
return I32;
case TType.I64:
return I64;
case TType.STRING:
return STRING;
}
final String unresolvedName;
if (fieldValueMetaData.isTypedef()) {
unresolvedName = fieldValueMetaData.getTypedefName();
} else {
unresolvedName = null;
}
return TypeSignature.ofUnresolved(firstNonNull(unresolvedName, "unknown"));
}
示例4: readOneValue
void readOneValue(TProtocol in, TProtocol out, byte type)
throws TException {
switch (type) {
case TType.LIST:
readOneList(in, out);
break;
case TType.MAP:
readOneMap(in, out);
break;
case TType.SET:
readOneSet(in, out);
break;
case TType.STRUCT:
readOneStruct(in, out);
break;
case TType.STOP:
break;
case TType.BOOL:
out.writeBool(in.readBool());
break;
case TType.BYTE:
out.writeByte(in.readByte());
break;
case TType.DOUBLE:
out.writeDouble(in.readDouble());
break;
case TType.I16:
out.writeI16(in.readI16());
break;
case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
case TType.I32:
out.writeI32(in.readI32());
break;
case TType.I64:
out.writeI64(in.readI64());
break;
case TType.STRING:
out.writeBinary(in.readBinary());
break;
case TType.VOID:
break;
default:
throw new TException("Unknown type: " + type);
}
}
示例5: readOneValue
/**
* @return true when all value is consumed, false when some values is ignored due to the field is not defined in expectedType
* @throws TException
*/
private boolean readOneValue(TProtocol in, byte type, List<Action> buffer, ThriftType expectedType) throws TException {
if (expectedType != null && expectedType.getType().getSerializedThriftType() != type) {
throw new DecodingSchemaMismatchException("the data type does not match the expected thrift structure: expected " + expectedType + " got " + typeName(type));
}
boolean hasFieldsIgnored = false;
switch (type) {
case TType.LIST:
hasFieldsIgnored = readOneList(in, buffer, (ListType)expectedType);
break;
case TType.MAP:
hasFieldsIgnored = readOneMap(in, buffer, (MapType)expectedType);
break;
case TType.SET:
hasFieldsIgnored = readOneSet(in, buffer, (SetType)expectedType);
break;
case TType.STRUCT:
hasFieldsIgnored = readOneStruct(in, buffer, (StructType)expectedType);
break;
case TType.STOP:
break;
case TType.BOOL:
final boolean bool = in.readBool();
writeBoolAction(buffer, bool);
break;
case TType.BYTE:
final byte b = in.readByte();
writeByteAction(buffer, b);
break;
case TType.DOUBLE:
final double d = in.readDouble();
writeDoubleAction(buffer, d);
break;
case TType.I16:
final short s = in.readI16();
writeShortAction(buffer, s);
break;
case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
case TType.I32:
final int i = in.readI32();
checkEnum(expectedType,i);
writeIntAction(buffer, i);
break;
case TType.I64:
final long l = in.readI64();
writeLongAction(buffer, l);
break;
case TType.STRING:
final ByteBuffer bin = in.readBinary();
writeStringAction(buffer, bin);
break;
case TType.VOID:
break;
default:
throw new TException("Unknown type: " + type);
}
return hasFieldsIgnored;
}