Repository: thinkaurelius/titan

Issue #988: Query matches old property value(s)
Created: 2015-03-25T15:30:35Z
Titan 0.5.4. When subsequently setting different values on the same vertex property, queries find the vertex by old values. To reproduce:
        final Map<String, Object> map = new HashMap<String, Object>();
        //map.put(GraphDatabaseConfiguration.AUTO_TYPE.getName(), "none");

        map.put(GraphDatabaseConfiguration.STORAGE_NS.getName() +"."+ GraphDatabaseConfiguration.STORAGE_BACKEND.getName(), "cassandra");
        map.put(GraphDatabaseConfiguration.STORAGE_NS.getName() +"."+ GraphDatabaseConfiguration.STORAGE_HOSTS.getName(), new String[] {"127.0.0.1"});
        map.put(GraphDatabaseConfiguration.STORAGE_NS.getName() +"."+ "cassandra.keyspace", "OldPropertyTest");
        map.put(GraphDatabaseConfiguration.STORAGE_NS.getName() +"."+ GraphDatabaseConfiguration.CONNECTION_TIMEOUT.getName(), new StandardDuration(60 * 1000, TimeUnit.MILLISECONDS));
        map.put(GraphDatabaseConfiguration.SCHEMA_NS.getName() +"."+ GraphDatabaseConfiguration.AUTO_TYPE.getName(), "none");

        map.put(GraphDatabaseConfiguration.QUERY_NS.getName()+".force-index", Boolean.TRUE);

        ReadConfiguration config = new ReadConfiguration() {

            @Override
            public Iterable<String> getKeys(String arg0) {
                final Set<String> sub = new HashSet<String>();
                for(Entry<String, Object> e : map.entrySet()){
                    if(e.getKey().startsWith(arg0)){
                        sub.add(e.getKey());
                    }
                }
                return new Iterable<String>() {
                    @Override
                    public Iterator<String> iterator() {
                        return sub.iterator();
                    }
                }; 
            }

            @SuppressWarnings("unchecked")
            @Override
            public <O> O get(String arg0, Class<O> arg1) {
                return (O)map.get(arg0);
            }

            @Override
            public void close() {
                // TODO Auto-generated method stub
            }
        };

        GraphDatabaseConfiguration graphconfig = new GraphDatabaseConfiguration(config);
        try {
            graphconfig.getBackend().clearStorage();
        } catch (BackendException e) {
            e.printStackTrace();
        }

        TitanGraph graph = TitanFactory.open(config);

        String NAME = "NAME";
        TitanManagement ms = graph.getManagementSystem();
        if (ms.getPropertyKey(NAME) == null) {
            ms.makePropertyKey(NAME).dataType(String.class).cardinality(Cardinality.SINGLE).make();
            ms.buildIndex("IDX_"+NAME, Vertex.class)
                    .addKey(ms.getPropertyKey(NAME))
                    .buildCompositeIndex();
        }
        ms.commit();
        graph.rollback();


        String aaName = "aName";
        String bbName = "bName";
        {
            Vertex v = graph.addVertex(null);
            Object vID = v.getId();
            v.setProperty(NAME, aaName);
            graph.commit();
            v = graph.getVertex(vID);

            //if following line is uncommented, then works as expected
            //v.removeProperty(NAME);

            v.setProperty(NAME, bbName);
            graph.commit();

            {
                int count = 0;
                for (Object o : graph.query().has(NAME,aaName).vertices()) {
                    Vertex v1 = (Vertex) o;
                    System.out.println(aaName+" "+v1+" "+v1.getProperty(NAME));
                    count++;
                }
                System.out.println("Verices found: "+count);
            }
        }
        graph.shutdown();
        graph = null;

Duplicate issue #938: Add no-check consistency modifier
Created: 2015-01-24T00:34:48Z
Currently, Titan will check if adding an edge or setting a property will violate a consistency constraint. That requires issuing a query which has performance implications. In some cases you just want to replace whatever is there without such a check. For this, we should have the NO_CHECK consistency modifier.

Closing comment (2015-04-14T23:04:18Z): However, we need to be really careful here. If there is an index (external or vertex-centric) associated with that key/label, then we still need to read the original property/edge so that we properly update the index structures.
Related to #988