Package com.google.cloud.bigtable.common
Class Type.SchemalessStruct
java.lang.Object
com.google.cloud.bigtable.common.Type.SchemalessStruct
- All Implemented Interfaces:
Type,SqlType<Struct>,SqlType.Struct,Serializable
- Enclosing interface:
- Type
This is a special version of struct that is intended to only be used in the
StructReader getters that require types. We don't
want users to need to specify the struct schema when the schema will be validated on calls to
StructReader methods on the struct.
Any attempts to interact with the schema will throw an exception.
For example the historical map data type uses this as follows:
Map<ByteString, List<Struct>> historicalMap =
resultSet.getMap(
"cf",
SqlType.mapOf(SqlType.bytes(), SqlType.arrayOf(SqlType.struct())));
Struct struct = historicalMap.get("column").get(0);
// Struct schema will be validated here so there's no need for users to pass the schema to getMap above
ByteString value = struct.getBytes("value");
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.cloud.bigtable.data.v2.models.sql.SqlType
SqlType.Array<Elem>, SqlType.Code, SqlType.Map<K,V>, SqlType.Struct Nested classes/interfaces inherited from interface com.google.cloud.bigtable.data.v2.models.sql.SqlType.Struct
SqlType.Struct.FieldNested classes/interfaces inherited from interface com.google.cloud.bigtable.common.Type
Type.Array<Elem>, Type.Bool, Type.Bytes, Type.Date, Type.DefaultInstances, Type.Float32, Type.Float64, Type.Int64, Type.Map<K,V>, Type.SchemalessStruct, Type.String, Type.StructWithSchema, Type.Timestamp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Type.SchemalessStructcreate()getCode()intgetColumnIndex(String fieldName) SqlType<?>getType(int fieldIndex) SqlType<?>toString()
-
Constructor Details
-
SchemalessStruct
public SchemalessStruct()
-
-
Method Details
-
create
-
getCode
- Specified by:
getCodein interfaceSqlType<Struct>- Returns:
SqlType.Codeenum for this type
-
getFields
- Specified by:
getFieldsin interfaceSqlType.Struct- Returns:
- the ordered list of
SqlType.Struct.Fields for the struct
-
getType
- Specified by:
getTypein interfaceSqlType.Struct- Parameters:
fieldIndex- index of the field- Returns:
- the
SqlTypeof the field at the given index
-
getType
- Specified by:
getTypein interfaceSqlType.Struct- Parameters:
fieldName- name of the field- Returns:
- the
SqlTypeof the field with the given name
-
getColumnIndex
- Specified by:
getColumnIndexin interfaceSqlType.Struct- Parameters:
fieldName- name of the field- Returns:
- the field index of the field with the given name
-
toString
-