question for put(K key,V value) in DefaultStoreClient.java

45 views
Skip to first unread message

Evan Zeng

unread,
Oct 13, 2012, 11:32:17 AM10/13/12
to project-...@googlegroups.com
recently I am having being studying voldemort's source code for detail implementation,and today  disturbed by a question that implementing put operator in DefaultStoreClient.java. My question is that what's the difference between getVersion(key) and get(key,null) except that "get" can return useless value.In my opinion, if getVersion can get more than one versions,get(key,null)  also throw an "InconsistentDataException" Exception.  So it seems no  meaning to do so
 
    public Version put(K key, V value) {
        List<Version> versions = getVersions(key);
        Versioned<V> versioned;
        if(versions.isEmpty())
            versioned = Versioned.value(value, new VectorClock());
        else if(versions.size() == 1)
            versioned = Versioned.value(value, versions.get(0));
        else {
            versioned = get(key, null);
            if(versioned == null)
                versioned = Versioned.value(value, new VectorClock());
            else
                versioned.setObject(value);
        }
        return put(key, versioned);
    }

Vinoth Chandar

unread,
Oct 16, 2012, 2:26:54 PM10/16/12
to project-...@googlegroups.com
Hi,

I don't think getVersion(k) is used anymore.

If you are asking about the difference between get and getVersions, its pretty much self explanatory. getVersion fetches the version of the value alone (It can fetch multiple versions for the same key, if they exist and can't be auto merged). get does the same thing, except, it will return the actual value too.

Hope that helps.

-Vinoth
Reply all
Reply to author
Forward
0 new messages