Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion question for put(K key,V value) in DefaultStoreClient.java

Date: Sat, 13 Oct 2012 08:32:17 -0700 (PDT)
From: Evan Zeng <evanzen...@gmail.com>
To: project-voldemort@googlegroups.com
Message-Id: <9f75f009-ee5a-4193-9a68-0cc44906cea5@googlegroups.com>
Subject: question for put(K key,V value)  in DefaultStoreClient.java
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_353_20676533.1350142337445"

------=_Part_353_20676533.1350142337445
Content-Type: multipart/alternative; 
	boundary="----=_Part_354_20801166.1350142337445"

------=_Part_354_20801166.1350142337445
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

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);
    }

------=_Part_354_20801166.1350142337445
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

recently I am having being studying voldemort's source code for detail impl=
ementation,and today &nbsp;disturbed by a question that&nbsp;implementing p=
ut&nbsp;operator&nbsp;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 o=
ne versions,get(key,null)&nbsp;&nbsp;also throw an "InconsistentDataExcepti=
on"&nbsp;Exception. &nbsp;So it seems no &nbsp;meaning to do so<div>&nbsp;<=
br><div><div>&nbsp; &nbsp; public Version put(K key, V value) {</div><div>&=
nbsp; &nbsp; &nbsp; &nbsp; List&lt;Version&gt; versions =3D getVersions(key=
);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Versioned&lt;V&gt; versioned;</div=
><div>&nbsp; &nbsp; &nbsp; &nbsp; if(versions.isEmpty())</div><div>&nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; versioned =3D Versioned.value(value, new =
VectorClock());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; else if(versions.size=
() =3D=3D 1)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; versioned =
=3D Versioned.value(value, versions.get(0));</div><div>&nbsp; &nbsp; &nbsp;=
 &nbsp; else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; versione=
d =3D get(key, null);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=
f(versioned =3D=3D null)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; versioned =3D Versioned.value(value, new VectorClock());</d=
iv><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; versioned.setObject(value);</=
div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp=
; return put(key, versioned);</div><div>&nbsp; &nbsp; }</div></div></div>
------=_Part_354_20801166.1350142337445--

------=_Part_353_20676533.1350142337445--