Search in sources :

Example 1 with PropertyTypes

use of jetbrains.exodus.entitystore.tables.PropertyTypes in project xodus by JetBrains.

the class PropertyCustomTypeTests method testSetGet.

public void testSetGet() {
    final PersistentEntityStoreImpl store = getEntityStore();
    final PropertyTypes propertyTypes = store.getPropertyTypes();
    final PersistentStoreTransaction txn = getStoreTransaction();
    final ComparablePair<Integer, String> sample = new ComparablePair<>(0, "");
    final ComparablePairBinding customBinding = new ComparablePairBinding(propertyTypes, sample);
    // REGISTER CUSTOM TYPE HERE
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
    Assert.assertTrue(txn.flush());
    final PersistentEntity e = txn.newEntity("CustomType");
    final int count = 1000;
    for (int i = 0; i < count; ++i) {
        e.setProperty(Integer.toString(i), new ComparablePair(i, Integer.toString(i)));
    }
    Assert.assertTrue(txn.flush());
    for (int i = 0; i < count; ++i) {
        final Comparable property = e.getProperty(Integer.toString(i));
        Assert.assertNotNull(property);
        Assert.assertEquals(property, new ComparablePair(i, Integer.toString(i)));
    }
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes) ComparablePairBinding(jetbrains.exodus.entitystore.custom.ComparablePairBinding) ComparablePair(jetbrains.exodus.entitystore.custom.ComparablePair)

Example 2 with PropertyTypes

use of jetbrains.exodus.entitystore.tables.PropertyTypes in project xodus by JetBrains.

the class PropertyCustomTypeTests method testRegisterTwiceWithoutReinit.

@TestFor(issue = "XD-603")
public void testRegisterTwiceWithoutReinit() {
    PersistentEntityStoreImpl store = getEntityStore();
    PropertyTypes propertyTypes = store.getPropertyTypes();
    PersistentStoreTransaction txn = getStoreTransaction();
    ComparablePair<Integer, String> sample = new ComparablePair<>(0, "");
    ComparablePairBinding customBinding = new ComparablePairBinding(propertyTypes, sample);
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
    Assert.assertTrue(txn.flush());
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes) ComparablePairBinding(jetbrains.exodus.entitystore.custom.ComparablePairBinding) ComparablePair(jetbrains.exodus.entitystore.custom.ComparablePair) TestFor(jetbrains.exodus.TestFor)

Example 3 with PropertyTypes

use of jetbrains.exodus.entitystore.tables.PropertyTypes in project xodus by JetBrains.

the class PropertyCustomTypeTests method testFind.

public void testFind() throws InterruptedException {
    final PersistentEntityStoreImpl store = getEntityStore();
    final PropertyTypes propertyTypes = store.getPropertyTypes();
    final PersistentStoreTransaction txn = getStoreTransaction();
    final ComparablePair<Integer, String> sample = new ComparablePair<>(0, "");
    final ComparablePairBinding customBinding = new ComparablePairBinding(propertyTypes, sample);
    // REGISTER CUSTOM TYPE HERE
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
    Assert.assertTrue(txn.flush());
    final PersistentEntity e = txn.newEntity("CustomType");
    final int count = 100;
    for (int i = 0; i < count; ++i) {
        e.setProperty(Integer.toString(i), new ComparablePair(i, Integer.toString(i)));
    }
    Assert.assertTrue(txn.flush());
    for (int i = 0; i < count; ++i) {
        final EntityIterable it = txn.find("CustomType", Integer.toString(i), new ComparablePair(i, Integer.toString(i)));
        Assert.assertFalse(it.isEmpty());
        Assert.assertEquals(e, it.getFirst());
        Assert.assertTrue(txn.find("CustomType", Integer.toString(i), new ComparablePair(i, Integer.toString(i + 1))).isEmpty());
        Assert.assertTrue(txn.find("CustomType", Integer.toString(i), new ComparablePair(i + 1, Integer.toString(i))).isEmpty());
        Assert.assertTrue(txn.find("CustomType", Integer.toString(i + 1), new ComparablePair(i, Integer.toString(i))).isEmpty());
        Thread.sleep(1);
    }
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes) ComparablePairBinding(jetbrains.exodus.entitystore.custom.ComparablePairBinding) ComparablePair(jetbrains.exodus.entitystore.custom.ComparablePair)

Example 4 with PropertyTypes

use of jetbrains.exodus.entitystore.tables.PropertyTypes in project xodus by JetBrains.

the class PropertyCustomTypeTests method testRegisterTwice.

public void testRegisterTwice() throws Exception {
    PersistentEntityStoreImpl store = getEntityStore();
    PropertyTypes propertyTypes = store.getPropertyTypes();
    PersistentStoreTransaction txn = getStoreTransaction();
    ComparablePair<Integer, String> sample = new ComparablePair<>(0, "");
    ComparablePairBinding customBinding = new ComparablePairBinding(propertyTypes, sample);
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
    reinit();
    store = getEntityStore();
    propertyTypes = store.getPropertyTypes();
    txn = getStoreTransaction();
    sample = new ComparablePair<>(0, "");
    customBinding = new ComparablePairBinding(propertyTypes, sample);
    store.registerCustomPropertyType(txn, sample.getClass(), customBinding);
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes) ComparablePairBinding(jetbrains.exodus.entitystore.custom.ComparablePairBinding) ComparablePair(jetbrains.exodus.entitystore.custom.ComparablePair)

Example 5 with PropertyTypes

use of jetbrains.exodus.entitystore.tables.PropertyTypes in project xodus by JetBrains.

the class UniqueKeyIndicesEngine method deleteUniqueKey.

public void deleteUniqueKey(@NotNull final PersistentStoreTransaction txn, @NotNull final Index index, @NotNull final List<Comparable> propValues) {
    final PropertyTypes propertyTypes = persistentStore.getPropertyTypes();
    final int propCount = index.getFields().size();
    if (propCount != propValues.size()) {
        throw new IllegalArgumentException("Number of fields differs from the number of property values");
    }
    getUniqueKeyIndex(txn, index).delete(txn.getEnvironmentTransaction(), propertyTypes.dataArrayToEntry(propValues.toArray(new Comparable[propCount])));
}
Also used : PropertyTypes(jetbrains.exodus.entitystore.tables.PropertyTypes)

Aggregations

PropertyTypes (jetbrains.exodus.entitystore.tables.PropertyTypes)7 ComparablePair (jetbrains.exodus.entitystore.custom.ComparablePair)4 ComparablePairBinding (jetbrains.exodus.entitystore.custom.ComparablePairBinding)4 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)1 ByteIterable (jetbrains.exodus.ByteIterable)1 TestFor (jetbrains.exodus.TestFor)1 SingleColumnTable (jetbrains.exodus.entitystore.tables.SingleColumnTable)1 Environment (jetbrains.exodus.env.Environment)1 Store (jetbrains.exodus.env.Store)1 IndexField (jetbrains.exodus.query.metadata.IndexField)1