Skip to content

Commit

Permalink
Merge pull request #12 from gavalian/evio-6.0
Browse files Browse the repository at this point in the history
Introduced a new constructor in Writer to specify the type for file h…
  • Loading branch information
carltimmer authored Oct 26, 2017
2 parents 13222aa + 7c6f068 commit 1d7172b
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 56 deletions.
19 changes: 14 additions & 5 deletions java/org/jlab/coda/hipo/Evio6Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
*/
package org.jlab.coda.hipo;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jlab.coda.jevio.EvioCompactReader;
import org.jlab.coda.jevio.EvioEvent;
import org.jlab.coda.jevio.EvioException;
import org.jlab.coda.jevio.EvioReader;

/**
*
Expand All @@ -27,7 +30,7 @@ public static void convert(String inFile, String outFile){
int nevents = reader.getEventCount();
ByteOrder order = reader.getByteOrder();

order = ByteOrder.BIG_ENDIAN;
//order = ByteOrder.BIG_ENDIAN;

System.out.println(" THE FILE ORDER = " + order);
Writer writer = new Writer(outFile,order,10000,8*1024*1024);
Expand All @@ -53,19 +56,25 @@ public static void convert(String inFile, String outFile){
}

public static void convert(String inFile, String outFile, int nthreads, int compressionType){
EvioCompactReader reader;
//EvioCompactReader reader;
EvioReader reader;
try {

reader = new EvioCompactReader(inFile);
//reader = new EvioCompactReader(inFile);
reader = new EvioReader(new File(inFile),false,false);
int nevents = reader.getEventCount();
ByteOrder order = reader.getByteOrder();
WriterMT writer = new WriterMT(order,10000,8*1024*1024,compressionType,
nthreads,nthreads*4);
nthreads,nthreads*2);
writer.open(outFile);
System.out.println("OPENED FILE: ENTRIES = " + nevents);
long start_writer = System.currentTimeMillis();
for(int i = 1; i < nevents; i++){
ByteBuffer buffer = reader.getEventBuffer(i,true);

//ByteBuffer buffer = reader.getEventBuffer(i,true);
EvioEvent event = reader.getEvent(i);
byte[] data = event.getRawBytes();
ByteBuffer buffer = ByteBuffer.wrap(data);
writer.addEvent(buffer.array());
if(i%5000==0){
System.out.println(" processed events # " + i);
Expand Down
26 changes: 25 additions & 1 deletion java/org/jlab/coda/hipo/Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,31 @@ public Writer(ByteOrder order, int maxEventCount, int maxBufferSize){
outputRecord = new RecordOutputStream(order, maxEventCount, maxBufferSize, 1);
fileHeader = new FileHeader(true);
}

/**
* Constructor with byte order.
* <b>No</b> file is opened.
* Any dictionary will be placed in the user header which will create a conflict if
* user tries to call {@link #open(String, byte[])} with another user header array.
*
* @param hType the type of the file. If set to HIPO type, then the header will be
* written with the first 4 bytes set to HIPO.
* @param order byte order of written file
* @param maxEventCount max number of events a record can hold.
* Value of O means use default (1M).
* @param maxBufferSize max number of uncompressed data bytes a record can hold.
* Value of < 8MB results in default of 8MB.
*/
public Writer(HeaderType hType,ByteOrder order, int maxEventCount, int maxBufferSize){
if (order != null) {
byteOrder = order;
}
outputRecord = new RecordOutputStream(order, maxEventCount, maxBufferSize, 1);
if(hType==HeaderType.HIPO_FILE){
fileHeader = new FileHeader(false);
} else {
fileHeader = new FileHeader(true);
}
}
/**
* Constructor with filename.
* The output file will be created with no user header.
Expand Down
106 changes: 56 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,69 +48,75 @@
<!-- build customization -->
<build>
<!-- copy jar into external directory -->
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>2.8</version>
</extension>
</extensions>
<plugins>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>org.jlab.coda.hipo.Evio6Converter</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>${env.CODA}/common/jar</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<configuration>
<archive>
<manifest>
<mainClass>org.jlab.coda.hipo.Evio6Converter</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>${env.CODA}/common/jar</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>


<sourceDirectory>./java/</sourceDirectory>
<defaultGoal>install</defaultGoal>
</build>

<!-- distribution for deployment -->
<distributionManagement>
<repository>
<id>jlab-coda-repo</id>
<id>ssh-clasweb</id>
<url>scpexe://[email protected]/group/clas/www/clasweb/html/jhep/maven</url>
<!-- FIXME: Set this to a real repo location. -->
<url>file:/group/da/distribution/maven</url>
</repository>
</distributionManagement>

Expand Down

0 comments on commit 1d7172b

Please sign in to comment.