Search in sources :

Example 36 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method duplicateIntegralFormerSubspaceKey.

@Test
public void duplicateIntegralFormerSubspaceKey() {
    List<Object> alternateKeys = Arrays.asList((byte) 42, (short) 42, 42);
    for (Object alternateKey : alternateKeys) {
        RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
        metaData.getIndex("MySimpleRecord$str_value_indexed").setSubspaceKey(42L);
        metaData.removeIndex("MySimpleRecord$str_value_indexed");
        metaData.getIndex("MySimpleRecord$num_value_3_indexed").setSubspaceKey(alternateKey);
        metaData.removeIndex("MySimpleRecord$num_value_3_indexed");
        assertInvalid("Same subspace key 42 used by two former indexes", metaData);
    }
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 37 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method primaryKeyRepeated.

@Test
public void primaryKeyRepeated() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
    metaData.getRecordType("MySimpleRecord").setPrimaryKey(Key.Expressions.field("repeater", KeyExpression.FanType.FanOut));
    assertInvalid("Primary key for MySimpleRecord can generate more than one entry", metaData);
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 38 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class MetaDataValidatorTest method duplicateIntegralRecordTypeKey.

@Test
public void duplicateIntegralRecordTypeKey() {
    List<Object> alternateKeys = Arrays.asList((byte) 42, (short) 42, 42, BigInteger.valueOf(42L));
    for (Object alternateKey : alternateKeys) {
        RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
        metaData.getRecordType("MySimpleRecord").setRecordTypeKey(42L);
        metaData.getRecordType("MyOtherRecord").setRecordTypeKey(alternateKey);
        assertInvalid("Same record type key 42 used by both", metaData);
    }
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder) Test(org.junit.jupiter.api.Test)

Example 39 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class RecordMetaDataBuilderTest method createBuilder.

private RecordMetaDataBuilder createBuilder(@Nonnull Descriptors.FileDescriptor fileDescriptor, boolean useCounterBasedSubspaceKey) {
    RecordMetaDataBuilder builder = RecordMetaData.newBuilder();
    if (useCounterBasedSubspaceKey) {
        builder.enableCounterBasedSubspaceKeys();
    }
    builder.setRecords(fileDescriptor);
    return builder;
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder)

Example 40 with RecordMetaDataBuilder

use of com.apple.foundationdb.record.RecordMetaDataBuilder in project fdb-record-layer by FoundationDB.

the class FDBRecordStoreNullQueryTest method proto3MetaData.

protected static RecordMetaData proto3MetaData() {
    RecordMetaDataBuilder metaData = RecordMetaData.newBuilder().setRecords(TestRecordsNulls3Proto.getDescriptor());
    metaData.addIndex("MyNullRecord", "int_value");
    metaData.addIndex("MyNullRecord", "string_value");
    return metaData.getRecordMetaData();
}
Also used : RecordMetaDataBuilder(com.apple.foundationdb.record.RecordMetaDataBuilder)

Aggregations

RecordMetaDataBuilder (com.apple.foundationdb.record.RecordMetaDataBuilder)150 Test (org.junit.jupiter.api.Test)91 RecordMetaData (com.apple.foundationdb.record.RecordMetaData)69 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 Nonnull (javax.annotation.Nonnull)22 Index (com.apple.foundationdb.record.metadata.Index)21 Descriptors (com.google.protobuf.Descriptors)15 TestRecords1Proto (com.apple.foundationdb.record.TestRecords1Proto)14 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)14 RecordMetaDataProto (com.apple.foundationdb.record.RecordMetaDataProto)13 ByteString (com.google.protobuf.ByteString)13 Tuple (com.apple.foundationdb.tuple.Tuple)12 Collections (java.util.Collections)12 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)11 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)11 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)11 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)11 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)11 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)10 BooleanSource (com.apple.test.BooleanSource)10