use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataValidatorTest method badSinceVersion.
@Test
public void badSinceVersion() {
RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaData.getRecordType("MySimpleRecord").setSinceVersion(metaData.getVersion() + 1);
assertInvalid("Record type MySimpleRecord has since version of " + (metaData.getVersion() + 1) + " which is greater than the meta-data version " + metaData.getVersion(), metaData);
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataValidatorTest method badIndexType.
@Test
public void badIndexType() {
RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords4Proto.getDescriptor());
metaData.addIndex("RestaurantReviewer", "stats");
assertInvalid(Query.InvalidExpressionException.class, "stats is a nested message, but accessed as a scalar", metaData);
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataValidatorTest method badPrimaryKeyField.
@Test
public void badPrimaryKeyField() {
RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaData.getRecordType("MySimpleRecord").setPrimaryKey(Key.Expressions.field("no_such_field"));
assertInvalid(KeyExpression.InvalidExpressionException.class, "Descriptor MySimpleRecord does not have field: no_such_field", metaData);
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataValidatorTest method badFormerIndexAddedVersion.
@Test
public void badFormerIndexAddedVersion() {
RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(RecordMetaData.build(TestRecords1Proto.getDescriptor()).toProto().toBuilder().addFormerIndexes(RecordMetaDataProto.FormerIndex.newBuilder().setSubspaceKey(ByteString.copyFrom(Tuple.from("dropped_index").pack())).setAddedVersion(10).setRemovedVersion(10)).build());
assertInvalid("Former index has added version 10 which is greater than the meta-data version " + metaData.getVersion(), metaData);
RecordMetaDataProto.MetaData.Builder protoBuilder = metaData.build(false).toProto().toBuilder();
protoBuilder.getFormerIndexesBuilder(0).setFormerName("dropped_index");
metaData = RecordMetaData.newBuilder().setRecords(protoBuilder.build());
assertInvalid("Former index dropped_index has added version 10 which is greater than the meta-data version " + metaData.getVersion(), metaData);
}
use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.
the class MetaDataValidatorTest method duplicateFormerAndCurrentSubspaceKey.
@Test
public void duplicateFormerAndCurrentSubspaceKey() {
RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaData.getIndex("MySimpleRecord$str_value_indexed").setSubspaceKey("same");
metaData.removeIndex("MySimpleRecord$str_value_indexed");
metaData.getIndex("MySimpleRecord$num_value_3_indexed").setSubspaceKey("same");
assertInvalid("Same subspace key same used by index MySimpleRecord$num_value_3_indexed and former index MySimpleRecord$str_value_indexed", metaData);
RecordMetaDataProto.MetaData.Builder protoBuilder = metaData.build(false).toProto().toBuilder();
protoBuilder.getFormerIndexesBuilder(0).clearFormerName();
metaData = RecordMetaData.newBuilder().setRecords(protoBuilder.build());
assertInvalid("Same subspace key same used by index MySimpleRecord$num_value_3_indexed and former index", metaData);
}
Aggregations