Print

Print


Commit in lcio on random_access_io_branch
bin/runAnalysisJob.bat+1-11.2 -> 1.2.24.1
   /runSimJob.bat+1-11.2 -> 1.2.24.1
   /runSIODump.bat+1-11.1 -> 1.1.24.1
tools/freehep-sio-2.1-SNAPSHOT.jar[binary]1.1.2.2 -> 1.1.2.3
src/java/hep/lcio/implementation/sio/SIOLCRandomAccessReader.java+28-211.1.2.1 -> 1.1.2.2
                                    /IndexBlock.java+17-11.1.2.3 -> 1.1.2.4
+48-25
6 modified files
Now actually works! Still need to deal with reading chains of files

lcio/bin
runAnalysisJob.bat 1.2 -> 1.2.24.1
diff -u -r1.2 -r1.2.24.1
--- runAnalysisJob.bat	6 Sep 2003 01:04:44 -0000	1.2
+++ runAnalysisJob.bat	3 Nov 2009 22:26:01 -0000	1.2.24.1
@@ -1 +1 @@
-java -cp %LCIO%/lib/lcio.jar;%LCIO%/tools/sio.jar hep.lcio.example.AnalysisJob %*
\ No newline at end of file
+java %JAVA_OPTS% -cp "%LCIO%/lib/lcio.jar;%LCIO%/tools/freehep-sio-2.1-SNAPSHOT.jar;%LCIO%/tools/freehep-xdr-2.0.4-SNAPSHOT.jar" hep.lcio.example.AnalysisJob %*
\ No newline at end of file

lcio/bin
runSimJob.bat 1.2 -> 1.2.24.1
diff -u -r1.2 -r1.2.24.1
--- runSimJob.bat	6 Sep 2003 01:04:44 -0000	1.2
+++ runSimJob.bat	3 Nov 2009 22:26:01 -0000	1.2.24.1
@@ -1 +1 @@
-java -cp %LCIO%/lib/lcio.jar;%LCIO%/tools/sio.jar hep.lcio.example.SimJob %*
\ No newline at end of file
+java -cp "%LCIO%/lib/lcio.jar;%LCIO%/tools/freehep-sio-2.1-SNAPSHOT.jar;%LCIO%/tools/freehep-xdr-2.0.4-SNAPSHOT.jar" hep.lcio.example.SimJob %*
\ No newline at end of file

lcio/bin
runSIODump.bat 1.1 -> 1.1.24.1
diff -u -r1.1 -r1.1.24.1
--- runSIODump.bat	6 Sep 2003 01:04:44 -0000	1.1
+++ runSIODump.bat	3 Nov 2009 22:26:01 -0000	1.1.24.1
@@ -1,2 +1,2 @@
 @echo off
-java -cp %LCIO%/lib/lcio.jar;%LCIO%/tools/sio.jar;%LCIO%/tools/jdom.jar;%LCIO%/tools/saxpath.jar;%LCIO%/tools/jaxen-jdom.jar;%LCIO%/tools/jaxen-core.jar;%LCIO%/tools/jel.jar hep.lcio.util.SIODump %*
\ No newline at end of file
+java -cp "%LCIO%/lib/lcio.jar;%LCIO%/tools/freehep-sio-2.1-SNAPSHOT.jar;%LCIO%/tools/freehep-xdr-2.0.4-SNAPSHOT.jar;%LCIO%/tools/jdom.jar;%LCIO%/tools/saxpath.jar;%LCIO%/tools/jaxen-jdom.jar;%LCIO%/tools/jaxen-core.jar;%LCIO%/tools/jel.jar" hep.lcio.util.SIODump %*
\ No newline at end of file

lcio/src/java/hep/lcio/implementation/sio
SIOLCRandomAccessReader.java 1.1.2.1 -> 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SIOLCRandomAccessReader.java	31 Oct 2009 00:26:19 -0000	1.1.2.1
+++ SIOLCRandomAccessReader.java	3 Nov 2009 22:26:01 -0000	1.1.2.2
@@ -6,6 +6,7 @@
 import hep.lcio.event.LCEvent;
 import hep.lcio.event.LCIO;
 import hep.lcio.event.LCRunHeader;
+import java.io.EOFException;
 import java.io.IOException;
 import java.util.AbstractList;
 import java.util.ArrayList;
@@ -92,16 +93,6 @@
             fileRandomAccessBlock = new RandomAccessBlock(record);
         }
 
-//        private void addRandomAccessRecord(SIORecord record) throws IOException {
-//            RandomAccessBlock ra = new RandomAccessBlock(record);
-//            System.out.println("Found ra=" + ra);
-//            if (ra.getIndexLocation() == 0) {
-//                fileRandomAccessBlock = ra;
-//            } else {
-//                indexRandomAccessBlocks.add(ra);
-//            }
-//        }
-
         private long findNextRunHeader() throws IOException {
             List<RandomAccessBlock> iab = findIndexRandomAccessBlocks();
             int iabIndex = findIndexOfRandomAccessBlockContaining(reader.getNextRecordPosition());
@@ -118,17 +109,33 @@
         }
 
         private void skipNEvents(int n) throws IOException {
-//            int iabIndex = findIndexOfRandomAccessBlockContaining(lastRecordPosition);
-//            List<RandomAccessBlock> iab = findIndexRandomAccessBlocks();
-//            IndexBlock ib = findIndexBlock(iab.get(iabIndex));
-//            int recordIndex = ib.findIndexOfRecord(lastRecordPosition);
-//            for (int i = recordIndex; i<ib.getRecordCount(); i++) {
-//            }
-//
-//            for (RandomAccessBlock rab : iab.subList(iabIndex, iab.size())) {
-//                IndexBlock ib = rab.get(iabIndex);
-//
-//            }
+            if (n==0) return;
+            int iabIndex = findIndexOfRandomAccessBlockContaining(reader.getNextRecordPosition());
+            List<RandomAccessBlock> iab = findIndexRandomAccessBlocks();
+            IndexBlock ib = findIndexBlock(iab.get(iabIndex));
+            // Find how many events are left in current block.
+            int recordIndex = ib.findIndexOfRecordLocation(reader.getNextRecordPosition());
+            for (int i = recordIndex; i<ib.getRecordCount(); i++) {
+                if (ib.isEvent(i)) if (n-- == 0) {
+                    reader.seek(ib.getLocation(i));
+                    return;
+                }
+            }
+
+            for (RandomAccessBlock rab : iab.subList(iabIndex+1, iab.size())) {
+                ib = findIndexBlock(rab);
+                int nEvents = ib.getEventCount();
+                if (nEvents <= n) n -= nEvents;
+                else {
+                    for (int i=0; i<ib.getRecordCount(); i++) {
+                        if (ib.isEvent(i)) if (n-- == 0) {
+                            reader.seek(ib.getLocation(i));
+                            return;
+                        }
+                    }
+                }
+            }
+            throw new EOFException();
         }
 
 

lcio/src/java/hep/lcio/implementation/sio
IndexBlock.java 1.1.2.3 -> 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- IndexBlock.java	31 Oct 2009 00:26:19 -0000	1.1.2.3
+++ IndexBlock.java	3 Nov 2009 22:26:02 -0000	1.1.2.4
@@ -130,10 +130,14 @@
         long firstLocation = sio.readLong();
         int size = sio.readInt();
         index = new ArrayList<IndexEntry>(size);
+        nEvents = 0;
+        nRunHeaders = 0;
         maxEntries = size;
         for (int i = 0; i < size; i++) {
             int run = oneRun ? minRun : minRun + sio.readInt();
             int event = sio.readInt();
+            if (event >= 0) nEvents++;
+            else nRunHeaders++;
             long location = firstLocation + (longOffset ? sio.readLong() : sio.readInt());
             index.add(new IndexEntry(run, event, location));
         }
@@ -173,6 +177,10 @@
         }
     }
 
+    long getLocation(int position) {
+        return index.get(position).recordLocation;
+    }
+
     long findRecordHeader(long startPosition) {
         int startIndex = findIndexOfRecordLocation(startPosition);
         for (IndexEntry entry : index.subList(startIndex, index.size())) {
@@ -187,7 +195,7 @@
         return index.isEmpty() ? 0 : index.get(0).recordLocation;
     }
 
-    private int findIndexOfRecordLocation(long recordLocation) {
+    int findIndexOfRecordLocation(long recordLocation) {
         int position = Collections.binarySearch(new RecordLocationList(), recordLocation);
         if (position < 0) {
             position = Math.max(0, -position - 2);
@@ -195,6 +203,14 @@
         return position;
     }
 
+    int getRecordCount() {
+        return nEvents+nRunHeaders;
+    }
+
+    boolean isEvent(int i) {
+        return index.get(i).getEvent() >= 0;
+    }
+
     private class RecordLocationList extends AbstractList<Long> {
 
         public Long get(int i) {
CVSspam 0.2.8