*** empty log message ***
authornavid <navid>
Mon, 26 Jan 2009 07:07:45 +0000 (07:07 +0000)
committernavid <navid>
Mon, 26 Jan 2009 07:07:45 +0000 (07:07 +0000)
25 files changed:
Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Conversions.java [new file with mode: 0644]
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/ExtendedTransaction.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalINodeState.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/GlobalLength.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/INode.java
Robust/Transactions/TransactionalIO/src/TransactionalIO/core/TransactionalFile.java
Robust/Transactions/dstm2/src/dstm2/factory/BaseFactory.java
Robust/Transactions/dstm2/src/dstm2/util/StringKeyHashMap.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/DualFileTable.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/DualFileTableTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/HashedTable.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/IndexedTableReaderTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/PagedIndex.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/PagedIndexTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/RowTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/TableIndexEntry.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/TableIndexEntryTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/TableIndexNodeTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/TableIndexPage.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/TableIndexPageTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/core/ValueTransactional.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelPerformanceTest.java [new file with mode: 0644]
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelThread.java [new file with mode: 0644]
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/ParallelPerformanceTest.java
Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/ParallelThread.java

diff --git a/Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Conversions.java b/Robust/Transactions/TransactionalIO/src/TransactionalIO/Utilities/Conversions.java
new file mode 100644 (file)
index 0000000..de8763f
--- /dev/null
@@ -0,0 +1,202 @@
+package TransactionalIO.Utilities;
+
+/* =============================================================
+ * SmallSQL : a free Java DBMS library for the Java(tm) platform
+ * =============================================================
+ *
+ * (C) Copyright 2004-2007, by Volker Berlin.
+ *
+ * Project Info:  http://www.smallsql.de/
+ *
+ * This library is free software; you can redistribute it and/or modify it 
+ * under the terms of the GNU Lesser General Public License as published by 
+ * the Free Software Foundation; either version 2.1 of the License, or 
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
+ * USA.  
+ *
+ * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
+ * in the United States and other countries.]
+ *
+ * ---------------
+ * Utils.java
+ * ---------------
+ * Author: Volker Berlin
+ * 
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileLock;
+import java.sql.SQLException;
+
+
+public class Conversions {
+
+       
+       
+       
+       public static int long2int(long value){
+               if(value > Integer.MAX_VALUE)
+                       return Integer.MAX_VALUE;
+               if(value < Integer.MIN_VALUE)
+                       return Integer.MIN_VALUE;
+               return (int)value;
+       }
+       
+       public static long double2long(double value){
+               if(value > Long.MAX_VALUE)
+                       return Long.MAX_VALUE;
+               if(value < Long.MIN_VALUE)
+                       return Long.MIN_VALUE;
+               return (long)value;
+       }
+
+
+
+    public static float bytes2float( byte[] bytes ){
+        return Float.intBitsToFloat( bytes2int( bytes ) );
+    }
+
+    public static double bytes2double( byte[] bytes ){
+        return Double.longBitsToDouble( bytes2long( bytes ) );
+    }
+
+    public static long bytes2long( byte[] bytes ){
+        long result = 0;
+        int length = Math.min( 8, bytes.length);
+        for(int i=0; i<length; i++){
+            result = (result << 8) | (bytes[i] & 0xFF);
+        }
+        return result;
+    }
+
+    public static int bytes2int( byte[] bytes ){
+        int result = 0;
+        int length = Math.min( 4, bytes.length);
+        for(int i=0; i<length; i++){
+            result = (result << 8) | (bytes[i] & 0xFF);
+        }
+        return result;
+    }
+
+    static byte[] double2bytes( double value ){
+        return long2bytes(Double.doubleToLongBits(value));
+    }
+
+    public static byte[] float2bytes( float value ){
+        return int2bytes(Float.floatToIntBits(value));
+    }
+
+    public static byte[] long2bytes( long value ){
+        byte[] result = new byte[8];
+        result[0] = (byte)(value >> 56);
+        result[1] = (byte)(value >> 48);
+        result[2] = (byte)(value >> 40);
+        result[3] = (byte)(value >> 32);
+        result[4] = (byte)(value >> 24);
+        result[5] = (byte)(value >> 16);
+        result[6] = (byte)(value >> 8);
+        result[7] = (byte)(value);
+        return result;
+    }
+    
+    public static int money2int( long value ) {
+               if (value < Integer.MIN_VALUE) return Integer.MIN_VALUE;
+               else if (value > Integer.MAX_VALUE) return Integer.MAX_VALUE;
+               else return (int) value;
+       }
+
+       public static byte[] int2bytes( int value ){
+               byte[] result = new byte[4];
+               result[0] = (byte)(value >> 24);
+               result[1] = (byte)(value >> 16);
+               result[2] = (byte)(value >> 8);
+               result[3] = (byte)(value);
+               return result;
+       }
+
+
+
+   
+
+    private static int hexDigit2int(char digit){
+        if(digit >= '0' && digit <= '9') return digit - '0';
+        digit |= 0x20;
+        if(digit >= 'a' && digit <= 'f') return digit - 'W'; // -'W'  ==  -'a' + 10
+        throw new RuntimeException();
+    }
+
+
+
+    static boolean string2boolean( String val){
+        try{
+            return Double.parseDouble( val ) != 0;
+        }catch(NumberFormatException e){/*ignore it if it not a number*/}
+        return "true".equalsIgnoreCase( val ) || "yes".equalsIgnoreCase( val ) || "t".equalsIgnoreCase( val );
+    }
+       
+       
+       static long doubleToMoney(double value){
+               if(value < 0)
+                       return (long)(value * 10000 - 0.5);
+               return (long)(value * 10000 + 0.5);
+       }
+
+    static int indexOf( char value, char[] str, int offset, int length ){
+        value |= 0x20;
+        for(int end = offset+length;offset < end; offset++){
+            if((str[offset] | 0x20) == value) return offset;
+        }
+        return -1;
+    }
+
+    public static int indexOf( int value, int[] list ){
+        int offset = 0;
+        for(int end = list.length; offset < end; offset++){
+            if((list[offset]) == value) return offset;
+        }
+        return -1;
+    }
+
+    public static int indexOf( byte[] value, byte[] list, int offset ){
+        int length = value.length;
+        loop1:
+        for(int end = list.length-length; offset <= end; offset++){
+            for(int i=0; i<length; i++ ){
+                if(list[offset+i] != value[i]){
+                    continue loop1;
+                }
+            }
+            return offset;
+        }
+        return -1;
+    }
+
+    public static int compareBytes( byte[] leftBytes, byte[] rightBytes){
+        int length = Math.min( leftBytes.length, rightBytes.length );
+        int comp = 0;
+        for(int i=0; i<length; i++){
+            if(leftBytes[i] != rightBytes[i]){
+                comp = leftBytes[i] < rightBytes[i] ? -1 : 1;
+                break;
+            }
+        }
+        if(comp == 0 && leftBytes.length != rightBytes.length){
+            comp = leftBytes.length < rightBytes.length ? -1 : 1;
+        }
+        return comp;
+    }
+       
+
+}
\ No newline at end of file
index db536b17cea65e1cfc379f80c443d70c3eb4a114..5770302b5ce52ae55297a6d31654146513cbd43b 100644 (file)
@@ -432,17 +432,18 @@ public class ExtendedTransaction implements TransactionStatu {
                         heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
                         trf.getInodestate().commitedfilesize.lengthlock.unlock();
                     }
+                    if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).lenght_read){
+                        trf.getInodestate().commitedfilesize.getLengthReaders().remove(this);
+                        //heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
+                        //trf.getInodestate().commitedfilesize.lengthlock.unlock();
+                    }
                     
                 } catch (IOException ex) {
                     Logger.getLogger(ExtendedTransaction.class.getName()).log(Level.SEVERE, null, ex);
                 }
             }
             
-            if (((TransactionLocalFileAttributes) GlobaltoLocalMappings.get(trf)).lenght_read){
-                trf.getInodestate().commitedfilesize.getLengthReaders().remove(this);
-                heldlengthlocks.remove(trf.getInodestate().commitedfilesize.lengthlock);
-                trf.getInodestate().commitedfilesize.lengthlock.unlock();
-            }
+          
         }
         
         
index 68554bc915f273bdb49c893e7d6ed3cb7398896f..291ebda7a5ea206dab6256d605ce798264d505e1 100644 (file)
@@ -64,6 +64,7 @@ public class GlobalINodeState {
         lockmap = new HashMap();
        
         commitedfilesize = new GlobalLength(length);
+     //   System.out.println(length);
         this.inode = inode;
     }
     
index de68c1c765ce5ab783e2e1eeeee8014c6c377d80..ea674303191e2d5fdd0f60971c6ad847d7129090 100644 (file)
@@ -20,6 +20,8 @@ public class GlobalLength {
 
     public GlobalLength(long length) {
         this.length = length;
+        lengthlock = new ReentrantLock();
+        lengthReaders = new Vector();
     }
     
 
index e5a1f826bec978fe42b67fb0fc730ac059df5ea2..886013f8aeb03434d8dcc30b327196b175a8f798 100644 (file)
@@ -49,7 +49,7 @@ public class INode implements Comparable{
         else if (this.getNumber() > other.getNumber())
             return 1;
         else{ 
-            System.out.println("Logical Eroor Two Inodes cannot have the same number");
+            System.out.println("Logical Error Two Inodes cannot have the same number" + this.filepath + " " + other.filepath);
             return 0;
         }
        
index 9f5be1408eaafe162d9d9c301b9d6fd3e2833828..22bac250eb2ca164b78e48aa400bb2be100cf0bc 100644 (file)
@@ -4,6 +4,7 @@
  */
 package TransactionalIO.core;
 
+import TransactionalIO.Utilities.Conversions;
 import TransactionalIO.Utilities.Range;
 import TransactionalIO.exceptions.AbortedException;
 import TransactionalIO.exceptions.PanicException;
@@ -122,10 +123,24 @@ public class TransactionalFile implements Comparable {
             }
 
         }
+   /*     synchronized(this){
+            if (to_be_created){
+                try {
+                    offsetlock = new ReentrantLock();
+                    file = new RandomAccessFile(filename, mode);
+                    try {
+                        System.out.println("ll " + file.length());
+                    } catch (IOException ex) {
+                        Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+                    }
+                } catch (FileNotFoundException ex) {
+                    Logger.getLogger(TransactionalFile.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
+        }*/
         inode = TransactionalFileWrapperFactory.getINodefromFileName(filename);
         inodestate = TransactionalFileWrapperFactory.createTransactionalFile(inode, filename, mode);
-
-
+        
         sequenceNum = inodestate.seqNum;
         inodestate.seqNum++;
 
@@ -138,7 +153,6 @@ public class TransactionalFile implements Comparable {
         if (inodestate != null) {
             synchronized (inodestate) {
                 committedoffset = new GlobalOffset(0);
-               
             }
         }
 
@@ -147,6 +161,8 @@ public class TransactionalFile implements Comparable {
 
     private int invokeNativepread(byte buff[], long offset, int size) {
         try {
+                    
             return nativepread(buff, offset, size, file.getFD());
         } catch (IOException ex) {
 
@@ -199,7 +215,12 @@ public class TransactionalFile implements Comparable {
         ExtendedTransaction me = Wrapper.getTransaction();
 
         if (me == null) {
-            return non_Transactional_getFilePointer();
+            long length = -1;
+            inodestate.commitedfilesize.lengthlock.lock();
+            length = inodestate.commitedfilesize.getLength();
+            inodestate.commitedfilesize.lengthlock.unlock();
+
+            return length;
         }
 
         if (!(me.getGlobaltoLocalMappings().containsKey(this))) {
@@ -310,11 +331,11 @@ public class TransactionalFile implements Comparable {
             return 0;
         }
         pos = getFilePointer();
-        len = length();
+       // len = length();
         newpos = pos + n;
-        if (newpos > len) {
-            newpos = len;
-        }
+      //  if (newpos > len) {
+     //       newpos = len;
+      //  }
         seek(newpos);
 
          /* return the actual number of bytes skipped */
@@ -339,21 +360,28 @@ public class TransactionalFile implements Comparable {
         byte[] data = new byte[2];
         read(data);
         int result = (short)((data[0] << 8) | data[1]);
+        System.out.println("res " + result);
         return result;
     }
     
     
     public final int readInt(){
         byte[] data = new byte[4];
-        read(data);
-        int result = (data[0] << 24) | (data[1] << 16) + (data[2] << 8) + data[3];
+        int k = read(data);
+        
+        int result = Conversions.bytes2int(data);
+        //int result = (data[0] << 24) | (data[1] << 16) + (data[2] << 8) + (data[3]<<0);
+        System.out.println("int res " + result);
         return result;
     }
     
     public final long readLong(){
+        //long result = ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
         byte[] data = new byte[8];
         read(data);
-        long result = ((long)data[0] << 56) + ((long)data[1] << 48) + ((long)data[2] << 40) + ((long)data[3] << 32) + ((long)data[4] << 24) + ((long)data[5] << 16)+ ((long)data[6] << 8) + data[7];
+        //long result = ((long)data[0] << 56) + ((long)data[1] << 48) + ((long)data[2] << 40) + ((long)data[3] << 32) + ((long)data[4] << 24) + ((long)data[5] << 16)+ ((long)data[6] << 8) + data[7];
+        long result = Conversions.bytes2long(data);
+        System.out.println("long res " + result);
         return result;
     }
     
@@ -397,9 +425,9 @@ public class TransactionalFile implements Comparable {
     public final void writeInt(int value){
         try {
             byte[] result = new byte[4];
-            result[0] = (byte) (value >> 24);
-            result[1] = (byte) (value >> 16);
-            result[2] = (byte) (value >> 8);
+            result[0] = (byte) (value >>> 24 & 0xFF);
+            result[1] = (byte) (value >>> 16 & 0xFF);
+            result[2] = (byte) (value >>> 8 & 0xFF);
             result[3] = (byte) (value);
             write(result);
         } catch (IOException ex) {
@@ -414,14 +442,14 @@ public class TransactionalFile implements Comparable {
     
      public final void writeLong(long value){
         try {
-            byte[] result = new byte[4];
-            result[0] = (byte)(value >> 56);
-            result[1] = (byte)(value >> 48);
-            result[2] = (byte)(value >> 40);
-            result[3] = (byte)(value >> 32);
-            result[4] = (byte)(value >> 24);
-            result[5] = (byte)(value >> 16);
-            result[6] = (byte)(value >> 8);
+            byte[] result = new byte[8];
+            result[0] = (byte)(value >>> 56);
+            result[1] = (byte)(value >>> 48);
+            result[2] = (byte)(value >>> 40);
+            result[3] = (byte)(value >>> 32);
+            result[4] = (byte)(value >>> 24);
+            result[5] = (byte)(value >>> 16);
+            result[6] = (byte)(value >>> 8);
             result[7] = (byte)(value);
             write(result);
         } catch (IOException ex) {
@@ -517,7 +545,6 @@ public class TransactionalFile implements Comparable {
         int size = b.length;
         int result = 0;
         if (me == null) {  // not a transaction, but any I/O operation even though within a non-transaction is considered a single opertion transactiion 
-
             return non_Transactional_Read(b);
         }
 
@@ -870,7 +897,6 @@ public class TransactionalFile implements Comparable {
     public void lockOffset(ExtendedTransaction me) {
         boolean locked = false;
         if (me.getStatus() == Status.ACTIVE) {                        //locking the offset
-
             offsetlock.lock();
             locked = true;
         }
index 82431bff275cf9597b495f23859f1026d91bc8e1..4a0a1abeeabac94f38ef7546088dd14ff27b5f5f 100644 (file)
@@ -152,7 +152,10 @@ public abstract class BaseFactory<T> implements Factory<T> {
       if (method.getName().substring(0,3).equals("get") &&
          !method.getDeclaringClass().getCanonicalName().contains("dstm2.util.LinkedList") &&
           !method.getDeclaringClass().getCanonicalName().contains("dstm2.util.Hashtable") &&
-         !method.getDeclaringClass().getCanonicalName().contains("dstm2.util.HashMap")) {
+         !method.getDeclaringClass().getCanonicalName().contains("dstm2.util.HashMap") &&
+          !method.getDeclaringClass().getCanonicalName().contains("com.solidosystems.tuplesoup.core.TableIndexPageTransactional") &&
+          !method.getDeclaringClass().getCanonicalName().contains("com.solidosystems.tuplesoup.core.TableIndexNodeTransactional") &&
+          !method.getDeclaringClass().getCanonicalName().contains("dstm2.util.StringKeyHashMap")){
         if (!isAtomicOrScalar(method.getReturnType())) {
           throw new PanicException("Method %s return type %s not scalar or atomic.",
               method.getName(), method.getReturnType().getName());
index dde4153d124728438229c3574b0223337206234e..e7310dac031c3f5cf80b479845cc85cbca67ceef 100644 (file)
@@ -719,29 +719,30 @@ public class StringKeyHashMap<V extends dstm2.AtomicSuperClass> implements Itera
         }
     }
 
-//    private class EntryIterator extends HashIterator<Map.Entry<K,V>> {
-//        public Map.Entry<K,V> next() {
-//            return nextEntry();
-//        }
-//    }
+    private class EntryIterator extends HashIterator<StringKeyHashMap.TEntry<V>> {
+        public StringKeyHashMap.TEntry<V> next() {
+            return nextEntry();
+        }
+    }
 
     // Subclass overrides these to alter behavior of views' iterator() method
     public Iterator<Integer> newKeyIterator()   {
         return new KeyIterator();
     }
     public Iterator<V> newValueIterator()   {
+        
         return new ValueIterator();
     }
-//    Iterator<Map.Entry<K,V>> newEntryIterator()   {
-//        return new EntryIterator();
-//    }
+    Iterator<StringKeyHashMap.TEntry<V>> newEntryIterator()   {
+        return new EntryIterator();
+    }
 
 
     // Views
 
     private transient Set<StringKeyHashMap.TEntry<V>> entrySet = null;
 
-
 
     private class KeySet extends AbstractSet<Integer> {
         public Iterator<Integer> iterator() {
@@ -781,10 +782,10 @@ public class StringKeyHashMap<V extends dstm2.AtomicSuperClass> implements Itera
         return (es != null ? es : (entrySet = (Set<StringKeyHashMap.TEntry<V>>) (Set) new EntrySet()));
     }
 
-    private class EntrySet {//extends AbstractSet/*<Map.Entry<K,V>>*/ {
-//        public Iterator/*<Map.Entry<K,V>>*/ iterator() {
-//            return newEntryIterator();
-//        }
+    private class EntrySet extends AbstractSet<StringKeyHashMap.TEntry<V>>{//extends AbstractSet/*<Map.Entry<K,V>>*/ {
+        public Iterator/*<Map.Entry<K,V>>*/ iterator() {
+            return newEntryIterator();
+        }
         public boolean contains(StringKeyHashMap.TEntry<V> o) {
             StringKeyHashMap.TEntry<V> e = (StringKeyHashMap.TEntry<V>) o;
             TEntry<V> candidate = getEntry(e.getHash());
index 8bfbe140b3bea0cdeff3cc41c5c6c67ec6b0be55..f4f17d13638598a3720861279261a6ef2c484781 100644 (file)
@@ -143,6 +143,7 @@ public class DualFileTable implements Table{
         if(!this.location.endsWith(File.separator))this.location+=File.separator;
         switch(indextype){
              case PAGED  : index=new PagedIndex(getFileName(INDEX));
+                
                 break;
            
         }
@@ -217,12 +218,14 @@ public class DualFileTable implements Table{
      private synchronized void openFile(int type) throws IOException{
          switch(type){
              case FILEA  : if(fileastream==null){
+                                System.out.println("file a " + getFileName(FILEA));
                                 fileastream=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFileName(FILEA),true)));
                                 File ftest=new File(getFileName(FILEA));
                                 fileaposition=ftest.length();
                            }
                           break;
              case FILEB  : if(filebstream==null){
+                 System.out.println("file b " + getFileName(FILEB));
                                 filebstream=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFileName(FILEB),true)));
                                 File ftest=new File(getFileName(FILEB));
                                 filebposition=ftest.length();
index b55c46c6310495812e57310dd09d272d448007f0..483b0e9dfa5f6d1d5f952639236ed0f8f6df1b7d 100644 (file)
@@ -39,6 +39,8 @@ import java.nio.channels.*;
 import com.solidosystems.tuplesoup.filter.*;
 import dstm2.atomic;
 import dstm2.Thread;
+import dstm2.benchmark.FinancialTransaction.FinancialTransactionDS;
+import dstm2.factory.Factory;
 import dstm2.util.StringKeyHashMap;
 import java.util.concurrent.Callable;
 
@@ -80,37 +82,39 @@ public class DualFileTableTransactional implements TableTransactional{
     private StringKeyHashMap<TableIndexNodeTransactional> indexcache;
     //private Hashtable<String,TableIndexNode> indexcache;
     
-    
+    static Factory<DualFileTableTSInf> factory = Thread.makeFactory(DualFileTableTSInf.class);
+    // static Factory<FinancialTransactionDS> factory = Thread.makeFactory(FinancialTransactionDS.class);
     DualFileTableTSInf atomicfields;
     // Statistic counters
+
     public @atomic interface DualFileTableTSInf{
-        long getstat_add();
-        long getstat_update();
-        long getstat_delete();
-        long getstat_add_size();
-        long getstat_update_size();
-        long getstat_read_size();
-        long getstat_read();
-        long getstat_cache_hit();
-        long getstat_cache_miss();
-        long getstat_cache_drop();
-        long getFileaposition();
-        long getFilebposition();
-        int getIndexcacheusage();
+        Long getstat_add();
+        Long getstat_update();
+        Long getstat_delete();
+        Long getstat_add_size();
+        Long getstat_update_size();
+        Long getstat_read_size();
+        Long getstat_read();
+        Long getstat_cache_hit();
+        Long getstat_cache_miss();
+        Long getstat_cache_drop();
+        Long getFileaposition();
+        Long getFilebposition();
+        Integer getIndexcacheusage();
         
-        void setstat_add(long val);
-        void setstat_update(long val);
-        void setstat_delete(long val);
-        void setstat_add_size(long val);
-        void setstat_update_size(long val);
-        void setstat_read_size(long val);
-        void setstat_read(long val);
-        void setstat_cache_hit(long val);
-        void setstat_cache_miss(long val);
-        void setstat_cache_drop(long val);
-        void setIndexcacheusage(int val);
-        void setFileaposition(long val);
-        void setFilebposition(long val);
+        void setstat_add(Long val);
+        void setstat_update(Long val);
+        void setstat_delete(Long val);
+        void setstat_add_size(Long val);
+        void setstat_update_size(Long val);
+        void setstat_read_size(Long val);
+        void setstat_read(Long val);
+        void setstat_cache_hit(Long val);
+        void setstat_cache_miss(Long val);
+        void setstat_cache_drop(Long val);
+        void setIndexcacheusage(Integer val);
+        void setFileaposition(Long val);
+        void setFilebposition(Long val);
     }
   
     /*long stat_add=0;
@@ -159,16 +163,17 @@ public class DualFileTableTransactional implements TableTransactional{
                 hash.put("stat_table_cache_hit",atomicfields.getstat_cache_hit());
                 hash.put("stat_table_cache_miss",atomicfields.getstat_cache_miss());
                 hash.put("stat_table_cache_drop",atomicfields.getstat_cache_drop());
-                atomicfields.setstat_add(0);
-                atomicfields.setstat_update(0);
-                atomicfields.setstat_delete(0);
-                atomicfields.setstat_add_size(0);
-                atomicfields.setstat_update_size(0);
-                atomicfields.setstat_read_size(0);
-                atomicfields.setstat_read(0);
-                atomicfields.setstat_cache_hit(0);
-                atomicfields.setstat_cache_miss(0);
-                atomicfields.setstat_cache_drop(0);
+                atomicfields.setstat_add(Long.valueOf(0));
+                atomicfields.setstat_update(Long.valueOf(0));
+                atomicfields.setstat_delete(Long.valueOf(0));
+                atomicfields.setstat_add_size(Long.valueOf(0));
+                atomicfields.setstat_update_size(Long.valueOf(0));
+                atomicfields.setstat_read_size(Long.valueOf(0));
+                atomicfields.getstat_read_size();
+                atomicfields.setstat_read(Long.valueOf(0));
+                atomicfields.setstat_cache_hit(Long.valueOf(0));
+                atomicfields.setstat_cache_miss(Long.valueOf(0));
+                atomicfields.setstat_cache_drop(Long.valueOf(0));
                 Hashtable<String,Long> ihash=index.readStatistics();
                 hash.putAll(ihash);
                 return hash;
@@ -186,6 +191,8 @@ public class DualFileTableTransactional implements TableTransactional{
      * Create a new table object with a specific index model
      */
     public DualFileTableTransactional(String title,String location, int indextype) throws IOException{
+        atomicfields = factory.create();
+        
         this.title=title;
         this.location=location;
         if(!this.location.endsWith(File.separator))this.location+=File.separator;
@@ -196,9 +203,19 @@ public class DualFileTableTransactional implements TableTransactional{
         }
         indexcachefirst=null;
         indexcachelast=null;
-        atomicfields.setFileaposition(0);
-        atomicfields.setFilebposition(0);
-        atomicfields.setIndexcacheusage(0);
+        atomicfields.setFileaposition(Long.valueOf(0));
+        atomicfields.setFilebposition(Long.valueOf(0));
+        atomicfields.setstat_update_size(Long.valueOf(0));
+        atomicfields.setstat_update(Long.valueOf(0));
+        atomicfields.setstat_read_size(Long.valueOf(0));
+        atomicfields.setstat_read(Long.valueOf(0));
+        atomicfields.setstat_delete(Long.valueOf(0));
+        atomicfields.setstat_cache_miss(Long.valueOf(0));
+        atomicfields.setstat_cache_hit(Long.valueOf(0));
+        atomicfields.setstat_cache_drop(Long.valueOf(0));
+        atomicfields.setstat_add_size(Long.valueOf(0));
+        atomicfields.setstat_add(Long.valueOf(0));
+        atomicfields.setIndexcacheusage(Integer.valueOf(0));
         indexcache=new StringKeyHashMap<TableIndexNodeTransactional>();
     }
      
@@ -268,6 +285,7 @@ public class DualFileTableTransactional implements TableTransactional{
          switch(type){
              case FILEA  : if(fileastream==null){
                                // fileastream=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFileName(FILEA),true)));
+                                System.out.println("file a " + getFileName(FILEA));
                                 fileastream=new TransactionalFile(getFileName(FILEA),"rw");
                                  
                                 //File ftest=new File(getFileName(FILEA));
@@ -277,6 +295,7 @@ public class DualFileTableTransactional implements TableTransactional{
                            }
                           break;
              case FILEB  : if(filebstream==null){
+                                System.out.println("file a " + getFileName(FILEB));
                                 filebstream=new TransactionalFile(getFileName(FILEB),"rw");
                                 //File ftest=new File(getFileName(FILEB));
                                 //atomicfields.setFilebposition(ftest.length());
@@ -391,14 +410,11 @@ public class DualFileTableTransactional implements TableTransactional{
      
 
      private void updateCacheEntry(TableIndexEntryTransactional entry){
-          final Vector args = new Vector();
-          args.add(entry);
-          Thread.doIt(new Callable<Boolean>() {
-             public Boolean call() throws Exception{
+        
           //synchronized(indexcache){
-              if(indexcache.containsKey(((TableIndexEntryTransactional)(args.get(0))).getId())){
-                  TableIndexNodeTransactional node=indexcache.get(((TableIndexEntryTransactional)(args.get(0))).getId());
-                  node.setData(((TableIndexEntryTransactional)(args.get(0))));
+              if(indexcache.containsKey(entry.getId())){
+                  TableIndexNodeTransactional node=indexcache.get(entry.getId());
+                  node.setData(entry);
                   if(node!=indexcachelast){
                       if(node==indexcachefirst){
                           indexcachefirst=node.getNext();
@@ -410,11 +426,11 @@ public class DualFileTableTransactional implements TableTransactional{
                       indexcachelast=node;
                   }
               }else{
-                  addCacheEntry(((TableIndexEntryTransactional)(args.get(0))));
+                  addCacheEntry(entry);
               }
-              return true;
-            }
-        });
+           //   return true;
+         //   }
+       // });
       }
 
       private void removeCacheEntry(String id){
@@ -454,14 +470,10 @@ public class DualFileTableTransactional implements TableTransactional{
       }
 
       private TableIndexEntryTransactional getCacheEntry(String id){
-          final Vector args = new Vector();
-          args.add(id);
-          
-          TableIndexEntryTransactional res = Thread.doIt(new Callable<TableIndexEntryTransactional>() {
-             public TableIndexEntryTransactional call() throws Exception{
+         
           //synchronized(indexcache){
-              if(indexcache.containsKey((String)(args.get(0)))){
-                  TableIndexNodeTransactional node=indexcache.get((String)(args.get(0)));
+              if(indexcache.containsKey(id)){
+                  TableIndexNodeTransactional node=indexcache.get(id);
                   if(node!=indexcachelast){
                       if(node==indexcachefirst){
                             indexcachefirst=node.getNext();
@@ -477,19 +489,10 @@ public class DualFileTableTransactional implements TableTransactional{
                 //   }
                   return node.getData();
               }
-              return null;
-             }
-          });
-          if (res != null)
-              return res;
-          
-          Thread.doIt(new Callable<Boolean>() {
-             public Boolean call() throws Exception{
+
           //synchronized(statlock){
                atomicfields.setstat_cache_miss(atomicfields.getstat_cache_miss()+1);
-               return true;
-             }
-          });
+
            //}
           return null;
       }
index b7d19687a1561cc6e4fe9432c71f24a967bf70a9..c0588cd777a21bde2a5fada39c465b77c3aeca17 100644 (file)
@@ -42,7 +42,7 @@ import com.solidosystems.tuplesoup.filter.*;
  * Every row must have a unique id within a table.
  */
 public class HashedTable implements Table{
-    private int TABLESETSIZE=16;
+    private int TABLESETSIZE=5;
     private List<Table> tableset;
     private String title;
     private String location;
index c034aa1a7bbfe48806ee2befeea6504dbdca81ae..e9c5cad73d505ea41f8a5da3cb43046af9a74aea 100644 (file)
  import java.util.*;
  import java.util.concurrent.Callable;
  import dstm2.Thread;
+import dstm2.factory.Factory;
 
 public class IndexedTableReaderTransactional extends TupleStreamTransactional{
+
+    
     private DataInputStream fileastream=null;
     private DataInputStream filebstream=null;
     private long fileaposition=0;
index a790399500df957341eb13082085c25311b048e8..a36fb047b7982963e0bee4919f92e6e8b903b9a6 100644 (file)
@@ -59,15 +59,19 @@ protected static final int INITIALPAGEHASH=1024;
         if(!ftest.exists())ftest.createNewFile();
         out=new RandomAccessFile(filename,"rw");
         root=new TableIndexPage[INITIALPAGEHASH];
+        System.out.println(filename);
+        System.out.println(out.length());
         if(out.length()>0){
             for(int i=0;i<INITIALPAGEHASH;i++){
                 root[i]=new TableIndexPage(this,out);
                 root[i].setFirst();
+                System.out.println("In loop " + root[i].getEndLocation());
                 out.seek(root[i].getEndLocation());
             }
         }else{
             for(int i=0;i<INITIALPAGEHASH;i++){
                 root[i]=TableIndexPage.createNewPage(this,out,PAGESIZE);
+                System.out.println("In Othe loop " + root[i].getEndLocation());
                 root[i].setFirst();
             }
         }
index b33122c14a2725e8db7e900fde5b74140f4ecaa4..2034f9f69a78d85aee751636e2a8f3eb09be74e5 100644 (file)
@@ -9,6 +9,7 @@ import TransactionalIO.core.TransactionalFile;
 import dstm2.AtomicArray;
 import dstm2.atomic;
 import dstm2.Thread;
+import dstm2.factory.Factory;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -23,6 +24,8 @@ import java.util.concurrent.Callable;
  */
 public class PagedIndexTransactional implements TableIndexTransactional{
 
+    static Factory<PageIndexTSInf> factory = Thread.makeFactory(PageIndexTSInf.class);
+    
     PageIndexTSInf atomicfields;
    
 
@@ -51,21 +54,32 @@ public class PagedIndexTransactional implements TableIndexTransactional{
     protected static final int PAGESIZE=2048;
     
         public PagedIndexTransactional(String filename) throws IOException{
+        atomicfields = factory.create();
+        
+        atomicfields.setStat_create_page(Long.valueOf(0));
+        atomicfields.setStat_page_branch(Long.valueOf(0));
+        atomicfields.setStat_page_next(Long.valueOf(0));
+        atomicfields.setStat_read(Long.valueOf(0));
+        atomicfields.setStat_write(Long.valueOf(0));
+        
         this.atomicfields.setFilename(filename);
         File ftest=new File(filename);
         if(!ftest.exists())ftest.createNewFile();
         out=new TransactionalFile(filename,"rw");
         atomicfields.setRoots(new AtomicArray<TableIndexPageTransactional>(TableIndexPageTransactional.class, INITIALPAGEHASH));
-    
+        System.out.println(filename);
+        System.out.println(out.length());
         if(out.length()>0){
             for(int i=0;i<INITIALPAGEHASH;i++){
                 atomicfields.getRoots().set(i, new TableIndexPageTransactional(this,out));
                 atomicfields.getRoots().get(i).setFirst();
+                System.out.println("In loop " + atomicfields.getRoots().get(i).getEndLocation());
                 out.seek(atomicfields.getRoots().get(i).getEndLocation());
             }
         }else{
             for(int i=0;i<INITIALPAGEHASH;i++){
                 atomicfields.getRoots().set(i, TableIndexPageTransactional.createNewPage(this,out,PAGESIZE));
+                     System.out.println("In Othe loop " + atomicfields.getRoots().get(i).getEndLocation());
                 atomicfields.getRoots().get(i).setFirst();
             }
         }
index cbe908cdf267c221769aca4fd82fff85b8e5c90e..3bdf0e8ac7c0cf65d384fa16f7627c9b251b2f98 100644 (file)
@@ -7,6 +7,8 @@ package com.solidosystems.tuplesoup.core;
 
 import TransactionalIO.core.TransactionalFile;
 import dstm2.atomic;
+import dstm2.Thread;
+import dstm2.factory.Factory;
 import dstm2.util.StringKeyHashMap;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
@@ -22,6 +24,8 @@ import java.util.Set;
  * @author navid
  */
 public class RowTransactional {
+     Factory<RowTSInf> factory = Thread.makeFactory(RowTSInf.class);
+     
      private String id;
     // private int size;
      RowTSInf atomicfields;
@@ -33,6 +37,8 @@ public class RowTransactional {
      }
      
      public RowTransactional(String id){
+         atomicfields = factory.create();
+         
          this.id=id;
          atomicfields.setSize(-1);
          values=new StringKeyHashMap<ValueTransactional>();
index 4102ff4c882db24ef9e0fdd75e78355b3cb40d1e..a944a6c9caff39ab36128136dbc63e72d48c3a90 100644 (file)
@@ -162,6 +162,7 @@ public class TableIndexEntry implements Comparable<TableIndexEntry>{
     protected static TableIndexEntry readData(DataInputStream in) throws IOException{
         in.readInt();
         int num=in.readShort();
+        System.out.println("num=444444444444444444444444 " + num);
         StringBuilder buf=new StringBuilder(num);
         for(int i=0;i<num;i++){
             buf.append(in.readChar());
index f9166e54df0339e4b16c23c8de694fc5a1538df0..eaca765b2d4631f68792960dafccb00f696a4d74 100644 (file)
@@ -8,6 +8,8 @@ package com.solidosystems.tuplesoup.core;
 import TransactionalIO.core.TransactionalFile;
 import dstm2.AtomicSuperClass;
 import dstm2.atomic;
+import dstm2.Thread;
+import dstm2.factory.Factory;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -20,24 +22,28 @@ import java.io.RandomAccessFile;
  * @author navid
  */
 public class TableIndexEntryTransactional implements AtomicSuperClass, Comparable<TableIndexEntryTransactional>{
-
+     
+    static Factory<TableIndexEntryTSInf> factory = Thread.makeFactory(TableIndexEntryTSInf.class);
+    
     TableIndexEntryTSInf atomicfields;
     public @atomic interface TableIndexEntryTSInf{
         String getId();
-        int getLocation();
-        long getPosition();
-        int getSize();
-        int getRowsize();
+        Integer getLocation();
+        Long getPosition();
+        Integer getSize();
+        Integer getRowsize();
         
         void setId(String val);
-        void setLocation(int val);
-        void setPosition(long val);
-        void setSize(int val);
-        void setRowsize(int val);
+        void setLocation(Integer val);
+        void setPosition(Long val);
+        void setSize(Integer val);
+        void setRowsize(Integer val);
     }
        
          
     public TableIndexEntryTransactional(String id,int rowsize,int location,long position){
+        atomicfields = factory.create();
+        
         this.atomicfields.setId(id);
         this.atomicfields.setLocation(location);
         this.atomicfields.setPosition(position);
@@ -61,7 +67,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
     }
     
     public int getRowSize(){
-        return atomicfields.getRowsize();
+        return atomicfields.getRowsize().intValue();
     }
     
     public int compareTo(TableIndexEntryTransactional obj) throws ClassCastException{
@@ -87,7 +93,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
     
     public int getSize(){
         if(atomicfields.getSize()<0) calcSize();
-        return atomicfields.getSize();
+        return atomicfields.getSize().intValue();
     }
     public void setSize(int size){
         this.atomicfields.setSize(size);
@@ -99,7 +105,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
             dout.writeInt(atomicfields.getId().hashCode());
             dout.writeShort(atomicfields.getId().length());
             dout.writeChars(atomicfields.getId());
-            dout.writeInt(atomicfields.getRowsize());
+            dout.writeInt(atomicfields.getRowsize().intValue());
             dout.writeByte(atomicfields.getLocation());
             dout.writeLong(atomicfields.getPosition());
             setSize(bout.size());
@@ -115,7 +121,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
         out.writeInt(atomicfields.getId().hashCode());
         out.writeShort(atomicfields.getId().length());
         out.writeChars(atomicfields.getId());
-        out.writeInt(atomicfields.getRowsize());
+        out.writeInt(atomicfields.getRowsize().intValue());
         out.writeByte(atomicfields.getLocation());
         out.writeLong(atomicfields.getPosition());
         setSize((int)(out.getFilePointer()-pre));
@@ -123,7 +129,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
     protected void updateData(TransactionalFile out) throws IOException{
         long pre=out.getFilePointer();
         out.skipBytes(4+2+atomicfields.getId().length()*2);
-        out.writeInt(atomicfields.getRowsize());
+        out.writeInt(atomicfields.getRowsize().intValue());
         out.writeByte(atomicfields.getLocation());
         out.writeLong(atomicfields.getPosition());
         setSize((int)(out.getFilePointer()-pre));
@@ -132,7 +138,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
         out.writeInt(atomicfields.getId().hashCode());
         out.writeShort(atomicfields.getId().length());
         out.writeChars(atomicfields.getId());
-        out.writeInt(atomicfields.getRowsize());
+        out.writeInt(atomicfields.getRowsize().intValue());
         out.writeByte(atomicfields.getLocation());
         out.writeLong(atomicfields.getPosition());
     }
@@ -140,6 +146,7 @@ public class TableIndexEntryTransactional implements AtomicSuperClass, Comparabl
         long pre=in.getFilePointer();
         in.readInt();
         int num=in.readShort();
+        //System.out.println("num= " + num);
         StringBuilder buf=new StringBuilder(num);
         for(int i=0;i<num;i++){
             buf.append(in.readChar());
index 73c60682d23e93202c54603a082fa1c984dbbd78..9de22949c3a1c2230ec184a022ec2ee32cfd04da 100644 (file)
@@ -7,6 +7,8 @@ package com.solidosystems.tuplesoup.core;
 
 import dstm2.AtomicSuperClass;
 import dstm2.atomic;
+import dstm2.Thread;
+import dstm2.factory.Factory;
 
 /**
  *
@@ -17,9 +19,10 @@ public class TableIndexNodeTransactional implements AtomicSuperClass{
     //private TableIndexNodeTransactional previous;
     //private TableIndexEntryTransactional data;
     //private TableIndexNodeTransactional next;
-    TableIndexInodeTSinf atomicfields;
+    static Factory<TableIndexInodeTSInf> factory = Thread.makeFactory(TableIndexInodeTSInf.class);
+    TableIndexInodeTSInf atomicfields;
     
-    public @atomic interface TableIndexInodeTSinf{
+    public @atomic interface TableIndexInodeTSInf{
         TableIndexNodeTransactional getPrevious(); 
         TableIndexEntryTransactional getData(); 
         TableIndexNodeTransactional getNext(); 
@@ -30,12 +33,16 @@ public class TableIndexNodeTransactional implements AtomicSuperClass{
     }
     
     public TableIndexNodeTransactional(){
+        atomicfields = factory.create();
+        
         atomicfields.setPrevious(null);
         atomicfields.setData(null);
         atomicfields.setNext(null);
     }
     
     public TableIndexNodeTransactional(TableIndexEntryTransactional entry){
+        atomicfields = factory.create();
+        
         atomicfields.setPrevious(null);
         atomicfields.setData(entry);
         atomicfields.setNext(null);
@@ -43,12 +50,16 @@ public class TableIndexNodeTransactional implements AtomicSuperClass{
     }
     
     public TableIndexNodeTransactional(TableIndexNodeTransactional prev,TableIndexEntryTransactional entry){
+        atomicfields = factory.create();
+        
         atomicfields.setPrevious(prev);
         atomicfields.setData(entry);
         atomicfields.setNext(null);
     }
     
     public TableIndexNodeTransactional(TableIndexNodeTransactional prev,TableIndexEntryTransactional entry,TableIndexNodeTransactional nex){
+        atomicfields = factory.create();
+        
         atomicfields.setPrevious(prev);
         atomicfields.setData(entry);
         atomicfields.setNext(nex);
index 375492179e6c07802dd4e6d4a13cd308a89ebdfe..dc8c289016713958ed03729b5882239d13f12683 100644 (file)
@@ -54,26 +54,43 @@ public class TableIndexPage{
     private PagedIndex index=null;
     
     public TableIndexPage(PagedIndex index,RandomAccessFile file) throws IOException{
-        this.file=file;
+           this.file=file;
         this.index=index;
         first=false;
         location=file.getFilePointer();
+        System.out.println(location);
         size=file.readInt();
         next=file.readLong();
         lower=file.readLong();
         offset=file.readInt();
         endhash=file.readInt();
+        System.out.println("si " + size);
+        System.out.println("next "  + next);
+        System.out.println("lower " + lower);
+        System.out.println("offset " + offset);
+        System.out.println("endhash " + endhash);
         if(offset>0)starthash=file.readInt();
+        System.out.println("here tav;eindepage");
+        
+        
     }
     
     public static TableIndexPage createNewPage(PagedIndex index,RandomAccessFile file,int size) throws IOException{
         long pre=file.length();
+        System.out.println("pre " + pre);
+           System.out.println("pointer1 " + file.length()+size+BASEOFFSET);
         file.setLength(file.length()+size+BASEOFFSET);
         file.seek(pre);
+     
+        System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(size);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeLong(-1l);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeLong(-1l);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(0);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(-1);
         file.seek(pre);
         index.stat_create_page++;
@@ -140,7 +157,9 @@ public class TableIndexPage{
     }
     
     public TableIndexEntry scanIndex(String id,int hashcode) throws IOException{
+        System.out.println("sacn index");
         if(!first){
+              
             if(hashcode<starthash){
                 if(lower==-1)return null;
                 if(lowerpage==null){
@@ -152,6 +171,7 @@ public class TableIndexPage{
             }
         }
         if(hashcode>endhash){
+            
             if(next==-1)return null;
             if(nextpage==null){
                 file.seek(next);
@@ -163,11 +183,15 @@ public class TableIndexPage{
         file.seek(location+BASEOFFSET);
         long pre=file.getFilePointer();
         while(file.getFilePointer()<pre+offset){
+            System.out.println("neddddxtex " + next);
             TableIndexEntry entry=TableIndexEntry.lookForData(id,file);
             if(entry!=null)return entry;
         }
+        System.out.println("neddddxt " + next);
         if(next==-1)return null;
+      
         if(nextpage==null){
+            System.out.println("next " + next);
             file.seek(next);
             nextpage=new TableIndexPage(index,file);
         }
index bf7e0cb9c66e846efcde3f3757696ca349f27546..e2bebd1b70c07cee973822ab426e010700694e53 100644 (file)
@@ -34,15 +34,20 @@ package com.solidosystems.tuplesoup.core;
 import TransactionalIO.core.TransactionalFile;
 import dstm2.AtomicSuperClass;
 import dstm2.atomic;
+import dstm2.Thread;
+import dstm2.factory.Factory;
 import java.io.*;
 import java.util.*;
 
 public class TableIndexPageTransactional implements AtomicSuperClass{
-    TableIndexPageTSInf atomicfields = null;
+    static Factory<TableIndexPageTSInf> factory = Thread.makeFactory(TableIndexPageTSInf.class);
+    
+    /*static*/ TableIndexPageTSInf atomicfields = null;
     private final static int BASEOFFSET=4+8+8+4+4;
     //private RandomAccessFile file=null;
     private TransactionalFile file = null;
     
+    
     public @atomic interface TableIndexPageTSInf{
         Long getLocation();
         Integer getSize();
@@ -60,8 +65,8 @@ public class TableIndexPageTransactional implements AtomicSuperClass{
         void setLowerpage(TableIndexPageTransactional lowerpage);   
         void setNextpage(TableIndexPageTransactional nextpage);
         void setFirst(Boolean val);
-        void setEndhash(int val);
-        void setStarthash(int val);
+        void setEndhash(Integer val);
+        void setStarthash(Integer val);
         void setOffset(Integer offset);
         void setNext(Long next);
         void setSize(Integer size);
@@ -74,28 +79,63 @@ public class TableIndexPageTransactional implements AtomicSuperClass{
     
     public TableIndexPageTransactional(PagedIndexTransactional index,TransactionalFile file) throws IOException{
         this.file=file;
+        atomicfields = factory.create();
         this.atomicfields.setIndex(index);
         this.atomicfields.setFirst(false);
         this.atomicfields.setLocation(file.getFilePointer());
+        System.out.println(file.getFilePointer());
         this.atomicfields.setSize(file.readInt());
+         System.out.println(file.getFilePointer());
         this.atomicfields.setNext(file.readLong());
+         System.out.println(file.getFilePointer());
         this.atomicfields.setLower(file.readLong());
+         System.out.println(file.getFilePointer());
+          System.out.println(file.getFilePointer());
         this.atomicfields.setOffset(file.readInt());
+         System.out.println(file.getFilePointer());
         this.atomicfields.setEndhash(file.readInt());
+             System.out.println("size " + atomicfields.getSize());
+        System.out.println("next "  + atomicfields.getNext());
+        System.out.println("lower " + atomicfields.getLower());
+        System.out.println("offset " + atomicfields.getOffset());
+        System.out.println("endhash " + atomicfields.getEndhash());
         if(this.atomicfields.getOffset()>0)
             this.atomicfields.setStarthash(file.readInt());
+        else 
+            this.atomicfields.setStarthash(-1);
     }
     
     public static TableIndexPageTransactional createNewPage(PagedIndexTransactional index,TransactionalFile file,int size) throws IOException{
+    
         long pre=file.length();
+        System.out.println("pre " + pre);
 //        file.setLength(file.length()+size+BASEOFFSET);
         file.seek(pre);
+        byte[] dummy = new byte[size+BASEOFFSET];
+        file.write(dummy);
+        System.out.println("pointer " + file.getFilePointer());
+        
+        file.seek(pre);
+        System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(size);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeLong(-1l);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeLong(-1l);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(0);
+         System.out.println("pointer2 " + file.getFilePointer());
         file.writeInt(-1);
         file.seek(pre);
+        file.readInt();
+        file.readLong();
+        file.readLong();
+        file.readInt();
+        file.readInt();
+        file.seek(pre);
+        
+        //index.atomicfields.setStat_create_page((long)2);
         index.atomicfields.setStat_create_page(index.atomicfields.getStat_create_page()+1);
         return new TableIndexPageTransactional(index,file);
     }
@@ -183,6 +223,7 @@ public class TableIndexPageTransactional implements AtomicSuperClass{
         file.seek(this.atomicfields.getLocation()+BASEOFFSET);
         long pre=file.getFilePointer();
         while(file.getFilePointer()<pre+this.atomicfields.getOffset()){
+            System.out.println("neddddxtex " + atomicfields.getNext());
             TableIndexEntryTransactional entry=TableIndexEntryTransactional.lookForData(id,file);
             if(entry!=null)return entry;
         }
index ab7083b93dbb1067ca554a0e362595d02f27a450..1b560d6a9f156f88224f892e09e9764c0533338e 100644 (file)
@@ -9,8 +9,10 @@ import TransactionalIO.core.TransactionalFile;
 import dstm2.AtomicByteArray;
 import dstm2.AtomicSuperClass;
 import dstm2.atomic;
+import dstm2.factory.Factory;
 import java.util.*;
- import java.io.*;
+import java.io.*;
+import dstm2.Thread;
 
 /**
  *
@@ -19,18 +21,19 @@ import java.util.*;
 public class ValueTransactional implements AtomicSuperClass{
 
      ValueTSInf atomicfields;
+     static Factory<ValueTSInf> factory = Thread.makeFactory(ValueTSInf.class);
      
      public @atomic interface ValueTSInf{
-         byte getType();
+         Byte getType();
          String getStr_value();
-         long getInt_value();
-         double getFloat_value();
+         Long getInt_value();
+         Double getFloat_value();
          AtomicByteArray getBinary();
          
-         void setType(byte val);
+         void setType(Byte val);
          void setStr_value(String val);
-         void setInt_value(long val);
-         void setFloat_value(double val);
+         void setInt_value(Long val);
+         void setFloat_value(Double val);
          void setBinary(AtomicByteArray bytes);
      }   
      
@@ -84,12 +87,12 @@ public class ValueTransactional implements AtomicSuperClass{
          int hash=0;
          switch(atomicfields.getType()){
              case STRING     : hash+=atomicfields.getStr_value().hashCode();
-             case INT        : hash+=(int)atomicfields.getInt_value();
-             case LONG       : hash+=(int)atomicfields.getInt_value();
-             case FLOAT      : hash+=(int)atomicfields.getFloat_value();
-             case DOUBLE     : hash+=(int)atomicfields.getFloat_value();
-             case BOOLEAN    : hash+=(int)atomicfields.getInt_value();
-             case TIMESTAMP  : hash+=(int)atomicfields.getInt_value();
+             case INT        : hash+=atomicfields.getInt_value();
+             case LONG       : hash+=atomicfields.getInt_value();
+             case FLOAT      : hash+=atomicfields.getFloat_value();
+             case DOUBLE     : hash+=atomicfields.getFloat_value();
+             case BOOLEAN    : hash+=atomicfields.getInt_value();
+             case TIMESTAMP  : hash+=atomicfields.getInt_value();
              case BINARY     : hash+=atomicfields.getBinary().hashCode();
          }
          return hash;
@@ -311,11 +314,11 @@ public class ValueTransactional implements AtomicSuperClass{
          try{
              switch(atomicfields.getType()){
                  case STRING     : return Integer.parseInt(atomicfields.getStr_value());
-                 case INT        : return (int)atomicfields.getInt_value();
-                 case LONG       : return (int)atomicfields.getInt_value();
-                 case FLOAT      : return (int)atomicfields.getFloat_value();
-                 case DOUBLE     : return (int)atomicfields.getFloat_value();
-                 case BOOLEAN    : return (int)atomicfields.getInt_value();
+                 case INT        : return atomicfields.getInt_value().intValue();
+                 case LONG       : return (int)atomicfields.getInt_value().intValue();
+                 case FLOAT      : return (int)atomicfields.getFloat_value().intValue();
+                 case DOUBLE     : return (int)atomicfields.getFloat_value().intValue();
+                 case BOOLEAN    : return (int)atomicfields.getInt_value().intValue();
                  case TIMESTAMP  : return (int)(atomicfields.getInt_value()/1000);
              }
          }catch(Exception e){}
@@ -336,8 +339,8 @@ public class ValueTransactional implements AtomicSuperClass{
                  case STRING     : return Long.parseLong(atomicfields.getStr_value());
                  case INT        : return atomicfields.getInt_value();
                  case LONG       : return atomicfields.getInt_value();
-                 case FLOAT      : return (long)atomicfields.getFloat_value();
-                 case DOUBLE     : return (long)atomicfields.getFloat_value();
+                 case FLOAT      : return (long)atomicfields.getFloat_value().longValue();
+                 case DOUBLE     : return (long)atomicfields.getFloat_value().longValue();
                  case BOOLEAN    : return atomicfields.getInt_value();
                  case TIMESTAMP  : return atomicfields.getInt_value();
              }
@@ -357,11 +360,11 @@ public class ValueTransactional implements AtomicSuperClass{
          try{
              switch(atomicfields.getType()){
                  case STRING     : return Float.parseFloat(atomicfields.getStr_value());
-                 case INT        : return (float)atomicfields.getInt_value();
-                 case LONG       : return (float)atomicfields.getInt_value();
-                 case FLOAT      : return (float)atomicfields.getFloat_value();
-                 case DOUBLE     : return (float)atomicfields.getFloat_value();
-                 case BOOLEAN    : return (float)atomicfields.getInt_value();
+                 case INT        : return (float)atomicfields.getInt_value().floatValue();
+                 case LONG       : return (float)atomicfields.getInt_value().floatValue();
+                 case FLOAT      : return (float)atomicfields.getFloat_value().floatValue();
+                 case DOUBLE     : return (float)atomicfields.getFloat_value().floatValue();
+                 case BOOLEAN    : return (float)atomicfields.getInt_value().floatValue();
                  case TIMESTAMP  : return (float)(atomicfields.getInt_value()/1000);
              }
          }catch(Exception e){}
@@ -433,7 +436,7 @@ public class ValueTransactional implements AtomicSuperClass{
                  case INT        : return new Date(atomicfields.getInt_value()*1000l);
                  case LONG       : return new Date(atomicfields.getInt_value());
                  case FLOAT      : return new Date((long)(atomicfields.getFloat_value()*1000l));
-                 case DOUBLE     : return new Date((long)atomicfields.getFloat_value());
+                 case DOUBLE     : return new Date((long)atomicfields.getFloat_value().longValue());
                  case TIMESTAMP  : return new Date(atomicfields.getInt_value());
              }
          }catch(Exception e){}
@@ -462,11 +465,11 @@ public class ValueTransactional implements AtomicSuperClass{
                                  out.writeChar(atomicfields.getStr_value().charAt(i));
                              }
                          break;
-             case INT    :   out.writeInt((int)atomicfields.getInt_value());
+             case INT    :   out.writeInt((int)atomicfields.getInt_value().intValue());
                          break;
              case LONG   :   out.writeLong(atomicfields.getInt_value());
                          break;
-             case FLOAT  :   out.writeFloat((float)atomicfields.getFloat_value());
+             case FLOAT  :   out.writeFloat((float)atomicfields.getFloat_value().intValue());
                          break;
              case DOUBLE :   out.writeDouble(atomicfields.getFloat_value());
                          break;
@@ -496,11 +499,11 @@ public class ValueTransactional implements AtomicSuperClass{
                                   out.writeChar(atomicfields.getStr_value().charAt(i));
                               }
                           break;
-              case INT    :   out.writeInt((int)atomicfields.getInt_value());
+              case INT    :   out.writeInt((int)atomicfields.getInt_value().intValue());
                           break;
               case LONG   :   out.writeLong(atomicfields.getInt_value());
                           break;
-              case FLOAT  :   out.writeFloat((float)atomicfields.getFloat_value());
+              case FLOAT  :   out.writeFloat((float)atomicfields.getFloat_value().intValue());
                           break;
               case DOUBLE :   out.writeDouble(atomicfields.getFloat_value());
                           break;
@@ -562,6 +565,7 @@ public class ValueTransactional implements AtomicSuperClass{
      
      public ValueTransactional(byte[] val){
          this();
+         atomicfields.setBinary(new AtomicByteArray(Byte.class, val.length));
          for (int i=0; i<val.length; i++) 
                  atomicfields.getBinary().set(i, val[i]);
          
@@ -583,8 +587,9 @@ public class ValueTransactional implements AtomicSuperClass{
       * Initializes this Value as null.
       */
      public ValueTransactional(){
+         atomicfields = factory.create();
          atomicfields.setStr_value(null);
-         atomicfields.setInt_value(0);
+         atomicfields.setInt_value(Long.valueOf(0));
          atomicfields.setFloat_value(0.0);
          atomicfields.setBinary(new AtomicByteArray(Byte.class, NULL));
          atomicfields.setType((byte)NULL);
@@ -597,7 +602,7 @@ public class ValueTransactional implements AtomicSuperClass{
       */
      public ValueTransactional(int val){
          this();
-         atomicfields.setInt_value(val);
+         atomicfields.setInt_value(Long.valueOf(val));
          atomicfields.setType((byte)INT);
      }
 
@@ -619,7 +624,7 @@ public class ValueTransactional implements AtomicSuperClass{
       */
      public ValueTransactional(float val){
          this();
-         atomicfields.setFloat_value(val);
+         atomicfields.setFloat_value(Double.valueOf(val));
          atomicfields.setType((byte)FLOAT);
      }
 
@@ -642,9 +647,9 @@ public class ValueTransactional implements AtomicSuperClass{
      public ValueTransactional(boolean val){
          this();
          if(val){
-             atomicfields.setInt_value(1);
+             atomicfields.setInt_value(Long.valueOf(1));
          }else{
-             atomicfields.setInt_value(0);
+             atomicfields.setInt_value(Long.valueOf(0));
          }
          atomicfields.setType((byte)BOOLEAN);
      }  
diff --git a/Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelPerformanceTest.java b/Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelPerformanceTest.java
new file mode 100644 (file)
index 0000000..6688cd8
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2007, Solido Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of Solido Systems nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+ package com.solidosystems.tuplesoup.test;
+ import com.solidosystems.tuplesoup.core.*;
+ import com.solidosystems.tuplesoup.filter.*;
+  
+import dstm2.Init;
+ import java.util.*;
+ import java.io.*;
+
+
+public class OrigParralelPerformanceTest extends BasicTest implements Runnable{
+    
+    long writetime;
+    long readtime;
+    long randomtime;
+    
+    public OrigParralelPerformanceTest(){
+              String path="/home/navid/Volumes/My Book/test/";
+        try{
+            //int records=50000;
+            int records=5;
+            for(int i=1;i<2/*11*/;i++){
+                outbr("Running Parallel DualFileTable Performance test");
+                outbr(1,i+" x "+(records/i)+" Large records");
+            
+               // outbr(2,"Memory index");
+             /*   Table table=new DualFileTable("Performance-test",path,Table.MEMORY);
+                benchmark(table,i,(records/i));
+                table.close();
+                table.deleteFiles();*/
+            
+              /*  outbr(2,"Flat index");
+                table=new DualFileTable("Performance-test",path,Table.FLAT);
+                benchmark(table,i,(records/i));
+                table.close();
+                table.deleteFiles();*/
+            
+                outbr(2,"Paged index");
+                Table table=new DualFileTable("Performance-test",path,Table.PAGED);
+                //TableTransactional table=new DualFileTableTransactional("Performance-test",path,TableTransactional.PAGED);
+                benchmark(table,5,(records/i));
+                table.close();
+             //   table.deleteFiles();
+            
+                outbr("Running Parallel HashedTable Performance test");
+                outbr(1,i+" x "+(records/i)+" Large records");
+            
+            /*    outbr(2,"Memory index");
+                table=new HashedTable("Performance-test",path,Table.MEMORY);
+                benchmark(table,i,(records/i));
+                table.close();
+                table.deleteFiles();
+            
+                outbr(2,"Flat index");
+                table=new HashedTable("Performance-test",path,Table.FLAT);
+                benchmark(table,i,(records/i));
+                table.close();
+                table.deleteFiles();*/
+            
+            //    outbr(2,"Paged index");
+                //table=new HashedTableTransactional("Performance-test",path,TableTransactional.PAGED);
+            //    table=new HashedTable("Performance-test",path,Table.PAGED);
+            //    benchmark(table,i,(records/i));
+            //    table.close();
+              //  table.deleteFiles();*/
+            }
+            
+            
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+    public static void main(String[] args){
+        Init.init();
+        new OrigParralelPerformanceTest();
+    }
+    
+    public void benchmark(Table table,int threadcount, int records) throws Exception{
+        writetime=0;
+        readtime=0;
+        randomtime=0;
+        List<Thread> lst=new ArrayList<Thread>();
+        for(int i=0;i<threadcount;i++){
+            Thread thr=new Thread(new OrigParralelThread(this,table,i+"",records));
+            thr.start();
+            lst.add(thr);
+        }
+        for(int i=0;i<threadcount;i++){
+            lst.get(i).join();
+        }
+        outbr(3,"Write "+writetime+" ms");
+        outbr(3,"Read "+readtime+" ms");
+        outbr(3,"Random "+randomtime+" ms");
+    }
+    
+    public void run(){
+        
+    }
+    
+    public long benchmarkLargeWrite(Table table,int records, String id) throws IOException{
+        long pre=System.currentTimeMillis();
+        for(int i=0;i<records;i++){
+           // RowTransactional row=new RowTransactional(id+i);
+            Row row=new Row(id+i);
+            row.put("key1","foobarbaz");
+            row.put("key2",123456);
+            row.put("key3",3.141592);
+            row.put("key4",true);
+            row.put("key5",new Value(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}));
+            table.addRow(row);
+        }
+        long post=System.currentTimeMillis();
+        return post-pre;
+    }
+    public long benchmarkLargeRead(Table table,int records, String id) throws IOException{
+        long pre=System.currentTimeMillis();
+        TupleStream stream=table.getRows();
+        //TupleStreamTransactional stream=table.getRows();
+        while(stream.hasNext()){
+            stream.next();
+        }
+        long post=System.currentTimeMillis();
+        return post-pre;
+    }
+    public long benchmarkLargeRandomRead(Table table,int records, String id) throws IOException{
+        long pre=System.currentTimeMillis();
+        for(int i=0;i<records;i++){
+            Row row=table.getRow(id+(int)(Math.random()*records));
+            //RowTransactional row=table.getRow(id+(int)(Math.random()*records));
+        }
+        long post=System.currentTimeMillis();
+        return post-pre;
+    }
+
+    public void printStats(Hashtable<String,Long> hash){
+        Set<String> keys=hash.keySet();
+        Iterator<String> it=keys.iterator();
+        while(it.hasNext()){
+            String key=it.next();
+            outbr(4,key+" "+hash.get(key));
+        }
+    }
+}
\ No newline at end of file
diff --git a/Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelThread.java b/Robust/Transactions/mytuplesoup/src/com/solidosystems/tuplesoup/test/OrigParralelThread.java
new file mode 100644 (file)
index 0000000..3d5a024
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2007, Solido Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of Solido Systems nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+ package com.solidosystems.tuplesoup.test;
+ import com.solidosystems.tuplesoup.core.*;
+ import com.solidosystems.tuplesoup.filter.*;
+  
+ import java.util.*;
+ import java.io.*;
+
+
+public class OrigParralelThread implements Runnable{
+    String id;
+    int records;
+    OrigParralelPerformanceTest app;
+    Table table;
+    //TableTransactional table;
+    
+    public OrigParralelThread(OrigParralelPerformanceTest app,Table table,String id,int records){
+        this.id=id;
+        this.records=records;
+        this.app=app;
+        this.table=table;
+    }
+    
+    public void run(){
+        try{
+            //long time;
+            long time=app.benchmarkLargeWrite(table,records,id);
+            synchronized(app){
+                app.writetime+=time;
+            }
+            /*long*/ time=app.benchmarkLargeRead(table,records,id);
+            synchronized(app){
+                app.readtime+=time;
+           }
+            time=app.benchmarkLargeRandomRead(table,records,id);
+            synchronized(app){
+               app.randomtime+=time;
+           }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+}
\ No newline at end of file
index e4173c3f9a205dba4705a9caba15f5f0e85388c1..adb7188c690e49927b96e0dad121aa5094037d43 100644 (file)
@@ -34,6 +34,7 @@
  import com.solidosystems.tuplesoup.core.*;
  import com.solidosystems.tuplesoup.filter.*;
   
+import dstm2.Init;
  import java.util.*;
  import java.io.*;
 
@@ -45,10 +46,11 @@ public class ParallelPerformanceTest extends BasicTest implements Runnable{
     long randomtime;
     
     public ParallelPerformanceTest(){
-        String path="./Volumes/My Book/test/";
+              String path="/home/navid/Volumes/My Book/test/";
         try{
-            int records=50000;
-            for(int i=1;i<11;i++){
+            //int records=10;
+            int records=5;
+            for(int i=1;i<2;i++){
                 outbr("Running Parallel DualFileTable Performance test");
                 outbr(1,i+" x "+(records/i)+" Large records");
             
@@ -65,13 +67,14 @@ public class ParallelPerformanceTest extends BasicTest implements Runnable{
                 table.deleteFiles();*/
             
                 outbr(2,"Paged index");
-                Table table=new DualFileTable("Performance-test",path,Table.PAGED);
-                benchmark(table,i,(records/i));
+                //Table table=new DualFileTable("Performance-test",path,Table.PAGED);
+                TableTransactional table=new DualFileTableTransactional("Performance-test",path,TableTransactional.PAGED);
+                benchmark(table,5,(records/i));
                 table.close();
-                table.deleteFiles();
+             //   table.deleteFiles();
             
-                outbr("Running Parallel HashedTable Performance test");
-                outbr(1,i+" x "+(records/i)+" Large records");
+               // outbr("Running Parallel HashedTable Performance test");
+                //outbr(1,i+" x "+(records/i)+" Large records");
             
             /*    outbr(2,"Memory index");
                 table=new HashedTable("Performance-test",path,Table.MEMORY);
@@ -85,11 +88,12 @@ public class ParallelPerformanceTest extends BasicTest implements Runnable{
                 table.close();
                 table.deleteFiles();*/
             
-                outbr(2,"Paged index");
-                table=new HashedTable("Performance-test",path,Table.PAGED);
-                benchmark(table,i,(records/i));
-                table.close();
-                table.deleteFiles();
+             //   outbr(2,"Paged index");
+                //table=new HashedTableTransactional("Performance-test",path,TableTransactional.PAGED);
+             //   table=new HashedTableTransactional("Performance-test",path,TableTransactional.PAGED);
+            //    benchmark(table,i,(records/i));
+             //   table.close();
+              //  table.deleteFiles();*/
             }
             
             
@@ -98,10 +102,11 @@ public class ParallelPerformanceTest extends BasicTest implements Runnable{
         }
     }
     public static void main(String[] args){
+        Init.init();
         new ParallelPerformanceTest();
     }
     
-    public void benchmark(Table table,int threadcount, int records) throws Exception{
+    public void benchmark(TableTransactional table/*Table table*/,int threadcount, int records) throws Exception{
         writetime=0;
         readtime=0;
         randomtime=0;
@@ -123,33 +128,36 @@ public class ParallelPerformanceTest extends BasicTest implements Runnable{
         
     }
     
-    public long benchmarkLargeWrite(Table table,int records, String id) throws IOException{
+    public long benchmarkLargeWrite(TableTransactional table,int records, String id) throws IOException{
         long pre=System.currentTimeMillis();
         for(int i=0;i<records;i++){
-            Row row=new Row(id+i);
+            RowTransactional row=new RowTransactional(id+i);
+            //Row row=new Row(id+i);
             row.put("key1","foobarbaz");
             row.put("key2",123456);
             row.put("key3",3.141592);
             row.put("key4",true);
-            row.put("key5",new Value(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}));
+            row.put("key5",new ValueTransactional(new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}));
             table.addRow(row);
         }
         long post=System.currentTimeMillis();
         return post-pre;
     }
-    public long benchmarkLargeRead(Table table,int records, String id) throws IOException{
+    public long benchmarkLargeRead(TableTransactional table,int records, String id) throws IOException{
         long pre=System.currentTimeMillis();
-        TupleStream stream=table.getRows();
+        //TupleStream stream=table.getRows();
+        TupleStreamTransactional stream=table.getRows();
         while(stream.hasNext()){
             stream.next();
         }
         long post=System.currentTimeMillis();
         return post-pre;
     }
-    public long benchmarkLargeRandomRead(Table table,int records, String id) throws IOException{
+    public long benchmarkLargeRandomRead(TableTransactional table/*Table table*/,int records, String id) throws IOException{
         long pre=System.currentTimeMillis();
         for(int i=0;i<records;i++){
-            Row row=table.getRow(id+(int)(Math.random()*records));
+            //Row row=table.getRow(id+(int)(Math.random()*records));
+            RowTransactional row=table.getRow(id+(int)(Math.random()*records));
         }
         long post=System.currentTimeMillis();
         return post-pre;
index 2183470d8703b0efb09dc0f69f36ca823e45ff4d..b19cd048f9f6e112c65b5919ecb58dc3e0c3fa8a 100644 (file)
@@ -42,9 +42,10 @@ public class ParallelThread implements Runnable{
     String id;
     int records;
     ParallelPerformanceTest app;
-    Table table;
+    //Table table;
+    TableTransactional table;
     
-    public ParallelThread(ParallelPerformanceTest app,Table table,String id,int records){
+    public ParallelThread(ParallelPerformanceTest app,TableTransactional table/*Table table*/,String id,int records){
         this.id=id;
         this.records=records;
         this.app=app;
@@ -53,18 +54,18 @@ public class ParallelThread implements Runnable{
     
     public void run(){
         try{
-            long time=app.benchmarkLargeWrite(table,records,id);
+          long time=app.benchmarkLargeWrite(table,records,id);
             synchronized(app){
                 app.writetime+=time;
-            }
-            time=app.benchmarkLargeRead(table,records,id);
+           }
+             time=app.benchmarkLargeRead(table,records,id);
             synchronized(app){
                 app.readtime+=time;
             }
             time=app.benchmarkLargeRandomRead(table,records,id);
             synchronized(app){
                 app.randomtime+=time;
-            }
+          }
         }catch(Exception e){
             e.printStackTrace();
         }