protected DetachedVertexProperty(final VertexProperty<V> vertexProperty, final boolean withProperties) { super(vertexProperty); this.value = vertexProperty.value(); this.vertex = DetachedFactory.detach(vertexProperty.element(), false); // only serialize properties if requested, the graph supports it and there are meta properties present. // this prevents unnecessary object creation of a new HashMap which will just be empty. it will use // Collections.emptyMap() by default if (withProperties && vertexProperty.graph().features().vertex().supportsMetaProperties()) { final Iterator<Property<Object>> propertyIterator = vertexProperty.properties(); if (propertyIterator.hasNext()) { this.properties = new HashMap<>(); propertyIterator.forEachRemaining(property -> this.properties.put(property.key(), Collections.singletonList(DetachedFactory.detach(property)))); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } }
public static void validateVertexPropertyEquality(final VertexProperty originalVertexProperty, final VertexProperty otherVertexProperty) { assertEquals(originalVertexProperty, otherVertexProperty); assertEquals(otherVertexProperty, originalVertexProperty); if (originalVertexProperty.isPresent()) { assertEquals(originalVertexProperty.key(), otherVertexProperty.key()); assertEquals(originalVertexProperty.value(), otherVertexProperty.value()); assertEquals(originalVertexProperty.element(), otherVertexProperty.element()); final boolean originalSupportsMetaProperties = originalVertexProperty.graph().features().vertex().supportsMetaProperties(); final boolean otherSupportsMetaProperties = otherVertexProperty.graph().features().vertex().supportsMetaProperties(); // if one supports and the other doesn't then neither should have meta properties. if (originalSupportsMetaProperties && !otherSupportsMetaProperties) assertEquals(0, originalVertexProperty.keys().size()); else if (!originalSupportsMetaProperties && otherSupportsMetaProperties) assertEquals(0, otherVertexProperty.keys().size()); else { // both support it, so assert in full assertEquals(originalVertexProperty.keys().size(), otherVertexProperty.keys().size()); for (final String key : originalVertexProperty.keys()) { validatePropertyEquality(originalVertexProperty.property(key), otherVertexProperty.property(key)); } } } }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final VertexProperty vertexProperty) { kryo.writeClassAndObject(output, vertexProperty.id()); output.writeString(vertexProperty.label()); kryo.writeClassAndObject(output, vertexProperty.value()); kryo.writeClassAndObject(output, vertexProperty.element().id()); output.writeString(vertexProperty.element().label()); if (vertexProperty instanceof DetachedVertexProperty || (vertexProperty.graph().features().vertex().supportsMetaProperties())) { writeElementProperties(kryo, output, vertexProperty); } else { output.writeBoolean(false); } }
protected DetachedVertexProperty(final VertexProperty<V> vertexProperty, final boolean withProperties) { super(vertexProperty); this.value = vertexProperty.value(); this.vertex = DetachedFactory.detach(vertexProperty.element(), false); // only serialize properties if requested, the graph supports it and there are meta properties present. // this prevents unnecessary object creation of a new HashMap which will just be empty. it will use // Collections.emptyMap() by default if (withProperties && vertexProperty.graph().features().vertex().supportsMetaProperties()) { final Iterator<Property<Object>> propertyIterator = vertexProperty.properties(); if (propertyIterator.hasNext()) { this.properties = new HashMap<>(); propertyIterator.forEachRemaining(property -> this.properties.put(property.key(), Collections.singletonList(DetachedFactory.detach(property)))); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, normalize); } } }
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize) throws IOException { // when "detached" you can't check features of the graph it detached from so it has to be // treated differently from a regular VertexProperty implementation. if (property instanceof DetachedVertexProperty) { // only write meta properties key if they exist if (property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } else { // still attached - so we can check the features to see if it's worth even trying to write the // meta properties key if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) { writeMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); } } }
public static void validateVertexPropertyEquality(final VertexProperty originalVertexProperty, final VertexProperty otherVertexProperty) { assertEquals(originalVertexProperty, otherVertexProperty); assertEquals(otherVertexProperty, originalVertexProperty); if (originalVertexProperty.isPresent()) { assertEquals(originalVertexProperty.key(), otherVertexProperty.key()); assertEquals(originalVertexProperty.value(), otherVertexProperty.value()); assertEquals(originalVertexProperty.element(), otherVertexProperty.element()); final boolean originalSupportsMetaProperties = originalVertexProperty.graph().features().vertex().supportsMetaProperties(); final boolean otherSupportsMetaProperties = otherVertexProperty.graph().features().vertex().supportsMetaProperties(); // if one supports and the other doesn't then neither should have meta properties. if (originalSupportsMetaProperties && !otherSupportsMetaProperties) assertEquals(0, originalVertexProperty.keys().size()); else if (!originalSupportsMetaProperties && otherSupportsMetaProperties) assertEquals(0, otherVertexProperty.keys().size()); else { // both support it, so assert in full assertEquals(originalVertexProperty.keys().size(), otherVertexProperty.keys().size()); for (final String key : originalVertexProperty.keys()) { validatePropertyEquality(originalVertexProperty.property(key), otherVertexProperty.property(key)); } } } }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final VertexProperty vertexProperty) { kryo.writeClassAndObject(output, vertexProperty.id()); output.writeString(vertexProperty.label()); kryo.writeClassAndObject(output, vertexProperty.value()); kryo.writeClassAndObject(output, vertexProperty.element().id()); output.writeString(vertexProperty.element().label()); if (vertexProperty instanceof DetachedVertexProperty || (vertexProperty.graph().features().vertex().supportsMetaProperties())) { writeElementProperties(kryo, output, vertexProperty); } else { output.writeBoolean(false); } }