use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method changeFormerIndexName.
@Test
public void changeFormerIndexName() {
RecordMetaDataBuilder metaData1Builder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaData1Builder.removeIndex("MySimpleRecord$str_value_indexed");
RecordMetaData metaData1 = metaData1Builder.getRecordMetaData();
RecordMetaDataProto.MetaData.Builder metaData2ProtoBuilder = metaData1.toProto().toBuilder().setVersion(metaData1.getVersion() + 1);
metaData2ProtoBuilder.setFormerIndexes(0, metaData2ProtoBuilder.getFormerIndexesBuilder(0).setFormerName("some_other_name"));
RecordMetaData metaData2 = RecordMetaData.build(metaData2ProtoBuilder.build());
assertInvalid("name of former index differs from prior version", metaData1, metaData2);
metaData2ProtoBuilder.setFormerIndexes(0, metaData2ProtoBuilder.getFormerIndexesBuilder(0).clearFormerName());
metaData2 = RecordMetaData.build(metaData2ProtoBuilder.build());
assertInvalid("name of former index differs from prior version", metaData1, metaData2);
// For existing former indexes, changing the name is not allowed even with the laxer validation option
MetaDataEvolutionValidator laxerValidator = MetaDataEvolutionValidator.newBuilder().setAllowMissingFormerIndexNames(true).build();
assertInvalid("name of former index differs from prior version", laxerValidator, metaData1, metaData2);
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataProtoTest method metadataProtoSimple.
@Test
public void metadataProtoSimple() throws KeyExpression.DeserializationException, KeyExpression.SerializationException {
List<Descriptors.FileDescriptor> files = Arrays.asList(TestRecords1Proto.getDescriptor(), TestRecords2Proto.getDescriptor(), TestRecords4Proto.getDescriptor(), TestRecords5Proto.getDescriptor(), TestRecords6Proto.getDescriptor(), TestRecords7Proto.getDescriptor(), TestRecordsChained1Proto.getDescriptor(), TestRecordsChained2Proto.getDescriptor(), TestRecordsImportProto.getDescriptor(), TestRecordsImportFlatProto.getDescriptor(), TestRecordsMultiProto.getDescriptor(), TestRecordsParentChildRelationshipProto.getDescriptor(), TestRecordsWithUnionProto.getDescriptor(), TestRecordsIndexCompatProto.getDescriptor());
for (int i = 0; i < files.size(); i++) {
Descriptors.FileDescriptor file = files.get(i);
RecordMetaData metaData = RecordMetaData.build(file);
RecordMetaDataBuilder builder = RecordMetaData.newBuilder();
builder.addDependencies(BASE_DEPENDENCIES);
RecordMetaData metaDataRedone = builder.setRecords(metaData.toProto()).getRecordMetaData();
verifyEquals(metaData, metaDataRedone);
}
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class FDBRecordStorePerformanceTest method createMetaData.
public void createMetaData() {
FDBDatabaseFactory factory = FDBDatabaseFactory.instance();
factory.setDirectoryCacheSize(databaseParameters.pathCache);
fdb = factory.getDatabase();
RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaDataBuilder.setSplitLongRecords(databaseParameters.splitRecords);
if (databaseParameters.stringSize > 100) {
metaDataBuilder.removeIndex("MySimpleRecord$str_value_indexed");
}
if (databaseParameters.rankIndex) {
metaDataBuilder.removeIndex("MySimpleRecord$num_value_unique");
metaDataBuilder.addIndex("MySimpleRecord", new Index("num_value_unique_rank", Key.Expressions.field("num_value_unique").ungrouped(), EmptyKeyExpression.EMPTY, IndexTypes.RANK, Collections.emptyMap()));
}
metaData = metaDataBuilder.getRecordMetaData();
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class FDBRecordStoreTestBase method openNewUnionRecordStore.
@Nonnull
protected FDBRecordStore openNewUnionRecordStore(FDBRecordContext context) {
RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecordsWithUnionProto.getDescriptor());
metaDataBuilder.addUniversalIndex(new Index("versions", field("etag")));
metaDataBuilder.addMultiTypeIndex(// partial_versions explicitly does not include MySimpleRecord3
Arrays.asList(metaDataBuilder.getRecordType("MySimpleRecord"), metaDataBuilder.getRecordType("MySimpleRecord2")), new Index("partial_versions", field("etag")));
metaDataBuilder.addUniversalIndex(new Index("cross_versions", field("nested").nest("etag")));
metaDataBuilder.addMultiTypeIndex(Arrays.asList(metaDataBuilder.getRecordType("MySimpleRecord"), metaDataBuilder.getRecordType("MySimpleRecord2"), metaDataBuilder.getRecordType("MySimpleRecord3")), new Index("partial_nested_versions", concat(field("nested").nest(field("etag")), field("etag"))));
createOrOpenRecordStore(context, metaDataBuilder.getRecordMetaData());
return recordStore;
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method removeFormerIndex.
// Former index tests
@Test
public void removeFormerIndex() {
RecordMetaDataBuilder metaData1Builder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaData1Builder.removeIndex("MySimpleRecord$str_value_indexed");
RecordMetaData metaData1 = metaData1Builder.getRecordMetaData();
RecordMetaData metaData2 = RecordMetaData.build(metaData1.toProto().toBuilder().setVersion(metaData1.getVersion() + 1).clearFormerIndexes().build());
assertInvalid("former index removed", metaData1, metaData2);
}
Aggregations