/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ @org.apache.thrift.annotation.Nullable public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS;
@VisibleForTesting static StructInfo newStructInfo(Class<? extends TBase<?, ?>> structClass) { final String name = structClass.getName(); final Map<?, FieldMetaData> metaDataMap = FieldMetaData.getStructMetaDataMap(structClass); final List<FieldInfo> fields = metaDataMap.values().stream() .map(fieldMetaData -> newFieldInfo(structClass, fieldMetaData)) .collect(Collectors.toList()); return new StructInfo(name, fields); }
@Test public void testNewExceptionInfo() { final ExceptionInfo exception = newExceptionInfo(FooServiceException.class); assertThat(exception).isEqualTo(new ExceptionInfo( FooServiceException.class.getName(), ImmutableList.of(newFieldInfo( FooServiceException.class, new FieldMetaData("stringVal", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING, false)))))); }
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"), TABLE_NAME((short)2, "tableName"), DB_NAME((short)3, "dbName"), OWNER((short)4, "owner"), CREATE_TIME((short)5, "createTime"), LAST_ACCESS_TIME((short)6, "lastAccessTime"), RETENTION((short)7, "retention"), SD((short)8, "sd"), PARTITION_KEYS((short)9, "partitionKeys"), PARAMETERS((short)10, "parameters"), VIEW_ORIGINAL_TEXT((short)11, "viewOriginalText"), VIEW_EXPANDED_TEXT((short)12, "viewExpandedText"), TABLE_TYPE((short)13, "tableType"), PRIVILEGES((short)14, "privileges"), TEMPORARY((short)15, "temporary"), REWRITE_ENABLED((short)16, "rewriteEnabled"), CREATION_METADATA((short)17, "creationMetadata"), CAT_NAME((short)18, "catName"), /** * * @see PrincipalType */ OWNER_TYPE((short)19, "ownerType"), WRITE_ID((short)20, "writeId"), IS_STATS_COMPLIANT((short)21, "isStatsCompliant"), COL_STATS((short)22, "colStats"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@Override @SuppressWarnings("unchecked") protected Object getRecordState(Object r, Schema s) { TFieldIdEnum[] fields = fieldCache.get(s); if (fields == null) { // cache miss fields = new TFieldIdEnum[s.getFields().size()]; Class c = r.getClass(); for (TFieldIdEnum f : FieldMetaData.getStructMetaDataMap((Class<? extends TBase>) c).keySet()) fields[s.getField(f.getFieldName()).pos()] = f; fieldCache.put(s, fields); // update cache } return fields; }
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
@SuppressWarnings("unchecked") final Map<TFieldIdEnum, FieldMetaData> metaDataMap = (Map<TFieldIdEnum, FieldMetaData>) FieldMetaData.getStructMetaDataMap(resultType);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
private static RpcRequest toRpcRequest(Class<?> serviceType, String method, TBase<?, ?> thriftArgs) { requireNonNull(thriftArgs, "thriftArgs"); // NB: The map returned by FieldMetaData.getStructMetaDataMap() is an EnumMap, // so the parameter ordering is preserved correctly during iteration. final Set<? extends TFieldIdEnum> fields = FieldMetaData.getStructMetaDataMap(thriftArgs.getClass()).keySet(); // Handle the case where the number of arguments is 0 or 1. final int numFields = fields.size(); switch (numFields) { case 0: return RpcRequest.of(serviceType, method); case 1: return RpcRequest.of(serviceType, method, ThriftFieldAccess.get(thriftArgs, fields.iterator().next())); } // Handle the case where the number of arguments is greater than 1. final List<Object> list = new ArrayList<>(numFields); for (TFieldIdEnum field : fields) { list.add(ThriftFieldAccess.get(thriftArgs, field)); } return RpcRequest.of(serviceType, method, list); }
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
FieldMetaData.getStructMetaDataMap(argsClass).values().stream() .map(fieldMetaData -> newFieldInfo(argsClass, fieldMetaData)) .collect(toImmutableList()); if (resultClass != null) { // Function isn't "oneway" function final Map<? extends TFieldIdEnum, FieldMetaData> resultMetaData = FieldMetaData.getStructMetaDataMap(resultClass);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
List<Field> fields = new ArrayList<>(); for (FieldMetaData f : FieldMetaData.getStructMetaDataMap((Class<? extends TBase>) c).values()) { Schema s = getSchema(f.valueMetaData); if (f.requirementType == TFieldRequirementType.OPTIONAL
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { QUERY((short)1, "query"), START((short)2, "start"), LENGTH((short)3, "length"), SCORING_FUNCTION_INDEX((short)4, "scoringFunctionIndex"), QUERY_VARIABLES((short)6, "query_variables"), FACETS_FILTER((short)7, "facetsFilter"), VARIABLE_RANGE_FILTERS((short)8, "variableRangeFilters"), FUNCTION_RANGE_FILTERS((short)9, "functionRangeFilters"), EXTRA_PARAMETERS((short)5, "extra_parameters"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // QUERY return QUERY; case 2: // START return START; case 3: // LENGTH
FieldMetaData.getStructMetaDataMap((Class<? extends TBase<?, ?>>) clazz);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
@VisibleForTesting static StructInfo newStructInfo(Class<? extends TBase<?, ?>> structClass) { final String name = structClass.getName(); final Map<?, FieldMetaData> metaDataMap = FieldMetaData.getStructMetaDataMap(structClass); final List<FieldInfo> fields = metaDataMap.values().stream() .map(fieldMetaData -> newFieldInfo(structClass, fieldMetaData)) .collect(Collectors.toList()); return new StructInfo(name, fields); }
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION
@VisibleForTesting static StructInfo newStructInfo(Class<? extends TBase<?, ?>> structClass) { final String name = structClass.getName(); final Map<?, FieldMetaData> metaDataMap = FieldMetaData.getStructMetaDataMap(structClass); final List<FieldInfo> fields = metaDataMap.values().stream() .map(fieldMetaData -> newFieldInfo(structClass, fieldMetaData)) .collect(Collectors.toList()); return new StructInfo(name, fields); }
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)1, "name"), MAX_VERSIONS((short)2, "maxVersions"), COMPRESSION((short)3, "compression"), IN_MEMORY((short)4, "inMemory"), BLOOM_FILTER_TYPE((short)5, "bloomFilterType"), BLOOM_FILTER_VECTOR_SIZE((short)6, "bloomFilterVectorSize"), BLOOM_FILTER_NB_HASHES((short)7, "bloomFilterNbHashes"), BLOCK_CACHE_ENABLED((short)8, "blockCacheEnabled"), TIME_TO_LIVE((short)9, "timeToLive"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // NAME return NAME; case 2: // MAX_VERSIONS return MAX_VERSIONS; case 3: // COMPRESSION