Skip to content

Commit

Permalink
Fixes #1070
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroecheler committed Sep 5, 2015
1 parent 7fa81a4 commit f93e0fb
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 171 deletions.
Expand Up @@ -12,4 +12,9 @@ public WriteConfiguration getBaseConfiguration() {
return BerkeleyStorageSetup.getBerkeleyJEGraphConfiguration(); return BerkeleyStorageSetup.getBerkeleyJEGraphConfiguration();
} }


@Override
public boolean storeUsesConsistentKeyLocker() {
return false;
}

} }
Expand Up @@ -17,4 +17,9 @@ public WriteConfiguration getBaseConfiguration() {
return CassandraStorageSetup.getCassandraThriftGraphConfiguration(getClass().getSimpleName()); return CassandraStorageSetup.getCassandraThriftGraphConfiguration(getClass().getSimpleName());
} }


@Override
public boolean storeUsesConsistentKeyLocker() {
return true;F
}

} }
Expand Up @@ -257,8 +257,8 @@ public void initialize(Configuration config) {
long edgeStoreCacheSize = Math.round(cacheSizeBytes * EDGESTORE_CACHE_PERCENT); long edgeStoreCacheSize = Math.round(cacheSizeBytes * EDGESTORE_CACHE_PERCENT);
long indexStoreCacheSize = Math.round(cacheSizeBytes * INDEXSTORE_CACHE_PERCENT); long indexStoreCacheSize = Math.round(cacheSizeBytes * INDEXSTORE_CACHE_PERCENT);


edgeStore = new ExpirationKCVSCache(edgeStoreRaw,getMetricsCacheName("edgeStore"),expirationTime,cleanWaitTime,edgeStoreCacheSize); edgeStore = new ExpirationKCVSCache(edgeStoreRaw,getMetricsCacheName(EDGESTORE_NAME),expirationTime,cleanWaitTime,edgeStoreCacheSize);
indexStore = new ExpirationKCVSCache(indexStoreRaw,getMetricsCacheName("indexStore"),expirationTime,cleanWaitTime,indexStoreCacheSize); indexStore = new ExpirationKCVSCache(indexStoreRaw,getMetricsCacheName(INDEXSTORE_NAME),expirationTime,cleanWaitTime,indexStoreCacheSize);
} else { } else {
edgeStore = new NoKCVSCache(edgeStoreRaw); edgeStore = new NoKCVSCache(edgeStoreRaw);
indexStore = new NoKCVSCache(indexStoreRaw); indexStore = new NoKCVSCache(indexStoreRaw);
Expand Down
Expand Up @@ -58,6 +58,12 @@ protected VertexCentricQueryBuilder getThis() {
protected<Q> Q execute(RelationCategory returnType, ResultConstructor<Q> resultConstructor) { protected<Q> Q execute(RelationCategory returnType, ResultConstructor<Q> resultConstructor) {
BaseVertexCentricQuery bq = super.constructQuery(returnType); BaseVertexCentricQuery bq = super.constructQuery(returnType);
if (bq.isEmpty()) return resultConstructor.emptyResult(); if (bq.isEmpty()) return resultConstructor.emptyResult();
if (returnType==RelationCategory.PROPERTY && hasTypes()
&& tx.getConfiguration().hasPropertyPrefetching()) {
//Preload properties
vertex.query().properties().iterator().hasNext();
}

if (isPartitionedVertex(vertex) && !hasQueryOnlyGivenVertex()) { //If it's a preloaded vertex we shouldn't preload data explicitly if (isPartitionedVertex(vertex) && !hasQueryOnlyGivenVertex()) { //If it's a preloaded vertex we shouldn't preload data explicitly
List<InternalVertex> vertices = allRequiredRepresentatives(vertex); List<InternalVertex> vertices = allRequiredRepresentatives(vertex);
profiler.setAnnotation(QueryProfiler.PARTITIONED_VERTEX_ANNOTATION,true); profiler.setAnnotation(QueryProfiler.PARTITIONED_VERTEX_ANNOTATION,true);
Expand Down
Expand Up @@ -106,7 +106,7 @@ public TitanVertex addVertex(Object... keyValues) {
// if (!keyValues[i].equals(T.id) && !keyValues[i].equals(T.label)) // if (!keyValues[i].equals(T.id) && !keyValues[i].equals(T.label))
// ((StandardTitanTx)this).addPropertyInternal(vertex,getOrCreatePropertyKey((String) keyValues[i]),keyValues[i+1]); // ((StandardTitanTx)this).addPropertyInternal(vertex,getOrCreatePropertyKey((String) keyValues[i]),keyValues[i+1]);
// } // }
ElementHelper.attachProperties(vertex, keyValues); com.thinkaurelius.titan.graphdb.util.ElementHelper.attachProperties(vertex, keyValues);
return vertex; return vertex;
} }


Expand Down
Expand Up @@ -759,6 +759,10 @@ public TitanVertexProperty addProperty(VertexProperty.Cardinality cardi, TitanVe
2) there are no indexes for this property key 2) there are no indexes for this property key
3) the cardinalities match (if we overwrite a set with single, we need to read all other values to delete) 3) the cardinalities match (if we overwrite a set with single, we need to read all other values to delete)
*/ */
ConsistencyModifier mod = ((InternalRelationType)key).getConsistencyModifier();
boolean hasIndex = TypeUtil.hasAnyIndex(key);
boolean cardiEqual = cardi==cardinality.convert();

if ( (!config.hasVerifyUniqueness() || ((InternalRelationType)key).getConsistencyModifier()!=ConsistencyModifier.LOCK) && if ( (!config.hasVerifyUniqueness() || ((InternalRelationType)key).getConsistencyModifier()!=ConsistencyModifier.LOCK) &&
!TypeUtil.hasAnyIndex(key) && cardi==cardinality.convert()) { !TypeUtil.hasAnyIndex(key) && cardi==cardinality.convert()) {
//Only delete in-memory so as to not trigger a read from the database which isn't necessary because we will overwrite blindly //Only delete in-memory so as to not trigger a read from the database which isn't necessary because we will overwrite blindly
Expand Down
Expand Up @@ -99,7 +99,7 @@ public static List<CompositeIndexType> getUniqueIndexes(PropertyKey key) {
public static boolean hasAnyIndex(PropertyKey key) { public static boolean hasAnyIndex(PropertyKey key) {
InternalRelationType type = (InternalRelationType) key; InternalRelationType type = (InternalRelationType) key;
return !Iterables.isEmpty(type.getKeyIndexes()) || return !Iterables.isEmpty(type.getKeyIndexes()) ||
!Iterables.isEmpty(type.getRelationIndexes()); Iterables.size(type.getRelationIndexes())>1; //The type itself is also returned as an index
} }


private static <T> T getTypeModifier(final SchemaSource schema, private static <T> T getTypeModifier(final SchemaSource schema,
Expand Down
Expand Up @@ -5,8 +5,7 @@
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.thinkaurelius.titan.core.*; import com.thinkaurelius.titan.core.*;
import com.thinkaurelius.titan.graphdb.relations.RelationIdentifier; import com.thinkaurelius.titan.graphdb.relations.RelationIdentifier;
import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.structure.Element;


import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collections; import java.util.Collections;
Expand Down Expand Up @@ -42,14 +41,32 @@ public static long getCompareId(Element element) {
else throw new IllegalArgumentException("Element identifier has unrecognized type: " + id); else throw new IllegalArgumentException("Element identifier has unrecognized type: " + id);
} }


public static void attachProperties(TitanElement element, Object... keyValues) { public static void attachProperties(TitanRelation element, Object... keyValues) {
if (keyValues==null || keyValues.length==0) return; //Do nothing if (keyValues==null || keyValues.length==0) return; //Do nothing
org.apache.tinkerpop.gremlin.structure.util.ElementHelper.legalPropertyKeyValueArray(keyValues); org.apache.tinkerpop.gremlin.structure.util.ElementHelper.legalPropertyKeyValueArray(keyValues);
if (org.apache.tinkerpop.gremlin.structure.util.ElementHelper.getIdValue(keyValues).isPresent()) throw Edge.Exceptions.userSuppliedIdsNotSupported(); if (org.apache.tinkerpop.gremlin.structure.util.ElementHelper.getIdValue(keyValues).isPresent()) throw Edge.Exceptions.userSuppliedIdsNotSupported();
if (org.apache.tinkerpop.gremlin.structure.util.ElementHelper.getLabelValue(keyValues).isPresent()) throw new IllegalArgumentException("Cannot provide label as argument"); if (org.apache.tinkerpop.gremlin.structure.util.ElementHelper.getLabelValue(keyValues).isPresent()) throw new IllegalArgumentException("Cannot provide label as argument");
org.apache.tinkerpop.gremlin.structure.util.ElementHelper.attachProperties(element,keyValues); org.apache.tinkerpop.gremlin.structure.util.ElementHelper.attachProperties(element,keyValues);
} }


/**
* This is essentially an adjusted copy&paste from TinkerPop's ElementHelper class.
* The reason for copying it is so that we can determine the cardinality of a property key based on
* Titan's schema which is tied to this particular transaction and not the graph.
*
* @param vertex
* @param propertyKeyValues
*/
public static void attachProperties(final TitanVertex vertex, final Object... propertyKeyValues) {
if (null == vertex)
throw Graph.Exceptions.argumentCanNotBeNull("vertex");

for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label))
vertex.property((String) propertyKeyValues[i], propertyKeyValues[i + 1]);
}
}

public static Set<String> getPropertyKeys(TitanVertex v) { public static Set<String> getPropertyKeys(TitanVertex v) {
final Set<String> s = new HashSet<>(); final Set<String> s = new HashSet<>();
v.query().properties().forEach( p -> s.add(p.propertyKey().name())); v.query().properties().forEach( p -> s.add(p.propertyKey().name()));
Expand Down
Expand Up @@ -32,4 +32,14 @@ public static void startHBase() throws IOException {
HBaseStorageSetup.startHBase(); HBaseStorageSetup.startHBase();
} }


@Override
public boolean storeUsesConsistentKeyLocker() {
return true;
}

@Override
public void testCacheConcurrency() throws InterruptedException {
//Don't run this test;
}

} }

0 comments on commit f93e0fb

Please sign in to comment.