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 disturbed by a question that implementing p=
ut 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 o=
ne versions,get(key,null) also throw an "InconsistentDataExcepti=
on" Exception. So it seems no meaning to do so<div> <=
br><div><div> public Version put(K key, V value) {</div><div>&=
nbsp; List<Version> versions =3D getVersions(key=
);</div><div> Versioned<V> versioned;</div=
><div> if(versions.isEmpty())</div><div> &=
nbsp; versioned =3D Versioned.value(value, new =
VectorClock());</div><div> else if(versions.size=
() =3D=3D 1)</div><div> versioned =
=3D Versioned.value(value, versions.get(0));</div><div> =
else {</div><div> versione=
d =3D get(key, null);</div><div> i=
f(versioned =3D=3D null)</div><div>  =
; versioned =3D Versioned.value(value, new VectorClock());</d=
iv><div> else</div><div> &nb=
sp; versioned.setObject(value);</=
div><div> }</div><div>  =
; return put(key, versioned);</div><div> }</div></div></div>
------=_Part_354_20801166.1350142337445--
------=_Part_353_20676533.1350142337445--