private Map.Entry<Object, OIdentifiable> calculateTxIndexEntry(final Object key, final OIdentifiable backendValue, OTransactionIndexChanges indexChanges) { final OTransactionIndexChangesPerKey changesPerKey = indexChanges.getChangesPerKey(key); if (changesPerKey.entries.isEmpty()) return createMapEntry(key, backendValue); int putCounter = 1; for (OTransactionIndexEntry entry : changesPerKey.entries) { if (entry.operation == OPERATION.PUT && entry.value.equals(backendValue)) putCounter++; else if (entry.operation == OPERATION.REMOVE) { if (entry.value == null) putCounter = 0; else if (entry.value.equals(backendValue) && putCounter > 0) putCounter--; } } if (putCounter <= 0) return null; return createMapEntry(key, backendValue); }
public PureTxBetweenIndexForwardCursor(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, OTransactionIndexChanges indexChanges) { this.indexChanges = indexChanges; fromKey = enhanceFromCompositeKeyBetweenAsc(fromKey, fromInclusive); toKey = enhanceToCompositeKeyBetweenAsc(toKey, toInclusive); final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive); if (keys.length == 0) { nextKey = null; } else { firstKey = keys[0]; lastKey = keys[1]; nextKey = firstKey; } }
public PureTxBetweenIndexBackwardCursor(Object fromKey, boolean fromInclusive, Object toKey, boolean toInclusive, OTransactionIndexChanges indexChanges) { this.indexChanges = indexChanges; fromKey = enhanceFromCompositeKeyBetweenDesc(fromKey, fromInclusive); toKey = enhanceToCompositeKeyBetweenDesc(toKey, toInclusive); final Object[] keys = indexChanges.firstAndLastKeys(fromKey, fromInclusive, toKey, toInclusive); if (keys.length == 0) { nextKey = null; } else { firstKey = keys[0]; lastKey = keys[1]; nextKey = lastKey; } }
public OIndex<?> preProcessBeforeReturn(ODatabaseDocumentInternal database, final OIndex<?> index) { if (index instanceof OIndexMultiValues) //noinspection unchecked return new OIndexTxAwareMultiValue(database, (OIndex<Collection<OIdentifiable>>) index); else if (index instanceof OIndexDictionary) //noinspection unchecked return new OIndexTxAwareDictionary(database, (OIndex<OIdentifiable>) index); else if (index instanceof OIndexOneValue) //noinspection unchecked return new OIndexTxAwareOneValue(database, (OIndex<OIdentifiable>) index); return index; }
key = getCollatingValue(key); Map.Entry<Object, OIdentifiable> entry = calculateTxIndexEntry(key, identifiable, indexChanges); if (entry != null) processed.add(entry.getValue()); Set<OIdentifiable> txChanges = calculateTxValue(key, indexChanges); if (txChanges != null) processed.addAll(txChanges);
@Override public boolean contains(final Object key) { final Collection<OIdentifiable> result = get(key); return result != null && !result.isEmpty(); }
public OIndex<?> preProcessBeforeReturn(ODatabaseDocumentInternal database, final OIndex<?> index) { if (index instanceof OIndexRemoteMultiValue) return new OIndexTxAwareMultiValue(database, (OIndex<Collection<OIdentifiable>>) index); else if (index instanceof OIndexDictionary) return new OIndexTxAwareDictionary(database, (OIndex<OIdentifiable>) index); else if (index instanceof OIndexRemoteOneValue) return new OIndexTxAwareOneValue(database, (OIndex<OIdentifiable>) index); return index; }
protected OrientIndex(final OrientBaseGraph orientGraph, final OIndex<?> rawIndex) { this.graph = orientGraph; this.underlying = rawIndex instanceof OIndexTxAwareMultiValue ? rawIndex : new OIndexTxAwareMultiValue( orientGraph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) rawIndex); load(rawIndex.getConfiguration()); }
protected OrientIndex(final OrientBaseGraph orientGraph, final OIndex<?> rawIndex) { this.graph = orientGraph; this.underlying = rawIndex instanceof OIndexTxAwareMultiValue ? rawIndex : new OIndexTxAwareMultiValue( orientGraph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) rawIndex); final ODocument metadata = rawIndex.getMetadata(); if (metadata == null) { load(rawIndex.getConfiguration()); } else load(metadata); }
private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) { this.indexClass = indexClass; if (iKeyType == null) iKeyType = OType.STRING; // CREATE THE MAP this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) graph.getRawGraph() .getMetadata().getIndexManager() .createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(iKeyType), null, null)); final String className; if (Vertex.class.isAssignableFrom(indexClass)) className = VERTEX; else if (Edge.class.isAssignableFrom(indexClass)) className = EDGE; else className = indexClass.getName(); // CREATE THE CONFIGURATION FOR THE NEW INDEX underlying.getConfiguration().field(CONFIG_CLASSNAME, className); }
private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) { this.indexClass = indexClass; if (iKeyType == null) iKeyType = OType.STRING; final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); this.recordKeyValueIndex = new OIndexTxAwareOneValue(graph.getRawGraph(), (OIndex<OIdentifiable>) graph .getRawGraph() .getMetadata() .getIndexManager() .createIndex("__@recordmap@___" + indexName, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK, OType.STRING), null, null, null)); final String className; if (Vertex.class.isAssignableFrom(indexClass)) className = VERTEX; else if (Edge.class.isAssignableFrom(indexClass)) className = EDGE; else className = indexClass.getName(); final ODocument metadata = new ODocument(); metadata.field(CONFIG_CLASSNAME, className); metadata.field(CONFIG_RECORD_MAP_NAME, recordKeyValueIndex.getName()); final OIndexFactory nuFactory = OIndexes.getFactory(OClass.INDEX_TYPE.NOTUNIQUE.toString(), null); // CREATE THE MAP this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) graph .getRawGraph() .getMetadata() .getIndexManager() .createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(nuFactory.getLastVersion(), iKeyType), null, null, metadata)); }