Class RecordType
- java.lang.Object
-
- com.apple.foundationdb.record.metadata.RecordType
-
- All Implemented Interfaces:
RecordTypeOrBuilder
,RecordMetaDataProvider
- Direct Known Subclasses:
SyntheticRecordType
@API(MAINTAINED) public class RecordType extends Object implements RecordTypeOrBuilder, RecordMetaDataProvider
Record type meta-data. A record type corresponds to a ProtobufDescriptors.Descriptor
and specifies a primary key expression and any number of secondaryIndex
es.
-
-
Constructor Summary
Constructors Constructor Description RecordType(RecordMetaData metaData, Descriptors.Descriptor descriptor, KeyExpression primaryKey, List<Index> indexes, List<Index> multiTypeIndexes, Integer sinceVersion, Object recordTypeKey)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Index>
getAllIndexes()
Gets the list of all indexes that apply for this type.Descriptors.Descriptor
getDescriptor()
Get the descriptor of the underlying message type.Object
getExplicitRecordTypeKey()
Get any explicit record type key value.List<Index>
getIndexes()
Get the list of indexes that are on this record and only this record.List<Index>
getMultiTypeIndexes()
The Indexes that this record type is on that also contain other record types.String
getName()
Get the name of the record type.KeyExpression
getPrimaryKey()
Gets the primary key expression for this record type.RecordMetaData
getRecordMetaData()
Get the meta-data of which this record type is a part.Object
getRecordTypeKey()
Gets theTuple
element value that will be used byRecordTypeKeyExpression
for this record type.Tuple
getRecordTypeKeyTuple()
Get aTuple
containing only the record type key.Integer
getSinceVersion()
Gets a metadata version, which shows when this record type got introduced in the metadata.boolean
hasExplicitRecordTypeKey()
Get whether this record type sets an explicit value forgetRecordTypeKey()
.boolean
isSynthetic()
Get whether this record type represents synthetic records.boolean
primaryKeyHasRecordTypePrefix()
Determine whether this record type has aRecordTypeKeyExpression
prefix in the primary key.String
toString()
-
-
-
Method Detail
-
getName
@Nonnull public String getName()
Description copied from interface:RecordTypeOrBuilder
Get the name of the record type. This is the same as the name of the underlying message type.- Specified by:
getName
in interfaceRecordTypeOrBuilder
- Returns:
- the message type name
-
getDescriptor
@Nonnull public Descriptors.Descriptor getDescriptor()
Description copied from interface:RecordTypeOrBuilder
Get the descriptor of the underlying message type. This specifies what fields the record will have and what their types should be.- Specified by:
getDescriptor
in interfaceRecordTypeOrBuilder
- Returns:
- the message type descriptor
-
getIndexes
@Nonnull public List<Index> getIndexes()
Description copied from interface:RecordTypeOrBuilder
Get the list of indexes that are on this record and only this record. This does not include indexes that are on multiple types even if one of them is on this type.- Specified by:
getIndexes
in interfaceRecordTypeOrBuilder
- Returns:
- the list of indexes only on this type
-
getMultiTypeIndexes
@Nonnull public List<Index> getMultiTypeIndexes()
The Indexes that this record type is on that also contain other record types. This does not include indexes that cover all record types- Specified by:
getMultiTypeIndexes
in interfaceRecordTypeOrBuilder
- Returns:
- a list of all indexes that include this record type along with other types.
-
getAllIndexes
@Nonnull public List<Index> getAllIndexes()
Gets the list of all indexes that apply for this type.- single type indexes defined on this type
- multi-type indexes including this type
- universal indexes
- Returns:
- the list of indexes for this type
- See Also:
getIndexes()
,getMultiTypeIndexes()
,RecordMetaData.getUniversalIndexes()
-
getPrimaryKey
@Nonnull public KeyExpression getPrimaryKey()
Description copied from interface:RecordTypeOrBuilder
Gets the primary key expression for this record type. Records of this type are inserted based on the value of this key expression when evaluated on the record.- Specified by:
getPrimaryKey
in interfaceRecordTypeOrBuilder
- Returns:
- the primary key expression for this record type
-
getSinceVersion
@Nullable public Integer getSinceVersion()
Description copied from interface:RecordTypeOrBuilder
Gets a metadata version, which shows when this record type got introduced in the metadata. This information is used to skip index rebuild for indices on new record types.- Specified by:
getSinceVersion
in interfaceRecordTypeOrBuilder
- Returns:
- metadata version when this type is introduced (
null
if this information is not available)
-
hasExplicitRecordTypeKey
public boolean hasExplicitRecordTypeKey()
Get whether this record type sets an explicit value forgetRecordTypeKey()
. If there is no explicit value, then#getRecordTypeKey
will use the union message field number.- Returns:
- true if there is an explicit record type key value
-
getExplicitRecordTypeKey
@Nullable public Object getExplicitRecordTypeKey()
Get any explicit record type key value.- Returns:
- the explicit record type key value or
null
ifgetRecordTypeKey()
would return a union field number
-
getRecordTypeKey
@Nonnull public Object getRecordTypeKey()
Gets theTuple
element value that will be used byRecordTypeKeyExpression
for this record type. The value should be unique among record types and stable in the face of meta-data changes.This value is not guaranteed to be
Tuple
-encodable. It is guaranteed that the value returned has implementedequals()
andhashCode()
so that the value can be used in hash-based data structures likeHashMap
s orHashSet
s. If the value is needed to construct aTuple
orSubspace
, one should callgetRecordTypeKeyTuple()
.- Specified by:
getRecordTypeKey
in interfaceRecordTypeOrBuilder
- Returns:
- stable and unique key for the record type
-
getRecordTypeKeyTuple
@Nonnull public Tuple getRecordTypeKeyTuple()
Get aTuple
containing only the record type key. The record type key is not generally required to beTuple
-encodable, so for some record type keys, the following might throw an error:Tuple.from(recordType.getRecordTypeKey()).pack()
This function will first convert the record type key into a type that the
Tuple
layer can encode before returning theTuple
to the user. This method should therefore be preferred over callinggetRecordTypeKey()
when this key is about to be used to read or write data from the database.- Returns:
- a
Tuple
containing the record type key
-
primaryKeyHasRecordTypePrefix
public boolean primaryKeyHasRecordTypePrefix()
Determine whether this record type has aRecordTypeKeyExpression
prefix in the primary key.- Returns:
true
if start of the primary key is the unique record type key
-
getRecordMetaData
@Nonnull public RecordMetaData getRecordMetaData()
Get the meta-data of which this record type is a part.- Specified by:
getRecordMetaData
in interfaceRecordMetaDataProvider
- Returns:
- owning meta-data
-
isSynthetic
@API(EXPERIMENTAL) public boolean isSynthetic()
Get whether this record type represents synthetic records. A synthetic record is one that is not actually stored, although it can may be indexed.- Returns:
true
if this record type represents synthetic records,false
if it represents records that are actually stored
-
-