FDBMetaDataStore extends FDBStoreBase implements RecordMetaDataProvider { @API(API.Status.MAINTAINED) public void updateRecords(@Nonnull Descriptors.FileDescriptor recordsDescriptor) { context.asyncToSync(FDBStoreTimer.Waits.WAIT_UPDATE_RECORDS_DESCRIPTOR, updateRecordsAsync(recordsDescriptor)); } @API(API.Status.UNSTABLE)  FDBMetaDataStore(@Nonnull FDBRecordContext context, @Nonnull Subspace subspace,
                            @Nullable MetaDataCache cache);  FDBMetaDataStore(@Nonnull FDBRecordContext context, @Nonnull KeySpacePath path); @SpotBugsSuppressWarnings("EI_EXPOSE_REP2") void setDependencies(@Nonnull Descriptors.FileDescriptor[] dependencies); @Nullable Descriptors.FileDescriptor getLocalFileDescriptor(); void setLocalFileDescriptor(@Nullable Descriptors.FileDescriptor localFileDescriptor); @Nonnull MetaDataEvolutionValidator getEvolutionValidator(); void setEvolutionValidator(@Nonnull MetaDataEvolutionValidator evolutionValidator); void setExtensionRegistry(@Nullable ExtensionRegistry extensionRegistry); void setMaintainHistory(boolean maintainHistory); CompletableFuture<RecordMetaDataProto.MetaData> loadAndSetCurrent(boolean checkCache, int currentVersion); CompletableFuture<RecordMetaData> loadVersion(int version); @Nonnull CompletableFuture<Void> saveAndSetCurrent(@Nonnull RecordMetaDataProto.MetaData metaDataProto); CompletableFuture<RecordMetaData> getRecordMetaDataAsync(boolean errorIfMissing); @Nonnull CompletableFuture<Void> preloadMetaData(@Nullable RecordMetaDataProvider metaDataProvider); @Nonnull @Override RecordMetaData getRecordMetaData(); @API(API.Status.MAINTAINED) void saveRecordMetaData(@Nonnull Descriptors.FileDescriptor fileDescriptor); void saveRecordMetaData(@Nonnull RecordMetaDataProvider metaDataProvider); void saveRecordMetaData(@Nonnull RecordMetaDataProto.MetaData metaDataProto); @API(API.Status.MAINTAINED) CompletableFuture<Void> saveRecordMetaDataAsync(@Nonnull Descriptors.FileDescriptor fileDescriptor); void addIndex(@Nonnull String recordType, @Nonnull String indexName, @Nonnull String fieldName); void addIndex(@Nonnull String recordType, @Nonnull String indexName, @Nonnull KeyExpression indexExpression); void addIndex(@Nonnull String recordType, @Nonnull Index index); @Nonnull CompletableFuture<Void> addIndexAsync(@Nonnull String recordType, @Nonnull String indexName, @Nonnull String fieldName); @Nonnull CompletableFuture<Void> addIndexAsync(@Nonnull String recordType, @Nonnull String indexName,
                                                 @Nonnull KeyExpression indexExpression); @Nonnull CompletableFuture<Void> addIndexAsync(@Nonnull String recordType, @Nonnull Index index); void addMultiTypeIndex(@Nullable List<String> recordTypes, @Nonnull Index index); @Nonnull CompletableFuture<Void> addMultiTypeIndexAsync(@Nullable List<String> recordTypes, @Nonnull Index index); void addUniversalIndex(@Nonnull Index index); @Nonnull CompletableFuture<Void> addUniversalIndexAsync(@Nonnull Index index); void dropIndex(@Nonnull String indexName); @Nonnull CompletableFuture<Void> dropIndexAsync(@Nonnull String indexName); @API(API.Status.MAINTAINED) void updateRecords(@Nonnull Descriptors.FileDescriptor recordsDescriptor); @Nonnull @API(API.Status.MAINTAINED) CompletableFuture<Void> updateRecordsAsync(@Nonnull Descriptors.FileDescriptor recordsDescriptor); void mutateMetaData(@Nonnull Consumer<RecordMetaDataProto.MetaData.Builder> mutateMetaDataProto); void mutateMetaData(@Nonnull Consumer<RecordMetaDataProto.MetaData.Builder> mutateMetaDataProto,
                               @Nullable Consumer<RecordMetaDataBuilder> mutateRecordMetaDataBuilder); @Nonnull CompletableFuture<Void> mutateMetaDataAsync(@Nonnull Consumer<RecordMetaDataProto.MetaData.Builder> mutateMetaDataProto); @Nonnull CompletableFuture<Void> mutateMetaDataAsync(@Nonnull Consumer<RecordMetaDataProto.MetaData.Builder> mutateMetaDataProto,
                                                       @Nullable Consumer<RecordMetaDataBuilder> mutateRecordMetaDataBuilder); void updateStoreRecordVersions(boolean storeRecordVersions); @Nonnull CompletableFuture<Void> updateStoreRecordVersionsAsync(boolean storeRecordVersions); void enableSplitLongRecords(); @Nonnull CompletableFuture<Void> enableSplitLongRecordsAsync(); @Nullable @VisibleForTesting MetaDataCache getCache(); static final Tuple CURRENT_KEY; static final Tuple HISTORY_KEY_PREFIX; static final Tuple OLD_FORMAT_KEY; }
@Test public void updateRecords() { try (FDBRecordContext context = fdb.openContext()) { openMetaDataStore(context); RecordMetaData metaData = RecordMetaData.build(TestRecords1Proto.getDescriptor()); metaDataStore.saveRecordMetaData(metaData); context.commit(); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MySimpleRecord")); } try (FDBRecordContext context = fdb.openContext()) { openMetaDataStore(context); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MySimpleRecord")); metaDataStore.updateRecords(TestRecords1EvolvedProto.getDescriptor()); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MySimpleRecord")); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MyOtherRecord")); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("AnotherRecord")); context.commit(); } try (FDBRecordContext context = fdb.openContext()) { openMetaDataStore(context); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MySimpleRecord")); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("MyOtherRecord")); assertNotNull(metaDataStore.getRecordMetaData().getRecordType("AnotherRecord")); context.commit(); } }