From 5e5ffee64e3bf5ab86a06602de8f68f76abcf707 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 12 Nov 2016 18:11:17 +0300 Subject: [PATCH] Resolved Groovy dependencies for numass-storage --- numass-storage/numass-client/build.gradle | 11 ------ numass-storage/numass-server/build.gradle | 9 ----- .../inr/numass/storage/NumassDataLoader.java | 37 ++++++++++++------- numass-storage/test/build.gradle | 29 +++++++++++++++ 4 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 numass-storage/test/build.gradle diff --git a/numass-storage/numass-client/build.gradle b/numass-storage/numass-client/build.gradle index b0307601..f727accd 100644 --- a/numass-storage/numass-client/build.gradle +++ b/numass-storage/numass-client/build.gradle @@ -6,17 +6,6 @@ if (!hasProperty('mainClass')) { mainClassName = mainClass -task runClient(type: JavaExec) { - description 'Start numass client locally' - - // Set main property to name of Groovy script class. - main = 'inr.numass.scripts.TestClient' - - // Set classpath for running the Groovy script. - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in -} - dependencies { compile project(':numass-storage') compile 'commons-cli:commons-cli:1.3.1' diff --git a/numass-storage/numass-server/build.gradle b/numass-storage/numass-server/build.gradle index 452ecda0..b6711a8d 100644 --- a/numass-storage/numass-server/build.gradle +++ b/numass-storage/numass-server/build.gradle @@ -1,15 +1,6 @@ description = 'dataforge-server' -task runServer(type: JavaExec) { - description 'Start numass server locally' - // Set main property to name of Groovy script class. - main = 'inr.numass.scripts.TestServer' - - // Set classpath for running the Groovy script. - classpath = sourceSets.main.runtimeClasspath - standardInput = System.in -} processResources { from project(':dataforge-storage:storage-servlet').file('/src/main/resources/ratpack') diff --git a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java b/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java index b2084225..512db645 100644 --- a/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java +++ b/numass-storage/src/main/java/inr/numass/storage/NumassDataLoader.java @@ -19,7 +19,6 @@ import hep.dataforge.context.GlobalContext; import hep.dataforge.data.binary.Binary; import hep.dataforge.exceptions.StorageException; import hep.dataforge.io.ColumnedDataReader; -import hep.dataforge.io.envelopes.DefaultEnvelopeReader; import hep.dataforge.io.envelopes.Envelope; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; @@ -36,7 +35,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.net.URL; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -180,14 +178,14 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader transformation) { + private NMPoint readPoint(Envelope envelope, Function transformation) { + return transformation.apply(readRawPoint(envelope)); + } + + /** + * Read raw point. Requires a low of memory. + * @param envelope + * @return + */ + private RawNMPoint readRawPoint(Envelope envelope) { List events = new ArrayList<>(); ByteBuffer buffer; try { @@ -235,12 +242,10 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader MAX_EVENTS_PER_POINT) { pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime(); } - RawNMPoint raw = new RawNMPoint(u, u, + return new RawNMPoint(u, u, events, pointTime, readTime(envelope.meta())); - - return transformation.apply(raw); } /** @@ -300,6 +305,10 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader readPoint(env)).collect(Collectors.toList()); } + public List getRawPoints() { + return this.getPoints().stream().parallel().map(env -> readRawPoint(env)).collect(Collectors.toList()); + } + private List getPoints() { return getItems().entrySet().stream() .filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null) diff --git a/numass-storage/test/build.gradle b/numass-storage/test/build.gradle new file mode 100644 index 00000000..14034b73 --- /dev/null +++ b/numass-storage/test/build.gradle @@ -0,0 +1,29 @@ +description = "Test module for numass client and server" + +task runServer(type: JavaExec) { + description 'Start numass server locally' + + // Set main property to name of Groovy script class. + main = 'inr.numass.scripts.TestServer' + + // Set classpath for running the Groovy script. + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in +} + +task runClient(type: JavaExec) { + description 'Start numass client locally' + + // Set main property to name of Groovy script class. + main = 'inr.numass.scripts.TestClient' + + // Set classpath for running the Groovy script. + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in +} + +dependencies { + compile project(':numass-storage:numass-client') + compile project(':numass-storage:numass-server') + compile project(':dataforge-grind') +} \ No newline at end of file