Search in sources :

Example 1 with PersistentStoreTransaction

use of jetbrains.exodus.entitystore.PersistentStoreTransaction in project xodus by JetBrains.

the class LinkNotNull method instantiate.

@Override
public Iterable<Entity> instantiate(String entityType, QueryEngine queryEngine, ModelMetaData metaData) {
    queryEngine.assertOperational();
    final PersistentStoreTransaction txn = queryEngine.getPersistentStore().getAndCheckCurrentTransaction();
    return txn.findWithLinks(entityType, name);
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction)

Example 2 with PersistentStoreTransaction

use of jetbrains.exodus.entitystore.PersistentStoreTransaction in project xodus by JetBrains.

the class LinkNotNull method instantiate.

@Override
public Iterable<Entity> instantiate(String entityType, QueryEngine queryEngine, ModelMetaData metaData, InstantiateContext context) {
    queryEngine.assertOperational();
    final PersistentStoreTransaction txn = queryEngine.getPersistentStore().getAndCheckCurrentTransaction();
    return txn.findWithLinks(entityType, name);
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction)

Example 3 with PersistentStoreTransaction

use of jetbrains.exodus.entitystore.PersistentStoreTransaction in project xodus by JetBrains.

the class PropertiesTable method getValueIndex.

@Nullable
public Store getValueIndex(@NotNull final PersistentStoreTransaction txn, final int propertyId, final boolean creationRequired) {
    Store valueIndex;
    synchronized (valueIndexes) {
        valueIndex = valueIndexes.get(propertyId);
        if (valueIndex == null) {
            final Transaction envTxn = txn.getEnvironmentTransaction();
            valueIndex = envTxn.getEnvironment().openStore(valueIndexName(propertyId), StoreConfig.WITH_DUPLICATES, envTxn, creationRequired);
            if (valueIndex != null && !valueIndex.getConfig().temporaryEmpty) {
                store.trackTableCreation(valueIndex, txn);
                valueIndexes.put(propertyId, valueIndex);
            }
        }
    }
    return valueIndex;
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with PersistentStoreTransaction

use of jetbrains.exodus.entitystore.PersistentStoreTransaction in project xodus by JetBrains.

the class PropertiesTable method put.

/**
 * Setter for property value. Doesn't affect entity version and doesn't
 * invalidate any of the cached entity iterables.
 *
 * @param localId    entity local id.
 * @param value      property value.
 * @param oldValue   property old value
 * @param propertyId property id
 */
public void put(@NotNull final PersistentStoreTransaction txn, final long localId, @NotNull final ByteIterable value, @Nullable final ByteIterable oldValue, final int propertyId, @NotNull final ComparableValueType type) {
    final Store valueIdx = getOrCreateValueIndex(txn, propertyId);
    final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId));
    final Transaction envTxn = txn.getEnvironmentTransaction();
    boolean success = primaryStore.put(envTxn, key, value);
    final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId);
    if (oldValue == null) {
        if (!allPropsIndex.put(envTxn, propertyId, localId)) {
            success = false;
        }
    } else {
        if (!deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type))) {
            success = false;
        }
    }
    for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) {
        if (!valueIdx.put(envTxn, secondaryKey, secondaryValue)) {
            success = false;
        }
    }
    checkStatus(success, "Failed to put");
}
Also used : PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) ByteIterable(jetbrains.exodus.ByteIterable)

Example 5 with PersistentStoreTransaction

use of jetbrains.exodus.entitystore.PersistentStoreTransaction in project xodus by JetBrains.

the class HumanReadablePresentationTests method test1.

@SuppressWarnings({ "HardcodedLineSeparator", "OverlyCoupledMethod" })
public void test1() {
    assertEquals(EntityIterableType.values().length, EntityIterableBase.children.length);
    assertEquals(EntityIterableType.values().length, EntityIterableBase.fields.length);
    final PersistentStoreTransaction txn = getStoreTransaction();
    assertNotNull(txn);
    checkIterable(new AddNullDecoratorIterable(txn, new PropertyRangeIterable(txn, 0, 1, "minValue", "maxValue"), EntityIterableBase.EMPTY), "Left operand appended with null if it's present in the right, but not left one\n" + "|   Entities with a property value in range 0 1 minvalue maxvalue\n" + "|   Empty iterable");
    checkIterable(new UnionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), "Union\n" + "|   Empty iterable\n" + "|   Empty iterable");
    checkIterable(new MinusIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), "Minus\n" + "|   Empty iterable\n" + "|   Empty iterable");
    checkIterable(new IntersectionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), "Intersection\n" + "|   Empty iterable\n" + "|   Empty iterable");
    checkIterable(new ConcatenationIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), "Concatenation\n" + "|   Empty iterable\n" + "|   Empty iterable");
    checkIterable(new PropertiesIterable(txn, 0, 1), "Entities with property sorted by its value 0 1");
    checkIterable(new PropertyValueIterable(txn, 0, 1, "value"), "Entities with specified property value 0 1 value");
    checkIterable(new PropertyContainsValueEntityIterable(txn, 0, 1, "sub", true), "Entities with string property containing a value 0 1 sub true");
    checkIterable(new EntitiesOfTypeIterable(txn, 0), "All entities of specific type 0");
    checkIterable(new EntitiesOfTypeRangeIterable(txn, 0, 3, 8), "Entities of specific type within id range 0 3 8");
    checkIterable(new EntitiesWithLinkIterable(txn, 0, 1), "Entities with link 0 1");
    checkIterable(new EntitiesWithLinkSortedIterable(txn, 0, 1, 2, 3), "Entities with link 0 1");
    checkIterable(new SingleEntityIterable(txn, new PersistentEntityId(0, 1)), "Single entity 0 1");
    checkIterable(new MergeSortedIterableWithValueGetter(txn, new ArrayList<>(), entity -> null, (o1, o2) -> 0), "Merge sorted iterables 0");
    checkIterable(new EntitiesWithPropertyIterable(txn, 0, 1), "Entities with property 0 1");
    checkIterable(new EntitiesWithBlobIterable(txn, 0, 1), "Entities with blob 0 1");
    checkIterable(new TakeEntityIterable(txn, EntityIterableBase.EMPTY, 0), "Take iterable 0\n" + "|   Empty iterable");
    checkIterable(new EntityReverseIterable(txn, EntityIterableBase.EMPTY), "Reversed iterable\n" + "|   Empty iterable");
    checkIterable(new SortIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY, 0, 2, false), "Sorting iterable 0 2 1\n" + "|   Empty iterable");
    checkIterable(new DistinctIterable(txn, EntityIterableBase.EMPTY), "Distinct iterable\n" + "|   Empty iterable");
    checkIterable(new SelectManyIterable(txn, EntityIterableBase.EMPTY, 0, true), "SelectMany distinct iterable 0\n" + "|   Empty iterable");
    checkIterable(new SortResultIterable(txn, EntityIterableBase.EMPTY), "Empty iterable");
    checkIterable(new SelectDistinctIterable(txn, EntityIterableBase.EMPTY, 0), "Select distinct iterable 0\n" + "|   Empty iterable");
    checkIterable(new SkipEntityIterable(txn, EntityIterableBase.EMPTY, 0), "Skip iterable 0\n" + "|   Empty iterable");
    checkIterable(new ExcludeNullIterableDecorator(txn, EntityIterableBase.EMPTY), "Exclude null\n" + "|   Empty iterable");
    IntHashMap<String> map = new IntHashMap<>();
    map.put(3, "value3");
    map.put(4, "value2");
    checkIterable(new EntityFromLinkSetIterable(txn, new PersistentEntityId(0, 1), map), "Outgoing links of a set from an entity 0 1  2 links: 3 4");
    checkIterable(new EntityFromLinksIterable(txn, new PersistentEntityId(0, 1), 2), "Outgoing links from an entity 0 1 2");
    checkIterable(new EntityToLinksIterable(txn, new PersistentEntityId(0, 1), 2, 3), "Incoming links to an entity 0 1 2 3");
    checkIterable(new FilterEntityTypeIterable(txn, 0, EntityIterableBase.EMPTY), "Filter source iterable by entity type 0\n" + "|   Empty iterable");
    checkIterable(new FilterLinksIterable(txn, 0, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), "Filter source iterable by links set 0\n" + "|   Empty iterable\n" + "|   Empty iterable");
    // XD-441
    checkIterable(new IntersectionIterable(txn, new IntersectionIterable(txn, new IntersectionIterable(txn, new UnionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), new MinusIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY)), new IntersectionIterable(txn, new UnionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), new MinusIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY))), new IntersectionIterable(txn, new IntersectionIterable(txn, new UnionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), new MinusIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY)), new IntersectionIterable(txn, new UnionIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY), new MinusIterable(txn, EntityIterableBase.EMPTY, EntityIterableBase.EMPTY)))), "Intersection\n" + "|   Intersection\n" + "|   |   Intersection\n" + "|   |   |   Union\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   Minus\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   Intersection\n" + "|   |   |   Union\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   Minus\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   Intersection\n" + "|   |   Intersection\n" + "|   |   |   Union\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   Minus\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   Intersection\n" + "|   |   |   Union\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   Minus\n" + "|   |   |   |   Empty iterable\n" + "|   |   |   |   Empty iterable");
}
Also used : PersistentEntityId(jetbrains.exodus.entitystore.PersistentEntityId) EntityIterableType(jetbrains.exodus.entitystore.EntityIterableType) jetbrains.exodus.entitystore.iterate.binop(jetbrains.exodus.entitystore.iterate.binop) IntHashMap(jetbrains.exodus.core.dataStructures.hash.IntHashMap) EntityStoreTestBase(jetbrains.exodus.entitystore.EntityStoreTestBase) PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) ArrayList(java.util.ArrayList) PersistentStoreTransaction(jetbrains.exodus.entitystore.PersistentStoreTransaction) ArrayList(java.util.ArrayList) IntHashMap(jetbrains.exodus.core.dataStructures.hash.IntHashMap) PersistentEntityId(jetbrains.exodus.entitystore.PersistentEntityId)

Aggregations

PersistentStoreTransaction (jetbrains.exodus.entitystore.PersistentStoreTransaction)10 ByteIterable (jetbrains.exodus.ByteIterable)3 EntityMetaData (jetbrains.exodus.query.metadata.EntityMetaData)2 PropertyMetaData (jetbrains.exodus.query.metadata.PropertyMetaData)2 ArrayList (java.util.ArrayList)1 IntHashMap (jetbrains.exodus.core.dataStructures.hash.IntHashMap)1 Entity (jetbrains.exodus.entitystore.Entity)1 EntityIterableType (jetbrains.exodus.entitystore.EntityIterableType)1 EntityStoreTestBase (jetbrains.exodus.entitystore.EntityStoreTestBase)1 PersistentEntityId (jetbrains.exodus.entitystore.PersistentEntityId)1 jetbrains.exodus.entitystore.iterate.binop (jetbrains.exodus.entitystore.iterate.binop)1 Nullable (org.jetbrains.annotations.Nullable)1