@API(value=MAINTAINED) public class RecordMetaData extends Object implements RecordMetaDataProvider
Message
s.
Each message Descriptors.Descriptor
corresponds to a RecordType
.
All message types in the database come from a single Descriptors.FileDescriptor
.
The Protobuf file must also define a union message type (conventionally named RecordTypeUnion
) with fields for
each of the possible record types.
When serializing, the record is put in the corresponding field and the whole saved as a byte string.
Then when deserializing, the returned record can be of any of the allowed types.
Meta-data can also define any number of secondary Index
es for record types.RecordMetaDataBuilder
Modifier | Constructor and Description |
---|---|
protected |
RecordMetaData(Descriptors.FileDescriptor recordsDescriptor,
Descriptors.Descriptor unionDescriptor,
Map<Descriptors.Descriptor,Descriptors.FieldDescriptor> unionFields,
Map<String,RecordType> recordTypes,
Map<String,SyntheticRecordType<?>> syntheticRecordTypes,
Map<String,Index> indexes,
Map<String,Index> universalIndexes,
List<FormerIndex> formerIndexes,
boolean splitLongRecords,
boolean storeRecordVersions,
int version,
long subspaceKeyCounter,
boolean usesSubspaceKeyCounter,
KeyExpression recordCountKey,
boolean usesLocalRecordsDescriptor) |
protected RecordMetaData(@Nonnull Descriptors.FileDescriptor recordsDescriptor, @Nonnull Descriptors.Descriptor unionDescriptor, @Nonnull Map<Descriptors.Descriptor,Descriptors.FieldDescriptor> unionFields, @Nonnull Map<String,RecordType> recordTypes, @Nonnull Map<String,SyntheticRecordType<?>> syntheticRecordTypes, @Nonnull Map<String,Index> indexes, @Nonnull Map<String,Index> universalIndexes, @Nonnull List<FormerIndex> formerIndexes, boolean splitLongRecords, boolean storeRecordVersions, int version, long subspaceKeyCounter, boolean usesSubspaceKeyCounter, @Nullable KeyExpression recordCountKey, boolean usesLocalRecordsDescriptor)
@Nonnull public static RecordMetaDataBuilder newBuilder()
RecordMetaDataBuilder
.@Nonnull public Descriptors.FileDescriptor getRecordsDescriptor()
@Nonnull public Descriptors.Descriptor getUnionDescriptor()
@Nonnull public Descriptors.FieldDescriptor getUnionFieldForRecordType(@Nonnull RecordType recordType)
@Nonnull public Map<String,RecordType> getRecordTypes()
@Nonnull public RecordType getRecordType(@Nonnull String name)
@Nonnull public RecordType getRecordTypeForDescriptor(@Nonnull Descriptors.Descriptor descriptor)
@Nonnull @API(value=EXPERIMENTAL) public Map<String,SyntheticRecordType<?>> getSyntheticRecordTypes()
@Nonnull @API(value=EXPERIMENTAL) public SyntheticRecordType<?> getSyntheticRecordType(@Nonnull String name)
@Nonnull @API(value=EXPERIMENTAL) public SyntheticRecordType<?> getSyntheticRecordTypeFromRecordTypeKey(@Nonnull Object recordTypeKey)
public RecordType getIndexableRecordType(@Nonnull String name)
name
- the name of the record typepublic List<FormerIndex> getFormerIndexes()
public boolean isSplitLongRecords()
public boolean isStoreRecordVersions()
public int getVersion()
public long getSubspaceKeyCounter()
RecordMetaDataBuilder.enableCounterBasedSubspaceKeys()
public boolean usesSubspaceKeyCounter()
true
if the subspace key counter is usedRecordMetaDataBuilder.enableCounterBasedSubspaceKeys()
public List<FormerIndex> getFormerIndexesSince(int version)
public Map<Index,List<RecordType>> getIndexesSince(int version)
@Nonnull public Collection<RecordType> recordTypesForIndex(@Nonnull Index index)
@Nullable @API(value=DEPRECATED) public KeyExpression getRecordCountKey()
public boolean primaryKeyHasRecordTypePrefix()
RecordType.primaryKeyHasRecordTypePrefix()
.
If so, records are strictly partitioned by record type.true
if every record type has a record type prefix on the primary key@Nonnull public RecordMetaData getRecordMetaData()
RecordMetaData
instance.getRecordMetaData
in interface RecordMetaDataProvider
RecordMetaData
instance@Nonnull public static RecordMetaData build(@Nonnull Descriptors.FileDescriptor descriptor)
@Nonnull public static RecordMetaData build(@Nonnull RecordMetaDataProto.MetaData proto)
proto
- the serialized proto message of the RecordMetaData
RecordMetaData
object@Nonnull public RecordMetaDataProto.MetaData toProto()
MetaData
proto message. By default, it includes all of the
dependencies except TupleFieldsProto
, RecordMetaDataOptionsProto
and RecordMetaDataProto
.
Note that if this record meta-data object was created with a local file descriptor, then serializing the meta-data to a proto message is disallowed. This is because setting a local file descriptor can change the meta-data in ways that would change its serialization, but it also will not update the meta-data version. This means that if the meta-data were then saved to disk, existing clients would not be informed that the meta-data had been updated.
MetaData
proto messageKeyExpression.SerializationException
- on any serialization failuresMetaDataException
- if this RecordMetaData
was initialized with a
local file descriptor@Nonnull public RecordMetaDataProto.MetaData toProto(@Nullable Descriptors.FileDescriptor[] excludedDependencies) throws KeyExpression.SerializationException
MetaData
proto message. This operates like
toProto()
except that any dependency in the excluded list is not included in the
serialized proto message. If the list is set to null
, then all dependencies will be serialized
to the proto message including those that are execluded by default.excludedDependencies
- a list of dependencies not to include in the serialized protoMetaData
proto messageKeyExpression.SerializationException
- on any serialization failuresMetaDataException
- if this RecordMetaData
was initialized with a
local file descriptortoProto()