incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1220353 [10/11] - in /incubator/lcf/branches/CONNECTORS-286/warthog-reimport: ./ src/main/java/org/apache/warthog/api/ src/main/java/org/apache/warthog/bytekeyvalue/ src/main/java/org/apache/warthog/common/ src/main/java/org/apache/warthog...
Date Sun, 18 Dec 2011 08:36:56 GMT
Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java Sun Dec 18 08:36:52 2011
@@ -1,172 +1,172 @@
-/* $Id: InMemTransactionImpl.java 1208500 2011-11-30 16:38:45Z kwright $ */
-
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.apache.warthog.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import java.util.*;
-
-/** This class implements a transaction that is in progress, completely in memory.
-*/
-public class InMemTransactionImpl implements WHTransaction
-{
-  protected WHAtomicKeyValueStore underlyingStore;
-  
-  protected KeyMap checkData = new KeyMap();
-  protected KeyMap localData = null;
-
-  /** Constructor */
-  public InMemTransactionImpl(WHAtomicKeyValueStore underlyingStore)
-  {
-    this.underlyingStore = underlyingStore;
-  }
-  
-  /** Set a value.  May be null. */
-  public void put(WHKey key, WHKeyValue value)
-    throws WHException
-  {
-    if (localData == null)
-      localData = new KeyMap();
-    localData.put(key,value);
-  }
-
-  /** Get a value.  Null returned if no value. */
-  public WHKeyValue get(WHKey key)
-    throws WHException
-  {
-    if (localData != null)
-    {
-      if (localData.containsKey(key))
-        return localData.get(key);
-    }
-    if (checkData.containsKey(key))
-      return checkData.get(key);
-    WHKeyValue value = underlyingStore.get(key);
-    checkData.put(key,value);
-    return value;
-  }
-
-  /** Check to see if this transaction has become inconsistent.
-  * If so, a WHDeadlockException is thrown.
-  */
-  public void check()
-    throws WHException
-  {
-    underlyingStore.check(checkData);
-  }
-
-  /** Commit this transaction */
-  public void commit()
-    throws WHException
-  {
-    if (localData != null)
-      underlyingStore.setAll(checkData,localData);
-    else
-      underlyingStore.check(checkData);
-  }
-  
-  /** Abandon this transaction.
-  * This is called as a nicety to free any resources associated with the
-  * transaction.  The implementation should also be robust as far as
-  * freeing resources if this method is NOT called, but might perform
-  * the necessary logic in a finalizer at an arbitrary time.
-  */
-  public void abandon()
-  {
-    // Does nothing so long as the entire temporary transaction is in
-    // memory.
-  }
-
-  /** Local implementation of WHKey/WHValue map */
-  protected static class KeyMap implements WHKeyMap
-  {
-    protected Map<WrappedKey,WHKeyValue> map = new HashMap<WrappedKey,WHKeyValue>();
-    
-    public KeyMap()
-    {
-    }
-    
-    /** Get a value from the map.
-    */
-    public WHKeyValue get(WHKey key)
-      throws WHException
-    {
-      return map.get(new WrappedKey(key));
-    }
-    
-    /** Iterate over the keys in the map.
-    */
-    public WHKeyIterator iterator()
-      throws WHException
-    {
-      return new KeyIterator(map.keySet().iterator());
-    }
-
-    /** Get the size of the map.
-    */
-    public long size()
-      throws WHException
-    {
-      return (long)map.size();
-    }
-
-    /** Check if the map contains the specified key.
-    */
-    public boolean containsKey(WHKey key)
-    {
-      return map.containsKey(new WrappedKey(key));
-    }
-
-    /** Put a value.
-    */
-    public void put(WHKey key, WHKeyValue value)
-    {
-      map.put(new WrappedKey(key),value);
-    }
-  }
-  
-  /** Key iterator for KeyMap */
-  protected static class KeyIterator implements WHKeyIterator
-  {
-    protected Iterator<WrappedKey> iterator;
-    
-    public KeyIterator(Iterator<WrappedKey> iterator)
-    {
-      this.iterator = iterator;
-    }
-    
-    /** Check if there is another value */
-    public boolean hasNext()
-      throws WHException
-    {
-      return iterator.hasNext();
-    }
-    
-    /** Get the next value */
-    public WHKey next()
-      throws WHException
-    {
-      return iterator.next().getKey();
-    }
-
-  }
-  
-}
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import java.util.*;
+
+/** This class implements a transaction that is in progress, completely in memory.
+*/
+public class InMemTransactionImpl implements WHTransaction
+{
+  protected WHAtomicKeyValueStore underlyingStore;
+  
+  protected KeyMap checkData = new KeyMap();
+  protected KeyMap localData = null;
+
+  /** Constructor */
+  public InMemTransactionImpl(WHAtomicKeyValueStore underlyingStore)
+  {
+    this.underlyingStore = underlyingStore;
+  }
+  
+  /** Set a value.  May be null. */
+  public void put(WHKey key, WHKeyValue value)
+    throws WHException
+  {
+    if (localData == null)
+      localData = new KeyMap();
+    localData.put(key,value);
+  }
+
+  /** Get a value.  Null returned if no value. */
+  public WHKeyValue get(WHKey key)
+    throws WHException
+  {
+    if (localData != null)
+    {
+      if (localData.containsKey(key))
+        return localData.get(key);
+    }
+    if (checkData.containsKey(key))
+      return checkData.get(key);
+    WHKeyValue value = underlyingStore.get(key);
+    checkData.put(key,value);
+    return value;
+  }
+
+  /** Check to see if this transaction has become inconsistent.
+  * If so, a WHDeadlockException is thrown.
+  */
+  public void check()
+    throws WHException
+  {
+    underlyingStore.check(checkData);
+  }
+
+  /** Commit this transaction */
+  public void commit()
+    throws WHException
+  {
+    if (localData != null)
+      underlyingStore.setAll(checkData,localData);
+    else
+      underlyingStore.check(checkData);
+  }
+  
+  /** Abandon this transaction.
+  * This is called as a nicety to free any resources associated with the
+  * transaction.  The implementation should also be robust as far as
+  * freeing resources if this method is NOT called, but might perform
+  * the necessary logic in a finalizer at an arbitrary time.
+  */
+  public void abandon()
+  {
+    // Does nothing so long as the entire temporary transaction is in
+    // memory.
+  }
+
+  /** Local implementation of WHKey/WHValue map */
+  protected static class KeyMap implements WHKeyMap
+  {
+    protected Map<WrappedKey,WHKeyValue> map = new HashMap<WrappedKey,WHKeyValue>();
+    
+    public KeyMap()
+    {
+    }
+    
+    /** Get a value from the map.
+    */
+    public WHKeyValue get(WHKey key)
+      throws WHException
+    {
+      return map.get(new WrappedKey(key));
+    }
+    
+    /** Iterate over the keys in the map.
+    */
+    public WHKeyIterator iterator()
+      throws WHException
+    {
+      return new KeyIterator(map.keySet().iterator());
+    }
+
+    /** Get the size of the map.
+    */
+    public long size()
+      throws WHException
+    {
+      return (long)map.size();
+    }
+
+    /** Check if the map contains the specified key.
+    */
+    public boolean containsKey(WHKey key)
+    {
+      return map.containsKey(new WrappedKey(key));
+    }
+
+    /** Put a value.
+    */
+    public void put(WHKey key, WHKeyValue value)
+    {
+      map.put(new WrappedKey(key),value);
+    }
+  }
+  
+  /** Key iterator for KeyMap */
+  protected static class KeyIterator implements WHKeyIterator
+  {
+    protected Iterator<WrappedKey> iterator;
+    
+    public KeyIterator(Iterator<WrappedKey> iterator)
+    {
+      this.iterator = iterator;
+    }
+    
+    /** Check if there is another value */
+    public boolean hasNext()
+      throws WHException
+    {
+      return iterator.hasNext();
+    }
+    
+    /** Get the next value */
+    public WHKey next()
+      throws WHException
+    {
+      return iterator.next().getKey();
+    }
+
+  }
+  
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java Sun Dec 18 08:36:52 2011
@@ -1,46 +1,46 @@
-/* $Id: InMemTransactionalStoreImpl.java 1205763 2011-11-24 09:15:57Z kwright $ */
-
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.apache.warthog.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-
-/** Class implementing a transactional key/value store completely in memory.
-*/
-public class InMemTransactionalStoreImpl implements WHTransactionalStore
-{
-  /** Underlying atomic key/value store */
-  protected WHAtomicKeyValueStore underlyingStore;
-  
-  /** Constructor. */
-  public InMemTransactionalStoreImpl(WHAtomicKeyValueStore underlyingStore)
-  {
-    this.underlyingStore = underlyingStore;
-  }
-  
-  /** Create a transaction. */
-  public WHTransaction createTransaction()
-    throws WHException
-  {
-    return new InMemTransactionImpl(this.underlyingStore);
-  }
-
-}
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.warthog.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+
+/** Class implementing a transactional key/value store completely in memory.
+*/
+public class InMemTransactionalStoreImpl implements WHTransactionalStore
+{
+  /** Underlying atomic key/value store */
+  protected WHAtomicKeyValueStore underlyingStore;
+  
+  /** Constructor. */
+  public InMemTransactionalStoreImpl(WHAtomicKeyValueStore underlyingStore)
+  {
+    this.underlyingStore = underlyingStore;
+  }
+  
+  /** Create a transaction. */
+  public WHTransaction createTransaction()
+    throws WHException
+  {
+    return new InMemTransactionImpl(this.underlyingStore);
+  }
+
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java Sun Dec 18 08:36:52 2011
@@ -1,473 +1,473 @@
-/* $Id: MultiThreadTest.java 1212814 2011-12-10 15:26:17Z kwright $ */
-
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.warthog.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.keyvaluetablestore.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.common.*;
-import org.junit.*;
-import static org.junit.Assert.*;
-import java.util.*;
-
-public class MultiThreadTest
-{
-
-  @Test
-  public void singleThreadBaselineTest()
-    throws Exception
-  {
-    doWrites(1);
-  }
-  
-  @Test
-  public void writeOnlyTest()
-    throws Exception
-  {
-    doWrites(24);
-  }
-  
-  protected void doWrites(int threadCount)
-    throws Exception
-  {
-    int totalInserts = 10000;
-    
-    int repeatCount = totalInserts/threadCount;
-
-    WHAtomicKeyValueStore store = new InMemAtomicNativeNonblockingKeyValueStore(16777216);
-    
-    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
-
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex1",table,
-      new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex2",table,
-      new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex3",table,
-      new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex4",table,
-      new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex5",table,
-      new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.commitTransaction();
-
-    InsertThread[] threads = new InsertThread[threadCount];
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i] = new InsertThread("Worker thread "+i,store,repeatCount);
-    }
-    
-    long startTime = System.currentTimeMillis();
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i].start();
-    }
-    
-    // Join at the end
-    
-    int contentions = 0;
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i].join();
-      Throwable e = threads[i].getException();
-      if (e != null)
-      {
-        if (e instanceof Error)
-          throw (Error)e;
-        if (e instanceof RuntimeException)
-          throw (RuntimeException)e;
-        throw (Exception)e;
-      }
-      contentions += threads[i].getContentions();
-    }
-
-    System.out.println(Integer.toString(totalInserts)+" writes across "+
-      Integer.toString(threadCount)+" threads took "+
-      new Long(System.currentTimeMillis()-startTime)+" ms and had "+
-      Integer.toString(contentions)+" contention retries");
-  }
-
-  @Test
-  public void writeQueryTest()
-    throws Exception
-  {
-    int totalCount = 10000/4;
-    int threadCount = 24;
-    
-    int repeatCount = totalCount/threadCount;
-
-    WHAtomicKeyValueStore store = new InMemAtomicNativeNonblockingKeyValueStore(16777216);
-    
-    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
-
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex1",table,
-      new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex2",table,
-      new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex3",table,
-      new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex4",table,
-      new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex5",table,
-      new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.commitTransaction();
-
-    TaskThread[] threads = new TaskThread[threadCount];
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i] = new TaskThread("Worker thread "+i,store,repeatCount);
-    }
-    
-    long startTime = System.currentTimeMillis();
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i].start();
-    }
-    
-    // Join at the end
-    
-    int contentions = 0;
-    for (int i = 0 ; i < threadCount ; i++)
-    {
-      threads[i].join();
-      Throwable e = threads[i].getException();
-      if (e != null)
-      {
-        if (e instanceof Error)
-          throw (Error)e;
-        if (e instanceof RuntimeException)
-          throw (RuntimeException)e;
-        throw (Exception)e;
-      }
-      contentions += threads[i].getContentions();
-    }
-
-    System.out.println(Integer.toString(threadCount*repeatCount)+" writes and "+
-      Integer.toString(threadCount*repeatCount*3)+" reads across "+
-      Integer.toString(threadCount)+" threads took "+
-      new Long(System.currentTimeMillis()-startTime)+" ms and had "+
-      Integer.toString(contentions)+" contention retries");
-  }
-  
-  // Protected methods
-  
-  protected static String randomString(Random r)
-  {
-    return new Long(randomLong(r)).toString();
-  }
-  
-  protected static long randomLong(Random r)
-  {
-    return r.nextLong();
-  }
-  
-  protected static class InsertThread extends Thread
-  {
-    protected int repeatCount;
-    protected int contentions = 0;
-    protected WHAtomicKeyValueStore store;
-    protected Throwable exception;
-    protected Random r = new Random();
-    
-    public InsertThread(String name, WHAtomicKeyValueStore store, int repeatCount)
-    {
-      super();
-      this.repeatCount = repeatCount;
-      this.store = store;
-      setName(name);
-    }
-    
-    public void run()
-    {
-      try
-      {
-        WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
-        performInserts(ts);
-      }
-      catch (Throwable e)
-      {
-        exception = e;
-      }
-    }
-    
-    public Throwable getException()
-    {
-      return exception;
-    }
-    
-    public int getContentions()
-    {
-      return contentions;
-    }
-    
-    protected void backOff()
-      throws InterruptedException
-    {
-      contentions++;
-      //Thread.sleep(r.nextInt(100));
-      Thread.yield();
-    }
-    
-    protected void performInserts(WHTableStore ts)
-      throws InterruptedException, WHException
-    {
-      // Task consists of a certain number of inserts and queries
-      for (int i = 0 ; i < repeatCount ; i++)
-      {
-        // Add a row
-        while (true)
-        {
-          ts.beginTransaction();
-          try
-          {
-            WHTable table = ts.lookupTable("testtable");
-            table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
-              new WHValue[]{
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r))});
-            ts.commitTransaction();
-            break;
-          }
-          catch (WHConcurrencyException e)
-          {
-            backOff();
-            continue;
-          }
-          finally
-          {
-            ts.abandonTransaction();
-          }
-        }
-      }
-    }
-    
-  }
-
-  protected static class TaskThread extends Thread
-  {
-    protected int repeatCount;
-    protected int contentions = 0;
-    protected WHAtomicKeyValueStore store;
-    protected Throwable exception;
-    protected Random r = new Random();
-    
-    public TaskThread(String name, WHAtomicKeyValueStore store, int repeatCount)
-    {
-      super();
-      this.repeatCount = repeatCount;
-      this.store = store;
-      setName(name);
-    }
-    
-    public void run()
-    {
-      try
-      {
-        WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
-        performTask(ts);
-      }
-      catch (Throwable e)
-      {
-        exception = e;
-      }
-    }
-    
-    public Throwable getException()
-    {
-      return exception;
-    }
-    
-    public int getContentions()
-    {
-      return contentions;
-    }
-    
-    protected void backOff()
-      throws InterruptedException
-    {
-      contentions++;
-      //Thread.sleep(r.nextInt(100));
-      Thread.yield();
-    }
-    
-    protected void performTask(WHTableStore ts)
-      throws InterruptedException, WHException
-    {
-      // Task consists of a certain number of inserts and queries
-      for (int i = 0 ; i < repeatCount ; i++)
-      {
-        // Add a row
-        while (true)
-        {
-          ts.beginTransaction();
-          try
-          {
-            WHTable table = ts.lookupTable("testtable");
-            table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
-              new WHValue[]{
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r)),
-                new LongValue(randomLong(r)),new StringValue(randomString(r))});
-            ts.commitTransaction();
-            break;
-          }
-          catch (WHConcurrencyException e)
-          {
-            backOff();
-            continue;
-          }
-          finally
-          {
-            ts.abandonTransaction();
-          }
-        }
-        
-        // Do a query
-        while (true)
-        {
-          ts.beginTransaction();
-          try
-          {
-            WHIndex index = ts.lookupIndex("testindex1");
-            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
-              new IndexBetween(new StringValue("1"),new StringValue("2")),
-              null},null);
-            while (true)
-            {
-              if (accessor.getCurrentRowID() == null)
-                break;
-              accessor.advance();
-            }
-            ts.commitTransaction();
-            break;
-          }
-          catch (WHConcurrencyException e)
-          {
-            backOff();
-            continue;
-          }
-          finally
-          {
-            ts.abandonTransaction();
-          }
-        }
-
-        // Do another query
-        while (true)
-        {
-          ts.beginTransaction();
-          try
-          {
-            WHIndex index = ts.lookupIndex("testindex2");
-            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
-              new IndexBetween(new StringValue("23"),new StringValue("25")),
-              null},null);
-            while (true)
-            {
-              if (accessor.getCurrentRowID() == null)
-                break;
-              accessor.advance();
-            }
-            ts.commitTransaction();
-            break;
-          }
-          catch (WHConcurrencyException e)
-          {
-            backOff();
-            continue;
-          }
-          finally
-          {
-            ts.abandonTransaction();
-          }
-        }
-
-        // Do a third query
-        while (true)
-        {
-          ts.beginTransaction();
-          try
-          {
-            WHIndex index = ts.lookupIndex("testindex3");
-            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
-              new IndexBetween(new StringValue("02"),new StringValue("04")),
-              null},null);
-            while (true)
-            {
-              if (accessor.getCurrentRowID() == null)
-                break;
-              accessor.advance();
-            }
-            ts.commitTransaction();
-            break;
-          }
-          catch (WHConcurrencyException e)
-          {
-            backOff();
-            continue;
-          }
-          finally
-          {
-            ts.abandonTransaction();
-          }
-        }
-
-      }
-    }
-    
-  }
-  
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.warthog.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.keyvaluetablestore.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.common.*;
+import org.junit.*;
+import static org.junit.Assert.*;
+import java.util.*;
+
+public class MultiThreadTest
+{
+
+  @Test
+  public void singleThreadBaselineTest()
+    throws Exception
+  {
+    doWrites(1);
+  }
+  
+  @Test
+  public void writeOnlyTest()
+    throws Exception
+  {
+    doWrites(24);
+  }
+  
+  protected void doWrites(int threadCount)
+    throws Exception
+  {
+    int totalInserts = 10000;
+    
+    int repeatCount = totalInserts/threadCount;
+
+    WHAtomicKeyValueStore store = new InMemAtomicNativeNonblockingKeyValueStore(16777216);
+    
+    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
+
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex1",table,
+      new String[]{"colB","colA"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex2",table,
+      new String[]{"colD","colC"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex3",table,
+      new String[]{"colF","colE"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex4",table,
+      new String[]{"colH","colG"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex5",table,
+      new String[]{"colJ","colI"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.commitTransaction();
+
+    InsertThread[] threads = new InsertThread[threadCount];
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i] = new InsertThread("Worker thread "+i,store,repeatCount);
+    }
+    
+    long startTime = System.currentTimeMillis();
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i].start();
+    }
+    
+    // Join at the end
+    
+    int contentions = 0;
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i].join();
+      Throwable e = threads[i].getException();
+      if (e != null)
+      {
+        if (e instanceof Error)
+          throw (Error)e;
+        if (e instanceof RuntimeException)
+          throw (RuntimeException)e;
+        throw (Exception)e;
+      }
+      contentions += threads[i].getContentions();
+    }
+
+    System.out.println(Integer.toString(totalInserts)+" writes across "+
+      Integer.toString(threadCount)+" threads took "+
+      new Long(System.currentTimeMillis()-startTime)+" ms and had "+
+      Integer.toString(contentions)+" contention retries");
+  }
+
+  @Test
+  public void writeQueryTest()
+    throws Exception
+  {
+    int totalCount = 10000/4;
+    int threadCount = 24;
+    
+    int repeatCount = totalCount/threadCount;
+
+    WHAtomicKeyValueStore store = new InMemAtomicNativeNonblockingKeyValueStore(16777216);
+    
+    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
+
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex1",table,
+      new String[]{"colB","colA"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex2",table,
+      new String[]{"colD","colC"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex3",table,
+      new String[]{"colF","colE"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex4",table,
+      new String[]{"colH","colG"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex5",table,
+      new String[]{"colJ","colI"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.commitTransaction();
+
+    TaskThread[] threads = new TaskThread[threadCount];
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i] = new TaskThread("Worker thread "+i,store,repeatCount);
+    }
+    
+    long startTime = System.currentTimeMillis();
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i].start();
+    }
+    
+    // Join at the end
+    
+    int contentions = 0;
+    for (int i = 0 ; i < threadCount ; i++)
+    {
+      threads[i].join();
+      Throwable e = threads[i].getException();
+      if (e != null)
+      {
+        if (e instanceof Error)
+          throw (Error)e;
+        if (e instanceof RuntimeException)
+          throw (RuntimeException)e;
+        throw (Exception)e;
+      }
+      contentions += threads[i].getContentions();
+    }
+
+    System.out.println(Integer.toString(threadCount*repeatCount)+" writes and "+
+      Integer.toString(threadCount*repeatCount*3)+" reads across "+
+      Integer.toString(threadCount)+" threads took "+
+      new Long(System.currentTimeMillis()-startTime)+" ms and had "+
+      Integer.toString(contentions)+" contention retries");
+  }
+  
+  // Protected methods
+  
+  protected static String randomString(Random r)
+  {
+    return new Long(randomLong(r)).toString();
+  }
+  
+  protected static long randomLong(Random r)
+  {
+    return r.nextLong();
+  }
+  
+  protected static class InsertThread extends Thread
+  {
+    protected int repeatCount;
+    protected int contentions = 0;
+    protected WHAtomicKeyValueStore store;
+    protected Throwable exception;
+    protected Random r = new Random();
+    
+    public InsertThread(String name, WHAtomicKeyValueStore store, int repeatCount)
+    {
+      super();
+      this.repeatCount = repeatCount;
+      this.store = store;
+      setName(name);
+    }
+    
+    public void run()
+    {
+      try
+      {
+        WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
+        performInserts(ts);
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+    
+    public Throwable getException()
+    {
+      return exception;
+    }
+    
+    public int getContentions()
+    {
+      return contentions;
+    }
+    
+    protected void backOff()
+      throws InterruptedException
+    {
+      contentions++;
+      //Thread.sleep(r.nextInt(100));
+      Thread.yield();
+    }
+    
+    protected void performInserts(WHTableStore ts)
+      throws InterruptedException, WHException
+    {
+      // Task consists of a certain number of inserts and queries
+      for (int i = 0 ; i < repeatCount ; i++)
+      {
+        // Add a row
+        while (true)
+        {
+          ts.beginTransaction();
+          try
+          {
+            WHTable table = ts.lookupTable("testtable");
+            table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
+              new WHValue[]{
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r))});
+            ts.commitTransaction();
+            break;
+          }
+          catch (WHConcurrencyException e)
+          {
+            backOff();
+            continue;
+          }
+          finally
+          {
+            ts.abandonTransaction();
+          }
+        }
+      }
+    }
+    
+  }
+
+  protected static class TaskThread extends Thread
+  {
+    protected int repeatCount;
+    protected int contentions = 0;
+    protected WHAtomicKeyValueStore store;
+    protected Throwable exception;
+    protected Random r = new Random();
+    
+    public TaskThread(String name, WHAtomicKeyValueStore store, int repeatCount)
+    {
+      super();
+      this.repeatCount = repeatCount;
+      this.store = store;
+      setName(name);
+    }
+    
+    public void run()
+    {
+      try
+      {
+        WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(store));
+        performTask(ts);
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+    
+    public Throwable getException()
+    {
+      return exception;
+    }
+    
+    public int getContentions()
+    {
+      return contentions;
+    }
+    
+    protected void backOff()
+      throws InterruptedException
+    {
+      contentions++;
+      //Thread.sleep(r.nextInt(100));
+      Thread.yield();
+    }
+    
+    protected void performTask(WHTableStore ts)
+      throws InterruptedException, WHException
+    {
+      // Task consists of a certain number of inserts and queries
+      for (int i = 0 ; i < repeatCount ; i++)
+      {
+        // Add a row
+        while (true)
+        {
+          ts.beginTransaction();
+          try
+          {
+            WHTable table = ts.lookupTable("testtable");
+            table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
+              new WHValue[]{
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r)),
+                new LongValue(randomLong(r)),new StringValue(randomString(r))});
+            ts.commitTransaction();
+            break;
+          }
+          catch (WHConcurrencyException e)
+          {
+            backOff();
+            continue;
+          }
+          finally
+          {
+            ts.abandonTransaction();
+          }
+        }
+        
+        // Do a query
+        while (true)
+        {
+          ts.beginTransaction();
+          try
+          {
+            WHIndex index = ts.lookupIndex("testindex1");
+            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
+              new IndexBetween(new StringValue("1"),new StringValue("2")),
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
+            ts.commitTransaction();
+            break;
+          }
+          catch (WHConcurrencyException e)
+          {
+            backOff();
+            continue;
+          }
+          finally
+          {
+            ts.abandonTransaction();
+          }
+        }
+
+        // Do another query
+        while (true)
+        {
+          ts.beginTransaction();
+          try
+          {
+            WHIndex index = ts.lookupIndex("testindex2");
+            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
+              new IndexBetween(new StringValue("23"),new StringValue("25")),
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
+            ts.commitTransaction();
+            break;
+          }
+          catch (WHConcurrencyException e)
+          {
+            backOff();
+            continue;
+          }
+          finally
+          {
+            ts.abandonTransaction();
+          }
+        }
+
+        // Do a third query
+        while (true)
+        {
+          ts.beginTransaction();
+          try
+          {
+            WHIndex index = ts.lookupIndex("testindex3");
+            WHAccessor accessor = index.buildAccessor(new IndexCriteria[]{
+              new IndexBetween(new StringValue("02"),new StringValue("04")),
+              null},null);
+            while (true)
+            {
+              if (accessor.getCurrentRowID() == null)
+                break;
+              accessor.advance();
+            }
+            ts.commitTransaction();
+            break;
+          }
+          catch (WHConcurrencyException e)
+          {
+            backOff();
+            continue;
+          }
+          finally
+          {
+            ts.abandonTransaction();
+          }
+        }
+
+      }
+    }
+    
+  }
+  
 }
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/MultiThreadTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java?rev=1220353&r1=1220352&r2=1220353&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java Sun Dec 18 08:36:52 2011
@@ -1,121 +1,121 @@
-/* $Id: PerformanceTest.java 1208116 2011-11-29 22:36:26Z kwright $ */
-
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.warthog.tests;
-
-import org.apache.warthog.api.*;
-import org.apache.warthog.transactionalkeyvaluestore.*;
-import org.apache.warthog.keyvaluetablestore.*;
-import org.apache.warthog.keyvalue.*;
-import org.apache.warthog.common.*;
-import org.junit.*;
-import static org.junit.Assert.*;
-import java.util.*;
-
-public class PerformanceTest
-{
-
-  @Test
-  public void rowCreateTest()
-    throws Exception
-  {
-    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(new InMemAtomicNativeKeyValueStore(16777216)));
-
-    ts.beginTransaction();
-    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
-    ts.commitTransaction();
-
-    ts.beginTransaction();
-    WHTable table = ts.lookupTable("testtable");
-    ts.createIndex("testindex1",table,
-      new String[]{"colB","colA"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex2",table,
-      new String[]{"colD","colC"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex3",table,
-      new String[]{"colF","colE"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex4",table,
-      new String[]{"colH","colG"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.createIndex("testindex5",table,
-      new String[]{"colJ","colI"},
-      new String[]{"org.apache.warthog.common.StringComparatorAscending",
-        "org.apache.warthog.common.LongComparatorAscending"},false);
-    ts.commitTransaction();
-
-    int rowCount = 10000;
-    Random r = new Random();
-    String[] str1Values = new String[rowCount];
-    long[] long1Values = new long[rowCount];
-    String[] str2Values = new String[rowCount];
-    long[] long2Values = new long[rowCount];
-    String[] str3Values = new String[rowCount];
-    long[] long3Values = new long[rowCount];
-    String[] str4Values = new String[rowCount];
-    long[] long4Values = new long[rowCount];
-    String[] str5Values = new String[rowCount];
-    long[] long5Values = new long[rowCount];
-    for (int i = 0 ; i < rowCount ; i++)
-    {
-      str1Values[i] = randomString(r);
-      long1Values[i] = randomLong(r);
-      str2Values[i] = randomString(r);
-      long2Values[i] = randomLong(r);
-      str3Values[i] = randomString(r);
-      long3Values[i] = randomLong(r);
-      str4Values[i] = randomString(r);
-      long4Values[i] = randomLong(r);
-      str5Values[i] = randomString(r);
-      long5Values[i] = randomLong(r);
-    }
-    long startTime = System.currentTimeMillis();
-    for (int i = 0 ; i < rowCount ; i++)
-    {
-      ts.beginTransaction();
-      table = ts.lookupTable("testtable");
-      table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
-        new WHValue[]{
-          new LongValue(long1Values[i]),new StringValue(str1Values[i]),
-          new LongValue(long2Values[i]),new StringValue(str2Values[i]),
-          new LongValue(long3Values[i]),new StringValue(str3Values[i]),
-          new LongValue(long4Values[i]),new StringValue(str4Values[i]),
-          new LongValue(long5Values[i]),new StringValue(str5Values[i])});
-      ts.commitTransaction();
-    }
-    System.out.println("Create of "+Integer.toString(rowCount)+" rows took "+new Long(System.currentTimeMillis() - startTime).toString()+" ms");
-  }
-  
-  // Protected methods
-  
-  protected static String randomString(Random r)
-  {
-    return new Long(randomLong(r)).toString();
-  }
-  
-  protected static long randomLong(Random r)
-  {
-    return r.nextLong();
-  }
-  
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.warthog.tests;
+
+import org.apache.warthog.api.*;
+import org.apache.warthog.transactionalkeyvaluestore.*;
+import org.apache.warthog.keyvaluetablestore.*;
+import org.apache.warthog.keyvalue.*;
+import org.apache.warthog.common.*;
+import org.junit.*;
+import static org.junit.Assert.*;
+import java.util.*;
+
+public class PerformanceTest
+{
+
+  @Test
+  public void rowCreateTest()
+    throws Exception
+  {
+    WHTableStore ts = new TableStore(new InMemNativeTransactionalStoreImpl(new InMemAtomicNativeKeyValueStore(16777216)));
+
+    ts.beginTransaction();
+    ts.createTable("testtable",new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"});
+    ts.commitTransaction();
+
+    ts.beginTransaction();
+    WHTable table = ts.lookupTable("testtable");
+    ts.createIndex("testindex1",table,
+      new String[]{"colB","colA"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex2",table,
+      new String[]{"colD","colC"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex3",table,
+      new String[]{"colF","colE"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex4",table,
+      new String[]{"colH","colG"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.createIndex("testindex5",table,
+      new String[]{"colJ","colI"},
+      new String[]{"org.apache.warthog.common.StringComparatorAscending",
+        "org.apache.warthog.common.LongComparatorAscending"},false);
+    ts.commitTransaction();
+
+    int rowCount = 10000;
+    Random r = new Random();
+    String[] str1Values = new String[rowCount];
+    long[] long1Values = new long[rowCount];
+    String[] str2Values = new String[rowCount];
+    long[] long2Values = new long[rowCount];
+    String[] str3Values = new String[rowCount];
+    long[] long3Values = new long[rowCount];
+    String[] str4Values = new String[rowCount];
+    long[] long4Values = new long[rowCount];
+    String[] str5Values = new String[rowCount];
+    long[] long5Values = new long[rowCount];
+    for (int i = 0 ; i < rowCount ; i++)
+    {
+      str1Values[i] = randomString(r);
+      long1Values[i] = randomLong(r);
+      str2Values[i] = randomString(r);
+      long2Values[i] = randomLong(r);
+      str3Values[i] = randomString(r);
+      long3Values[i] = randomLong(r);
+      str4Values[i] = randomString(r);
+      long4Values[i] = randomLong(r);
+      str5Values[i] = randomString(r);
+      long5Values[i] = randomLong(r);
+    }
+    long startTime = System.currentTimeMillis();
+    for (int i = 0 ; i < rowCount ; i++)
+    {
+      ts.beginTransaction();
+      table = ts.lookupTable("testtable");
+      table.insertRow(new String[]{"colA","colB","colC","colD","colE","colF","colG","colH","colI","colJ"},
+        new WHValue[]{
+          new LongValue(long1Values[i]),new StringValue(str1Values[i]),
+          new LongValue(long2Values[i]),new StringValue(str2Values[i]),
+          new LongValue(long3Values[i]),new StringValue(str3Values[i]),
+          new LongValue(long4Values[i]),new StringValue(str4Values[i]),
+          new LongValue(long5Values[i]),new StringValue(str5Values[i])});
+      ts.commitTransaction();
+    }
+    System.out.println("Create of "+Integer.toString(rowCount)+" rows took "+new Long(System.currentTimeMillis() - startTime).toString()+" ms");
+  }
+  
+  // Protected methods
+  
+  protected static String randomString(Random r)
+  {
+    return new Long(randomLong(r)).toString();
+  }
+  
+  protected static long randomLong(Random r)
+  {
+    return r.nextLong();
+  }
+  
 }
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog-reimport/src/test/java/org/apache/warthog/tests/PerformanceTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message