@Override public <V> TitanVertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value) { if (!supports(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); Preconditions.checkArgument(value != null); Preconditions.checkArgument(cardinality== VertexProperty.Cardinality.single,"Only single cardinality is supported, provided: %s",cardinality); vertexMemory.setProperty(vertexId, key, value); return constructProperty(key,value); }
@Override public <V> JanusGraphVertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value) { if (!supports(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); Preconditions.checkArgument(value != null); if (cardinality == VertexProperty.Cardinality.single) { vertexMemory.setProperty(vertexId, key, value); } else { final V previousValue = vertexMemory.getProperty(vertexId, key); final List<V> values; if (previousValue != null) { assert previousValue instanceof List; values = new ArrayList<>(((List) previousValue)); } else { values = new ArrayList<>(); } values.add(value); vertexMemory.setProperty(vertexId, key, values); } return constructProperty(key,value); }
@Override public void execute(final Vertex vertex, final Messenger<Object> messenger, final Memory memory) { try { vertex.property(VertexProperty.Cardinality.single, "blah", "blah"); fail("Should throw an IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals(GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey("blah").getMessage(), e.getMessage()); } catch (final Exception e) { fail("Should throw an IllegalArgumentException: " + e); } memory.add("a", 1); if (memory.isInitialIteration()) { vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length()); memory.add("b", vertex.<String>value("name").length()); } else { vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length() + vertex.<Integer>value("nameLengthCounter")); } }
@Override public void execute(final Vertex vertex, final Messenger<Object> messenger, final Memory memory) { try { vertex.property(VertexProperty.Cardinality.single, "blah", "blah"); fail("Should throw an IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals(GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey("blah").getMessage(), e.getMessage()); } catch (final Exception e) { fail("Should throw an IllegalArgumentException: " + e); } memory.add("a", 1); if (memory.isInitialIteration()) { vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length()); memory.add("b", vertex.<String>value("name").length()); } else { vertex.property(VertexProperty.Cardinality.single, "nameLengthCounter", vertex.<String>value("name").length() + vertex.<Integer>value("nameLengthCounter")); } }
public <V> Property<V> addProperty(final TinkerVertex vertex, final String key, final V value) { ElementHelper.validateProperty(key, value); if (isComputeKey(key)) { final TinkerVertexProperty<V> property = new TinkerVertexProperty<V>((TinkerVertex) vertex, key, value) { @Override public void remove() { removeProperty(vertex, key, this); } }; this.addValue(vertex, key, property); return property; } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
public <V> Property<V> addProperty(final TinkerVertex vertex, final String key, final V value) { ElementHelper.validateProperty(key, value); if (isComputeKey(key)) { final TinkerVertexProperty<V> property = new TinkerVertexProperty<V>((TinkerVertex) vertex, key, value) { @Override public void remove() { removeProperty(vertex, key, this); } }; this.addValue(vertex, key, property); return property; } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
public <V> Property<V> addProperty(DuctileVertex vertex, String key, V value) { ElementHelper.validateProperty(key, value); if (!isComputeKey(key)) { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } DuctileVertexProperty<V> property = new DuctileVertexProperty<V>(vertex, key, value) { @Override public void remove() { removeProperty(vertex, key, this); } }; addValue(vertex, key, property); return property; }
@Override public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(cardinality, key, value, keyValues)); }
@Override public <V> VertexProperty<V> property(final String key, final V value) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(key, value)); }
public void removeProperty(DuctileVertex vertex, String key, DuctileVertexProperty<?> property) { if (isComputeKey(key)) { removeValue(vertex, key, property); } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
@Override public <V> TitanVertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value) { if (!supports(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); Preconditions.checkArgument(value != null); Preconditions.checkArgument(cardinality== VertexProperty.Cardinality.single,"Only single cardinality is supported, provided: %s",cardinality); vertexMemory.setProperty(vertexId, key, value); return constructProperty(key,value); }
public void removeProperty(final TinkerVertex vertex, final String key, final VertexProperty property) { if (isComputeKey(key)) { this.removeValue(vertex, key, property); } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
public void removeProperty(final TinkerVertex vertex, final String key, final VertexProperty property) { if (isComputeKey(key)) { this.removeValue(vertex, key, property); } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
@Override public <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(key, value, keyValues)); }
public <V> Property<V> addProperty(final TinkerVertex vertex, final String key, final V value) { ElementHelper.validateProperty(key, value); if (isComputeKey(key)) { final TinkerVertexProperty<V> property = new TinkerVertexProperty<V>((TinkerVertex) vertex, key, value) { @Override public void remove() { removeProperty(vertex, key, this); } }; this.addValue(vertex, key, property); return property; } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
@Override public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(cardinality, key, value, keyValues)); }
@Override public <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(key, value, keyValues)); }
public void removeProperty(final TinkerVertex vertex, final String key, final VertexProperty property) { if (isComputeKey(key)) { this.removeValue(vertex, key, property); } else { throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); } }
@Override public <V> VertexProperty<V> property(final String key, final V value) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce(); if (!computeKeys.contains(key)) throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key); return new ComputerVertexProperty<>(this.getBaseVertex().property(key, value)); }