[no commit message]
This commit is contained in:
parent
3cbc3e9aee
commit
cd8562abc0
@ -30,7 +30,6 @@ import hep.dataforge.tables.ListTable;
|
|||||||
import hep.dataforge.tables.MapPoint;
|
import hep.dataforge.tables.MapPoint;
|
||||||
import hep.dataforge.tables.PointSource;
|
import hep.dataforge.tables.PointSource;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.tables.TableFormat;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -100,8 +100,8 @@ public class PrepareDataAction extends OneToOneAction<NumassData, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String head;
|
String head;
|
||||||
if (dataFile.getInfo() != null) {
|
if (dataFile.meta() != null) {
|
||||||
head = dataFile.getInfo().toString();
|
head = dataFile.meta().toString();
|
||||||
} else {
|
} else {
|
||||||
head = dataFile.getName();
|
head = dataFile.getName();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.storage.api.Loader;
|
import hep.dataforge.storage.api.Loader;
|
||||||
import hep.dataforge.storage.commons.StorageUtils;
|
import hep.dataforge.storage.commons.StorageUtils;
|
||||||
import inr.numass.storage.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
|
import inr.numass.storage.NumassDataLoader;
|
||||||
import inr.numass.storage.NumassStorage;
|
import inr.numass.storage.NumassStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,17 +37,36 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
|
|||||||
try {
|
try {
|
||||||
NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false);
|
NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false);
|
||||||
DataFilter filter = new DataFilter().configure(actionMeta);
|
DataFilter filter = new DataFilter().configure(actionMeta);
|
||||||
|
|
||||||
DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
|
DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
|
||||||
|
|
||||||
|
boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false);
|
||||||
|
boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false);
|
||||||
|
|
||||||
StorageUtils.loaderStream(storage).forEach(pair -> {
|
StorageUtils.loaderStream(storage).forEach(pair -> {
|
||||||
Loader loader = pair.getValue();
|
Loader loader = pair.getValue();
|
||||||
if (loader instanceof NumassData) {
|
if (loader instanceof NumassData) {
|
||||||
Data<NumassData> datum = new StaticData<>((NumassData) loader);
|
NumassDataLoader nd = (NumassDataLoader) loader;
|
||||||
if (filter.acceptData(pair.getKey(), datum)) {
|
boolean reversed = nd.isReversed();
|
||||||
builder.putData(pair.getKey(), datum);
|
if ((reverseOnly && reversed) || (forwardOnly && !reversed) || (!forwardOnly && !reverseOnly)) {
|
||||||
|
Data<NumassData> datum = new StaticData<>(nd);
|
||||||
|
if (filter.acceptData(pair.getKey(), datum)) {
|
||||||
|
builder.putData(pair.getKey(), datum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
|
||||||
|
//
|
||||||
|
// StorageUtils.loaderStream(storage).forEach(pair -> {
|
||||||
|
// Loader loader = pair.getValue();
|
||||||
|
// if (loader instanceof NumassData) {
|
||||||
|
// Data<NumassData> datum = new StaticData<>((NumassData) loader);
|
||||||
|
// if (filter.acceptData(pair.getKey(), datum)) {
|
||||||
|
// builder.putData(pair.getKey(), datum);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
storage.legacyFiles().forEach(nd -> {
|
storage.legacyFiles().forEach(nd -> {
|
||||||
Data<NumassData> datum = new StaticData<>(nd);
|
Data<NumassData> datum = new StaticData<>(nd);
|
||||||
@ -60,5 +80,9 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
|
|||||||
throw new RuntimeException("Failed to load storage", ex);
|
throw new RuntimeException("Failed to load storage", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class NMFile extends NamedMetaHolder implements NumassData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Meta getInfo() {
|
public Meta meta() {
|
||||||
return new MetaBuilder("info").setValue("info", head);
|
return new MetaBuilder("info").setValue("info", head);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.storage;
|
package inr.numass.storage;
|
||||||
|
|
||||||
|
import hep.dataforge.meta.Annotated;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.names.Named;
|
import hep.dataforge.names.Named;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
@ -16,11 +17,12 @@ import java.util.function.Supplier;
|
|||||||
*
|
*
|
||||||
* @author Alexander Nozik <altavir@gmail.com>
|
* @author Alexander Nozik <altavir@gmail.com>
|
||||||
*/
|
*/
|
||||||
public interface NumassData extends Named {
|
public interface NumassData extends Named, Annotated {
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
Meta getInfo();
|
@Override
|
||||||
|
Meta meta();
|
||||||
|
|
||||||
List<NMPoint> getNMPoints();
|
List<NMPoint> getNMPoints();
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.storage.api.ObjectLoader;
|
import hep.dataforge.storage.api.ObjectLoader;
|
||||||
import hep.dataforge.storage.api.Storage;
|
import hep.dataforge.storage.api.Storage;
|
||||||
|
import hep.dataforge.storage.filestorage.FileEnvelope;
|
||||||
import hep.dataforge.storage.loaders.AbstractLoader;
|
import hep.dataforge.storage.loaders.AbstractLoader;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
@ -35,6 +36,7 @@ import java.io.InputStream;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -144,8 +146,8 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
|| fileName.equals(HV_FRAGMENT_NAME)
|
|| fileName.equals(HV_FRAGMENT_NAME)
|
||||||
|| fileName.startsWith(POINT_FRAGMENT_NAME)) {
|
|| fileName.startsWith(POINT_FRAGMENT_NAME)) {
|
||||||
try {
|
try {
|
||||||
return readStream(file.getContent().getInputStream());
|
return new FileEnvelope(file.getPublicURIString(), true);
|
||||||
} catch (FileSystemException ex) {
|
} catch (IOException | ParseException ex) {
|
||||||
LoggerFactory.getLogger(NumassDataLoader.class).error("Can't read file envelope", ex);
|
LoggerFactory.getLogger(NumassDataLoader.class).error("Can't read file envelope", ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -196,8 +198,8 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check if the point is composite
|
//Check if the point is composite
|
||||||
boolean segmented = envelope.meta().hasValue("events") && envelope.meta().getValue("events").isList();
|
boolean segmented = envelope.meta().getBoolean("split", false);
|
||||||
|
|
||||||
if (!segmented && events.size() > MAX_EVENTS_PER_POINT) {
|
if (!segmented && events.size() > MAX_EVENTS_PER_POINT) {
|
||||||
pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime();
|
pointTime = events.get(events.size() - 1).getTime() - events.get(0).getTime();
|
||||||
}
|
}
|
||||||
@ -234,10 +236,8 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Envelope readStream(InputStream stream) {
|
private static Envelope readStream(InputStream stream) {
|
||||||
// Tag override = new Tag((short) 1, (short) 1, -1, 256, -1);
|
|
||||||
try {
|
try {
|
||||||
return new DefaultEnvelopeReader().read(stream);
|
return new DefaultEnvelopeReader().read(stream);
|
||||||
// return new DefaultEnvelopeReader().customRead(stream, override.asProperties());
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
LoggerFactory.getLogger(NumassDataLoader.class).warn("Can't read a fragment from numass zip or directory", ex);
|
LoggerFactory.getLogger(NumassDataLoader.class).warn("Can't read a fragment from numass zip or directory", ex);
|
||||||
return null;
|
return null;
|
||||||
@ -268,11 +268,12 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Meta getInfo() {
|
public Meta meta() {
|
||||||
return getItems()
|
return getItems()
|
||||||
.get(META_FRAGMENT_NAME)
|
.get(META_FRAGMENT_NAME)
|
||||||
.get()
|
.get()
|
||||||
.meta();
|
.meta();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -299,9 +300,6 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Envelope getHvData() {
|
|
||||||
// return hvData;
|
|
||||||
// }
|
|
||||||
@Override
|
@Override
|
||||||
public List<NMPoint> getNMPoints() {
|
public List<NMPoint> getNMPoints() {
|
||||||
return this.getPoints().stream().parallel().map(env -> readPoint(env)).collect(Collectors.toList());
|
return this.getPoints().stream().parallel().map(env -> readPoint(env)).collect(Collectors.toList());
|
||||||
@ -310,12 +308,22 @@ public class NumassDataLoader extends AbstractLoader implements ObjectLoader<Env
|
|||||||
private List<Envelope> getPoints() {
|
private List<Envelope> getPoints() {
|
||||||
return getItems().entrySet().stream()
|
return getItems().entrySet().stream()
|
||||||
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
|
.filter(entry -> entry.getKey().startsWith(POINT_FRAGMENT_NAME) && entry.getValue() != null)
|
||||||
.map(entry -> entry.getValue().get())//TODO check for nulls?
|
.map(entry -> entry.getValue().get())
|
||||||
.sorted((Envelope t, Envelope t1)
|
.sorted((Envelope t, Envelope t1)
|
||||||
-> t.meta().getInt("external_meta.point_index", -1).compareTo(t1.meta().getInt("external_meta.point_index", -1)))
|
-> t.meta().getInt("external_meta.point_index", -1).compareTo(t1.meta().getInt("external_meta.point_index", -1)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isReversed() {
|
||||||
|
//TODO replace by meta tag in later revisions
|
||||||
|
List<Envelope> points = getPoints();
|
||||||
|
if (getPoints().size() >= 2) {
|
||||||
|
return readTime(points.get(0).meta()).isAfter(readTime(points.get(1).meta()));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return getItems().isEmpty();
|
return getItems().isEmpty();
|
||||||
|
@ -192,7 +192,12 @@ public class NumassLoaderTreeBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return loader.getName();
|
// if (loader.meta().getBoolean("reverse", false)) {
|
||||||
|
// return loader.getName() + " \u2191";
|
||||||
|
// } else {
|
||||||
|
// return loader.getName();
|
||||||
|
// }
|
||||||
|
return loader.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -292,7 +292,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupInfo(NumassData loader) {
|
private void setupInfo(NumassData loader) {
|
||||||
Meta info = loader.getInfo();
|
Meta info = loader.meta();
|
||||||
infoTextBox.setText(new JSONMetaWriter().writeString(info, null).
|
infoTextBox.setText(new JSONMetaWriter().writeString(info, null).
|
||||||
replace("\\r", "\r\t").replace("\\n", "\n\t"));
|
replace("\\r", "\r\t").replace("\\n", "\n\t"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user