Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 22a9f96 + 2227eeb commit aaa247cf642ea6e92f45b694863e2720d042a35a @sudiptodas committed Nov 22, 2011
@@ -21,6 +21,10 @@ REDIS_FILE=jedis-2.0.0.jar
VOLDEMORT_DIR=db/voldemort/lib
VOLDEMORT_FILE=voldemort-0.90.1.tar.gz
+.PHONY: build
+build: download-database-deps
+ ant -q -e compile
+ grep name=\"dbcompile build.xml | perl -ne '$$_=~/name=\"(.+)\"\s+depends/; print "$$1\n"; system "ant -q -e $$1"'
download-database-deps: $(CASSANDRA_5_DIR)/$(CASSANDRA_5_FILE) \
$(CASSANDRA_6_DIR)/$(CASSANDRA_6_FILE) \
@@ -35,7 +39,7 @@ download-database-deps: $(CASSANDRA_5_DIR)/$(CASSANDRA_5_FILE) \
$(CASSANDRA_5_DIR)/$(CASSANDRA_5_FILE) :
wget http://archive.apache.org/dist/cassandra/0.5.1/$(CASSANDRA_5_FILE)\
-O $(CASSANDRA_5_DIR)/$(CASSANDRA_5_FILE)
- tar -C $(CASSANDRA_5_DIR) -zxf $(CASSANDRA_6_DIR)/$(CASSANDRA_5_FILE)
+ tar -C $(CASSANDRA_5_DIR) -zxf $(CASSANDRA_5_DIR)/$(CASSANDRA_5_FILE)
$(CASSANDRA_6_DIR)/$(CASSANDRA_6_FILE) :
wget http://archive.apache.org/dist/cassandra/0.6.13/$(CASSANDRA_6_FILE)\
View
@@ -15,8 +15,6 @@
</fileset>
</path>
- <target name="dbcompile-all" depends="dbcompile-infinispan-5.0,dbcompile-cassandra-0.5,dbcompile-cassandra-0.6,dbcompile-cassandra-0.7,dbcompile-cassandra-0.8,dbcompile-hbase,dbcompile-mongodb,dbcompile-voldemort,dbcompile-jdbc,dbcompile-redis"/>
-
<target name="dbcompile-infinispan-5.0" depends="compile">
<property name="db.dir" value="db/infinispan-5.0" />
<antcall target="dbcompile" />
@@ -69,20 +67,20 @@
<target name="compile">
<mkdir dir="${classes.dir}"/>
- <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="build.classpath" deprecation="on">
+ <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="build.classpath" deprecation="on">
<compilerarg value="-Xlint:unchecked"/>
</javac>
<antcall target="makejar"/>
</target>
- <target name="dbcompile">
+ <target name="dbcompile">
<path id="dbclasspath">
<fileset dir="${db.dir}/lib" includes="**/*.jar"/>
<fileset file="build/ycsb.jar"/>
</path>
<mkdir dir="${classes.dir}"/>
- <javac srcdir="${db.dir}/src" destdir="${classes.dir}" classpathref="dbclasspath" deprecation="on">
+ <javac includeantruntime="false" srcdir="${db.dir}/src" destdir="${classes.dir}" classpathref="dbclasspath" deprecation="on">
<compilerarg value="-Xlint:unchecked"/>
</javac>
<antcall target="makejar"/>
View
@@ -18,6 +18,10 @@
* gh-44 Constant occupancy workload (sears)
* gh-45 Modify DB API for efficient large object support (sears)
* gh-46 Fixed typo in RedisClient (Zlender)
+ * gh-49 Build fix (sears)
+ * gh-50 Switch unordered key generation from FNV32 to FNV64 (sears)
+ * gh-51 Improved Random Number Generation Performance and add Exponential distribution support (sears)
+ * gh-52 Mongo db fix (sears)
0.1.3
* Voldemort binding (rsumbaly)
@@ -442,9 +442,9 @@ public static void main(String[] args)
}
HashMap<String,ByteIterator> vals=new HashMap<String,ByteIterator>();
- vals.put("age","57");
- vals.put("middlename","bradley");
- vals.put("favoritecolor","blue");
+ vals.put("age",new StringByteIterator("57"));
+ vals.put("middlename",new StringByteIterator("bradley"));
+ vals.put("favoritecolor",new StringByteIterator("blue"));
int res=cli.insert("usertable","BrianFrankCooper",vals);
System.out.println("Result of insert: "+res);
@@ -14,6 +14,7 @@
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
+import java.util.Map;
import java.util.Vector;
import org.bson.types.ObjectId;
@@ -147,8 +148,9 @@ public int insert(String table, String key, HashMap<String, ByteIterator> values
DBCollection collection = db.getCollection(table);
DBObject r = new BasicDBObject().append("_id", key);
- r.putAll(values);
-
+ for(String k: values.keySet()) {
+ r.put(k, values.get(k).toString());
+ }
collection.setWriteConcern(writeConcern);
collection.insert(r);
@@ -21,7 +21,6 @@
import java.util.Properties;
import java.util.Set;
import java.util.Enumeration;
-import java.util.Random;
import java.util.Vector;
@@ -37,13 +36,11 @@
public static final String SIMULATE_DELAY_DEFAULT="0";
- Random random;
boolean verbose;
int todelay;
public BasicDB()
{
- random=new Random();
todelay=0;
}
@@ -54,7 +51,7 @@ void delay()
{
try
{
- Thread.sleep((long)random.nextInt(todelay));
+ Thread.sleep((long)Utils.random().nextInt(todelay));
}
catch (InterruptedException e)
{
@@ -137,8 +137,6 @@ public void run()
*/
class ClientThread extends Thread
{
- static Random random=new Random();
-
DB _db;
boolean _dotransactions;
Workload _workload;
@@ -215,7 +213,7 @@ public void run()
//and the sleep() doesn't make sense for granularities < 1 ms anyway
if ( (_target>0) && (_target<=1.0) )
{
- sleep(random.nextInt((int)(1.0/_target)));
+ sleep(Utils.random().nextInt((int)(1.0/_target)));
}
}
catch (InterruptedException e)
@@ -16,10 +16,7 @@
*/
package com.yahoo.ycsb;
-import java.util.Random;
-
public class RandomByteIterator extends ByteIterator {
- static Random random=new Random();
long len;
long off;
int buf_off;
@@ -31,7 +28,7 @@ public boolean hasNext() {
}
private void fillBytesImpl(byte[] buf, int base) {
- int bytes = random.nextInt();
+ int bytes = Utils.random().nextInt();
try {
buf[base+0] = (byte)(((bytes ) & 31) + ' ');
buf[base+1] = (byte)(((bytes >> 5 ) & 31) + ' ');
@@ -44,8 +44,8 @@ public static void putAllAsStrings(Map<String, String> out, Map<String, ByteIter
* Create a copy of a map, converting the values from Strings to
* StringByteIterators.
*/
- public static Map<String, ByteIterator> getByteIteratorMap(Map<String, String> m) {
- Map<String, ByteIterator> ret =
+ public static HashMap<String, ByteIterator> getByteIteratorMap(Map<String, String> m) {
+ HashMap<String, ByteIterator> ret =
new HashMap<String,ByteIterator>();
for(String s: m.keySet()) {
@@ -58,8 +58,8 @@ public static void putAllAsStrings(Map<String, String> out, Map<String, ByteIter
* Create a copy of a map, converting the values from
* StringByteIterators to Strings.
*/
- public static Map<String, String> getStringMap(Map<String, ByteIterator> m) {
- Map<String, String> ret = new HashMap<String,String>();
+ public static HashMap<String, String> getStringMap(Map<String, ByteIterator> m) {
+ HashMap<String, String> ret = new HashMap<String,String>();
for(String s: m.keySet()) {
ret.put(s, m.get(s).toString());;
@@ -24,8 +24,17 @@
*/
public class Utils
{
- static Random random=new Random();
-
+ private static final Random rand = new Random();
+ private static final ThreadLocal<Random> rng = new ThreadLocal<Random>();
+
+ public static Random random() {
+ Random ret = rng.get();
+ if(ret == null) {
+ ret = new Random(rand.nextLong());
+ rng.set(ret);
+ }
+ return ret;
+ }
/**
* Generate a random ASCII string of a given length.
*/
@@ -34,7 +43,7 @@ public static String ASCIIString(int length)
int interval='~'-' '+1;
byte []buf = new byte[length];
- random.nextBytes(buf);
+ random().nextBytes(buf);
for (int i = 0; i < length; i++) {
if (buf[i] < 0) {
buf[i] = (byte)((-buf[i] % interval) + ' ');
@@ -48,9 +57,9 @@ public static String ASCIIString(int length)
/**
* Hash an integer value.
*/
- public static int hash(int val)
+ public static long hash(long val)
{
- return FNVhash32(val);
+ return FNVhash64(val);
}
public static final int FNV_offset_basis_32=0x811c9dc5;
@@ -17,34 +17,39 @@
package com.yahoo.ycsb.generator;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* Generates a sequence of integers 0, 1, ...
*/
public class CounterGenerator extends IntegerGenerator
{
- int counter;
+ final AtomicInteger counter;
/**
* Create a counter that starts at countstart
*/
public CounterGenerator(int countstart)
{
- counter=countstart;
- setLastInt(countstart-1);
+ counter=new AtomicInteger(countstart);
+ setLastInt(counter.get()-1);
}
/**
* If the generator returns numeric (integer) values, return the next value as an int. Default is to return -1, which
* is appropriate for generators that do not return numeric values.
*/
- public synchronized int nextInt()
+ public int nextInt()
{
- int lastint=counter;
- counter++;
- setLastInt(lastint);
- return lastint;
+ int ret = counter.getAndIncrement();
+ setLastInt(ret);
+ return ret;
+ }
+ @Override
+ public int lastInt()
+ {
+ return counter.get() - 1;
}
-
@Override
public double mean() {
throw new UnsupportedOperationException("Can't compute mean of non-stationary distribution!");
@@ -20,6 +20,7 @@
import java.util.Vector;
import java.util.Random;
+import com.yahoo.ycsb.Utils;
import com.yahoo.ycsb.WorkloadException;
/**
@@ -40,13 +41,11 @@
}
Vector<Pair> _values;
- Random _random;
String _lastvalue;
public DiscreteGenerator()
{
_values=new Vector<Pair>();
- _random=new Random();
_lastvalue=null;
}
@@ -62,7 +61,7 @@ public String nextString()
sum+=p._weight;
}
- double val=_random.nextDouble();
+ double val=Utils.random().nextDouble();
for (Pair p : _values)
{
Oops, something went wrong. Retry.

0 comments on commit aaa247c

Please sign in to comment.