org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitsyVertex.java    From bitsy with Apache License 2.0 5 votes vote down vote up
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
	if (cardinality != Cardinality.single) {
		// For some reason, TP3 tests fail with this exception
		//throw new BitsyException(BitsyErrorCodes.NO_MULTI_PROPERTY_SUPPORT, "Encountered cardinality: " + cardinality.toString());
	} else if (keyValues.length != 0) {
		throw new UnsupportedOperationException("Encountered key values: " + keyValues.toString(), new BitsyException(BitsyErrorCodes.NO_META_PROPERTY_SUPPORT));
	}

	return property(key, value);
}
 
Example #2
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
protected void addProperty(Features features, Element v, String key, List<?> values) {
  if (v instanceof Vertex && !Cardinality.single.equals(features.vertex().getCardinality(key))) {
    values.stream().filter(not(isNull())).forEach(value -> setProperty(v, key, value));
  } else {
    ValueStrategy valueStrategy = options.getValueStrategyProvider().get(key);
    addSingleProperty(v, key, values, valueStrategy);
  }
}
 
Example #3
Source File: EntityGraphFactory.java    From baleen with Apache License 2.0 5 votes vote down vote up
private Graph createTransformGraph(boolean multiValue) {
  BaseConfiguration configuration = new BaseConfiguration();
  configuration.setProperty(Graph.GRAPH, TinkerGraph.class.getName());
  if (multiValue) {
    configuration.setProperty(
        TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY,
        VertexProperty.Cardinality.list.name());
  } else {
    configuration.setProperty(
        TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY,
        VertexProperty.Cardinality.single.name());
  }

  return TinkerGraph.open(configuration);
}
 
Example #4
Source File: BlazeVertex.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Strengthen return type to {@link BlazeVertexProperty}.
 * 
 * @see BlazeGraph#vertexProperty(BlazeVertex, Cardinality, String, Object, Object...)
 */
@Override
public <V> BlazeVertexProperty<V> property(final Cardinality cardinality, 
        final String key, final V val, final Object... kvs) {
    ElementHelper.validateProperty(key, val);
    if (ElementHelper.getIdValue(kvs).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    
    return graph.vertexProperty(this, cardinality, key, val, kvs);
}
 
Example #5
Source File: SampleCode.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Demonstration of the search API.
 * <p>
 * The search API lets you use Blazegraph's built-in full text index to
 * perform Lucene-style searches against your graph. Searches are done
 * against property values - the search results are an iterator of Property
 * objects (connected to the graph elements to which they belong). The
 * search API will find both properties (on vertices and edges) and
 * meta-properties (on vertex properties). To use the API, specify a search
 * string and a match behavior. The search string can consist of one or more
 * tokens to find. The match behavior tells the search engine how to look
 * for the tokens - find any of them (or), find all of them (and), or find
 * only exact matches for the search string. "Exact" is somewhat expensive
 * relative to "All" - it's usually better to use "All" and live with
 * slightly less precision in the search results. If a "*" appears at the
 * end of a token, the search engine will use prefix matching instead of
 * token matching. Prefix match is either on or off for the entire search,
 * it is not done on a token by token basis.
 * </p>
 */
@Test
public void demonstrateSearchAPI() throws Exception {
    
    /*
     * Load a toy graph.
     */
    graph.bulkLoad(() -> {
        final BlazeVertex v = graph.addVertex();
        v.property(Cardinality.set, "key", "hello foo");
        v.property(Cardinality.set, "key", "hello bar");
        v.property(Cardinality.set, "key", "hello foo bar");
        v.property(Cardinality.set, "key", "hello bar foo");
    });
    graph.tx().commit();
    
    // all four vertex properties contain "foo" or "bar"
    assertEquals(4, graph.search("foo bar", Match.ANY).count());
    // three contain "foo"
    assertEquals(3, graph.search("foo", Match.ANY).count());
    // and three contain "bar"
    assertEquals(3, graph.search("bar", Match.ANY).count());
    // only two contain both
    assertEquals(2, graph.search("foo bar", Match.ALL).count());
    // and only one contains exactly "foo bar"
    assertEquals(1, graph.search("foo bar", Match.EXACT).count());
    
    // prefix match
    assertEquals(4, graph.search("hell*", Match.ANY).count());
    
}
 
Example #6
Source File: TestBasicOperations.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
public void testCardinalityList() throws Exception {
    
    final BlazeVertex a = graph.addVertex(T.id, "a");
    a.property(Cardinality.list, "foo", "bar", "acl", "public");
    a.property(Cardinality.list, "foo", "baz", "acl", "public");
    a.property(Cardinality.list, "foo", "bar", "acl", "private");
    graph.tx().commit();

    log.debug(() -> "\n"+graph.dumpStore());

    final List<VertexProperty<Object>> vps = a.properties("foo").collect();
    log.debug(() -> vps.stream());
    assertEquals(3, vps.size());
    
    vps.get(0).remove();
    graph.tx().commit();
    log.debug(() -> "\n"+graph.dumpStore());
    assertEquals(2, a.properties().count());
    
    vps.get(1).remove();
    graph.tx().commit();
    log.debug(() -> "\n"+graph.dumpStore());
    assertEquals(1, a.properties().count());
    
    a.remove();
    graph.tx().commit();
    log.debug(() -> "\n"+graph.dumpStore());
    assertEquals(0, a.properties().count());
    
}
 
Example #7
Source File: TestSearch.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Make sure we can find all five kinds of properties:
 * <p>
 * <pre>
 * Edge -> Property
 * Vertex -> VertexProperty(single/set)
 * Vertex -> VertexProperty(list)
 * VertexProperty(single/set) -> Property
 * VertexProperty(list) -> Property
 * </pre>
 * </p>
 */
public void testAllFiveKinds() {
    
    final BlazeVertex a = graph.addVertex(T.id, "a");
    final BlazeVertex b = graph.addVertex(T.id, "b");
    final BlazeEdge e = graph.addEdge(a, b, Edge.DEFAULT_LABEL, T.id, "e");
    
    final Property<String> ep = e.property("ep", "foo 1");
    final VertexProperty<String> vps = a.property(Cardinality.single, "vps", "foo 2");
    final VertexProperty<String> vpl = a.property(Cardinality.list, "vpl", "foo 3");
    final Property<String> vpsp = vps.property("vpsp", "foo 4");
    final Property<String> vplp = vpl.property("vplp", "foo 5");
    graph.commit();
    
    final Map<String,Property<String>> expected = 
            new HashMap<String,Property<String>>() {{
        put("foo 1", ep);
        put("foo 2", vps);
        put("foo 3", vpl);
        put("foo 4", vpsp);
        put("foo 5", vplp);
    }};
    
    log.debug(() -> "\n"+graph.dumpStore());
    
    final List<Property<String>> results = 
            graph.<String>search("foo", Match.ANY).collect();
    log.debug(() -> results.stream());
    assertEquals(5, results.size());
    results.stream().forEach(p -> {
        assertEquals(expected.get(p.value()), p);
    });
    
}
 
Example #8
Source File: TestBulkLoad.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
public void testBulkLoad1() {
    
    final List<BlazeGraphEdit> edits = new LinkedList<>();
    graph.addListener((edit,rdfEdit) -> edits.add(edit));
    
    final BlazeVertex a = graph.addVertex(T.id, "a");
    graph.bulkLoad(() -> {
        /*
         * In incremental update mode Cardinality.single would clean old
         * values when a new value is set.  If bulk load is working we
         * should see three values and no removes.  Breaks the semantics
         * of Cardinality.single which is why bulk load should be used with
         * care.
         */
        a.property(Cardinality.single, "key", "v1");
        a.property(Cardinality.single, "key", "v2");
        a.property(Cardinality.single, "key", "v3");
    });
    graph.commit();
    
    // bulk load should be off again
    assertFalse(graph.isBulkLoad());
    // three properties
    assertEquals(3, a.properties().count());
    // zero removes
    assertEquals(0, edits.stream().filter(e -> e.getAction() == Action.Remove).count());
    
}
 
Example #9
Source File: TestBulkLoad.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
public void testBulkLoad2() {
    
    final List<BlazeGraphEdit> edits = new LinkedList<>();
    graph.addListener((edit,rdfEdit) -> edits.add(edit));
    
    final BlazeVertex a = graph.addVertex(T.id, "a");
    graph.setBulkLoad(true);
    /*
     * In incremental update mode Cardinality.single would clean old
     * values when a new value is set.  If bulk load is working we
     * should see three values and no removes.  Breaks the semantics
     * of Cardinality.single which is why bulk load should be used with
     * care.
     */
    a.property(Cardinality.single, "key", "v1");
    a.property(Cardinality.single, "key", "v2");
    a.property(Cardinality.single, "key", "v3");
    graph.commit();
    graph.setBulkLoad(false);
    
    // bulk load should be off again
    assertFalse(graph.isBulkLoad());
    // three properties
    assertEquals(3, a.properties().count());
    // zero removes
    assertEquals(0, edits.stream().filter(e -> e.getAction() == Action.Remove).count());
    
}
 
Example #10
Source File: ArangoDBVertex.java    From arangodb-tinkerpop-provider with Apache License 2.0 4 votes vote down vote up
@Override
public <V> VertexProperty<V> property(
	Cardinality cardinality,
	String key,
	V value,
	Object... keyValues) {
	logger.debug("setting vertex property {} = {} ({})", key, value, keyValues);
	ElementHelper.validateProperty(key, value);
	ElementHelper.legalPropertyKeyValueArray(keyValues);
	Optional<Object> idValue = ElementHelper.getIdValue(keyValues);
	String id = null;
	if (idValue.isPresent()) {
		if (graph.features().vertex().willAllowId(idValue.get())) {
			id = idValue.get().toString();
			if (id.toString().contains("/")) {
        		String fullId = id.toString();
        		String[] parts = fullId.split("/");
        		// The collection name is the last part of the full name
        		String[] collectionParts = parts[0].split("_");
				String collectionName = collectionParts[collectionParts.length-1];
				if (collectionName.contains(ArangoDBGraph.ELEMENT_PROPERTIES_COLLECTION)) {
        			id = parts[1];
        			
        		}
        	}
	        Matcher m = ArangoDBUtil.DOCUMENT_KEY.matcher((String)id);
			if (!m.matches()) {
				throw new ArangoDBGraphException(String.format("Given id (%s) has unsupported characters.", id));
	    	}
		}
		else {
			throw VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported();
		}
		int idIndex = 0;
           for (int i = 0; i < keyValues.length; i+=2) {
               if (keyValues[i] == T.id) {
                   idIndex = i;
                   break;
               }
           }
           keyValues = ArrayUtils.remove(keyValues, idIndex);
           keyValues = ArrayUtils.remove(keyValues, idIndex);
	}
       final Optional<VertexProperty<V>> optionalVertexProperty = ElementHelper.stageVertexProperty(this, cardinality, key, value, keyValues);
       if (optionalVertexProperty.isPresent()) return optionalVertexProperty.get();
       

       ArangoDBVertexProperty<V> p = ArangoDBUtil.createArangoDBVertexProperty(id, key, value, this);
       ElementHelper.attachProperties(p, keyValues);
	return p;
}
 
Example #11
Source File: SampleCode.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Demonstration of the history API.
 * <p>
 * The history API is closely related to the listener API in that the unit
 * of information is the same - BlazeGraphEdits. With the history API, you
 * can look back in time on the history of the graph - when vertices and
 * edges were added or removed or what the property history looks like for
 * individual elements. With the history API you specify the element ids of
 * interest and get back an iterator of edits for those ids. The history
 * information is also modeled using RDF*, meaning the history is part of
 * the raw RDF graph itself. Thus the history information can also be
 * accessed via Sparql.
 * </p>
 */
@Test
public void demonstrateHistoryAPI() throws Exception {
    
    /*
     * Add a vertex.
     */
    final BlazeVertex a = graph.addVertex(T.id, "a");
    graph.tx().commit();
    
    /*
     * Add a property.
     */
    a.property(Cardinality.single, "key", "foo");
    graph.tx().commit();
    
    /*
     * Change the value.
     */
    a.property(Cardinality.single, "key", "bar");
    graph.tx().commit();
    
    /*
     * Remove the vertex.
     */
    a.remove();
    graph.tx().commit();

    /*
     * Get the history, which should be the following:
     * 
     * 1. VertexAtom("a"), action=add, time=t0
     * 2. VertexPropertyAtom("key"="foo"), action=add, time=t1
     * 3. VertexPropertyAtom("key"="foo"), action=remove, time=t2
     * 4. VertexPropertyAtom("key"="bar"), action=add, time=t2
     * 5. VertexPropertyAtom("key"="bar"), action=remove, time=t3
     * 6. VertexAtom("a"), action=add, time=t3
     */
    List<BlazeGraphEdit> history = graph.history("a").collect();
    assertEquals(6, history.size());
    
    log.info(() -> history.stream());
    
}
 
Example #12
Source File: SampleCode.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Demonstration of the bulk load API.
 * <p>
 * The bulk load API provides a means of fast unchecked loading of data into
 * Blazegraph. By default, Blazegraph/TP3 is in "incremental update" mode.
 * Incremental update does strict checking on vertex and edge id re-use and
 * enforcement of property key cardinality. Both of these validations
 * require a read against the database indices. Blazegraph benefits greatly
 * from buffering and batch inserting statements into the database indices.
 * Buffering and batch insert are defeated by interleaving reads and removes
 * into the loading process, which is what happens with the normal
 * validation steps in incremental update mode. The bulk load API is a means
 * of bypassing the strict validation that normally occurs in incremental
 * update mode. The bulk load API is suitable for use in loading
 * "known-good" datasets - datasets that have already been validated for
 * consistency errors.
 * </p>
 */
@Test
public void demonstrateBulkLoadAPI() throws Exception {
    
    /*
     * Bulk load another graph.
     */
    final TinkerGraph theCrew = TinkerFactory.createTheCrew();
    graph.bulkLoad(theCrew);
    graph.tx().commit();
    
    assertEquals(6, graph.vertexCount());
    
    /*
     * Execute a code block in bulk load mode.
     */
    graph.bulkLoad(() -> {
        graph.addVertex(T.id, "a");
        graph.addVertex(T.id, "b");
    });
    graph.tx().commit();
    
    assertEquals(8, graph.vertexCount());
    
    /*
     * Manually set and reset bulk load mode. 
     */
    graph.setBulkLoad(true);
    graph.addVertex(T.id, "c");
    graph.addVertex(T.id, "d");
    graph.setBulkLoad(false);
    graph.tx().commit();

    assertEquals(10, graph.vertexCount());

    /*
     * Be careful not to introduce consistency errors while in bulk load
     * mode. 
     */
    graph.bulkLoad(() -> {
        final BlazeVertex e = graph.addVertex(T.id, "e", T.label, "foo");
        e.property(Cardinality.single, "key", "v1");
        e.property(Cardinality.single, "key", "v2");
        /*
         * Consistency error - cardinality enforcement has been bypassed,
         * resulting in two values for Cardinality.single.
         */
        assertEquals(2, e.properties("key").count());
        
        graph.addVertex(T.id, "e", T.label, "bar");
        /*
         * Consistency error - we've created a new vertex with the same id
         * as an existing one.
         */
        assertEquals(2, graph.vertices("e").count());
    });
    graph.tx().rollback();
    
    assertEquals(10, graph.vertexCount());

    try (CloseableIterator<Vertex> it = graph.vertices()) {
        log.info(() -> it.stream());
    }
    
}
 
Example #13
Source File: TestListeners.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public void testVertexProperties() throws Exception {
        
        final List<BlazeGraphEdit> edits = new LinkedList<>();
        graph.addListener((edit,rdfEdit) -> edits.add(edit));
        
        final BlazeVertex a = graph.addVertex(T.id, "a");
        final BlazeVertexProperty<Integer> _1 = a.property(Cardinality.set, "foo", 1, "acl", "public");
        final BlazeVertexProperty<Integer> _2 = a.property(Cardinality.set, "foo", 2, "acl", "private");
//        final BlazeVertex b = graph.addVertex(T.id, "b");
        graph.commit();
        
        log.debug(() -> "\n"+graph.dumpStore());
        log.debug(() -> edits.stream());
//        assertEquals(5, graph.statementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(2, a.properties().count());
        assertEquals(1, _1.properties().count());
        assertEquals(1, _2.properties().count());
        assertEquals(5, edits.size());

        _1.properties().forEachRemaining(p -> p.remove());
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        log.debug(() -> edits.stream());
//        assertEquals(4, graph.statementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(2, a.properties().count());
        assertEquals(0, _1.properties().count());
        assertEquals(1, _2.properties().count());
        assertEquals(6, edits.size());
        
        _2.remove();
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        log.debug(() -> edits.stream());
//        assertEquals(2, graph.statementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(1, a.properties().count());
        assertEquals(8, edits.size());
        
        a.remove();
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        log.debug(() -> edits.stream());
//        assertEquals(0, graph.statementCount());
        assertEquals(0, graph.vertexCount());
        assertEquals(10, edits.size());
        
    }
 
Example #14
Source File: TestBasicOperations.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public void testRollback() throws Exception {
    
    final Vertex v1 = graph.addVertex("name", "marko");
    final Edge e1 = v1.addEdge("l", v1, "name", "xxx");
    graph.commit();
    
    assertEquals(v1.id(), graph.vertices(v1.id()).next().id());
    assertEquals(e1.id(), graph.edges(e1.id()).next().id());
    assertEquals("marko", v1.<String>value("name"));
    assertEquals("xxx", e1.<String>value("name"));

    assertEquals("marko", v1.<String>value("name"));
    assertEquals("marko", graph.vertices(v1.id()).next().<String>value("name"));

    v1.property(VertexProperty.Cardinality.single, "name", "stephen");

    assertEquals("stephen", v1.<String>value("name"));
    assertEquals("stephen", graph.vertices(v1.id()).next().<String>value("name"));

    graph.rollback();

    assertEquals("marko", v1.<String>value("name"));
    assertEquals("marko", graph.vertices(v1.id()).next().<String>value("name"));

}
 
Example #15
Source File: TestBasicOperations.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public void testSwitchCardinality() throws Exception {
    
    final BlazeVertex a = graph.addVertex(T.id, "a");
    a.property(Cardinality.list, "foo", "bar", "acl", "public");
    a.property(Cardinality.list, "foo", "baz", "acl", "public");
    a.property(Cardinality.list, "foo", "bar", "acl", "private");

    log.debug(() -> "\n"+graph.dumpStore());

    a.property(Cardinality.single, "foo", "single", "acl", "public");

    log.debug(() -> "\n"+graph.dumpStore());
    
    assertEquals(1, a.properties().count());
    
}
 
Example #16
Source File: TestHistory.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
public void testVertexPropertyHistory() throws Exception {
        
        final BlazeVertex a = graph.addVertex(T.id, "a");
        final BlazeVertexProperty<Integer> _1 = a.property(Cardinality.set, "foo", 1, "acl", "public");
        final BlazeVertexProperty<Integer> _2 = a.property(Cardinality.set, "foo", 2, "acl", "private");
//        final BlazeVertex b = graph.addVertex(T.id, "b");
        graph.commit();
        
        log.debug(() -> "\n"+graph.dumpStore());
        assertEquals(10, graph.historicalStatementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(2, a.properties().count());
        assertEquals(1, _1.properties().count());
        assertEquals(1, _2.properties().count());

        _1.properties().forEachRemaining(p -> p.remove());
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        assertEquals(11, graph.historicalStatementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(2, a.properties().count());
        assertEquals(0, _1.properties().count());
        assertEquals(1, _2.properties().count());
        
        countEdits(3, "a");
        
        try {
            graph.history(_1.id(), _2.id());
            fail("History not supported for VertexProperty elements");
        } catch (IllegalArgumentException ex) {}
        
        _2.remove();
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        assertEquals(13, graph.historicalStatementCount());
        assertEquals(1, graph.vertexCount());
        assertEquals(1, a.properties().count());
        countEdits(4, "a");
        
        a.remove();
        graph.commit();
        log.debug(() -> "\n"+graph.dumpStore());
        assertEquals(15, graph.historicalStatementCount());
        assertEquals(0, graph.vertexCount());
        countEdits(6, "a");
        
    }
 
Example #17
Source File: BlazeVertex.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Strengthen return type to {@link BlazeVertexProperty} and use 
 * Cardinality.single by default.
 */
@Override
public <V> BlazeVertexProperty<V> property(final String key, final V val) {
    return property(Cardinality.single, key, val);
}
 
Example #18
Source File: BlazeGraph.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper for {@link BlazeVertex#property(Cardinality, String, Object, Object...)}.
 * 
 * @param vertex the BlazeVertex
 * @param cardinality the property cardinality
 * @param key the property key
 * @param val the property value
 * @param kvs the properties to attach to the BlazeVertexProperty
 * @return a BlazeVertexProperty
 */
<V> BlazeVertexProperty<V> vertexProperty(final BlazeVertex vertex, 
        final Cardinality cardinality, final String key, final V val,
        final Object... kvs) {
    final BigdataValueFactory rdfvf = rdfValueFactory();
    final URI s = vertex.rdfId();
    final URI p = rdfvf.asValue(vf.propertyURI(key));
    final Literal lit = rdfvf.asValue(vf.toLiteral(val));
    
    final BigdataStatement stmt;
    if (cardinality == Cardinality.list) {
        final Literal timestamp = rdfvf.createLiteral(
                String.valueOf(vpIdFactory.getAndIncrement()), 
                LI_DATATYPE);
        stmt = rdfvf.createStatement(s, p, timestamp);
    } else {
        stmt = rdfvf.createStatement(s, p, lit);
    }
    final BigdataBNode sid = rdfvf.createBNode(stmt);
    final String vpId = vertexPropertyId(stmt);
    
    final RepositoryConnection cxn = cxn();
    Code.wrapThrow(() -> {
        if (cardinality == Cardinality.list) {
            // <s> <key> timestamp .
            cxn.add(stmt);
            // <<<s> <key> timestamp>> rdf:value "val" .
            cxn.add(sid, VALUE, lit);
        } else {
            if (cardinality == Cardinality.single && !bulkLoad) {
                final String queryStr = sparql.cleanVertexProps(s, p, lit);
                update(queryStr);
            }
            // << stmt >> <key> "val" .
            cxn.add(stmt);
        }
    });
    
    final BlazeProperty<V> prop = 
            new BlazeProperty<>(this, vertex, p, lit);
    final BlazeVertexProperty<V> bvp =
            new BlazeVertexProperty<>(prop, vpId, sid);
    ElementHelper.attachProperties(bvp, kvs);
    return bvp;
}
 
Example #19
Source File: BitsyAutoReloadingVertex.java    From bitsy with Apache License 2.0 4 votes vote down vote up
@Override
public <V> VertexProperty<V> property(Cardinality cardinality, String key, V value, Object... keyValues) {
	return getBaseVertex().property(cardinality, key, value, keyValues);
}
 
Example #20
Source File: BlazeGraphFeatures.java    From tinkerpop3 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Really you would need to perform a Sparql query to ascertain this,
 * unless you have a fixed application schema.  Returns Cardinality.set
 * by default since that is the closest match to RDF.
 */
@Override
public Cardinality getCardinality(final String key) {
    return Cardinality.set;
}