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);
}
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);
}
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;
}
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");
}
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");
}
Aggregations