Trying to implement caching

This commit is contained in:
Alexander Nozik 2016-07-17 22:28:43 +03:00
parent 875123c81f
commit bc05ae5006
12 changed files with 87 additions and 23 deletions

View File

@ -47,6 +47,14 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *

View File

@ -6,8 +6,8 @@
package inr.numass.actions; package inr.numass.actions;
import hep.dataforge.actions.GenericAction; import hep.dataforge.actions.GenericAction;
import hep.dataforge.context.DFProcess; import hep.dataforge.work.Work;
import hep.dataforge.context.ProcessManager.Callback; import hep.dataforge.work.WorkManager.Callback;
import hep.dataforge.data.Data; import hep.dataforge.data.Data;
import hep.dataforge.data.DataFilter; import hep.dataforge.data.DataFilter;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
@ -42,7 +42,7 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false); boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false);
boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false); boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false);
DFProcess<DataSet<NumassData>> process = getContext().processManager() Work<DataSet<NumassData>> process = getContext().workManager()
.<DataSet<NumassData>>post(getName(), (Callback callback) -> { .<DataSet<NumassData>>post(getName(), (Callback callback) -> {
//FIXME remove in later revisions //FIXME remove in later revisions
SetDirectionUtility.load(getContext()); SetDirectionUtility.load(getContext());

View File

@ -35,6 +35,14 @@ import static java.lang.Double.isNaN;
import static java.lang.Math.abs; import static java.lang.Math.abs;
import static java.lang.Double.isNaN; import static java.lang.Double.isNaN;
import static java.lang.Math.abs; import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
/** /**
* *

View File

@ -7,7 +7,7 @@ package inr.numass.tasks;
import hep.dataforge.actions.Action; import hep.dataforge.actions.Action;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.ProcessManager; import hep.dataforge.work.WorkManager;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataTree; import hep.dataforge.data.DataTree;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
@ -44,7 +44,7 @@ public class PrepareTask extends GenericTask {
*/ */
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected TaskState transform(ProcessManager.Callback callback, Context context, TaskState state, Meta config) { protected TaskState transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
//acquiring initial data. Data node could not be empty //acquiring initial data. Data node could not be empty
Meta dataMeta = Template.compileTemplate(config.getNode("data"), config); Meta dataMeta = Template.compileTemplate(config.getNode("data"), config);
DataNode<NumassData> data = runAction(new ReadNumassStorageAction(), callback, context, DataNode.empty(), dataMeta); DataNode<NumassData> data = runAction(new ReadNumassStorageAction(), callback, context, DataNode.empty(), dataMeta);
@ -70,8 +70,8 @@ public class PrepareTask extends GenericTask {
return state; return state;
} }
private <T, R> DataNode<R> runAction(Action<T, R> action, ProcessManager.Callback callback, Context context, DataNode<T> data, Meta meta) { private <T, R> DataNode<R> runAction(Action<T, R> action, WorkManager.Callback callback, Context context, DataNode<T> data, Meta meta) {
return action.withContext(context).withParentProcess(callback.processName()).run(data, meta); return action.withContext(context).withParentProcess(callback.workName()).run(data, meta);
} }
@Override @Override

View File

@ -41,6 +41,22 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *

View File

@ -152,7 +152,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
this.context = this.contextFactory.build(parentContext, config); this.context = this.contextFactory.build(parentContext, config);
// attachig visual process manager // attachig visual process manager
processWindow.setManager(context.processManager()); processWindow.setManager(context.workManager());
// setting io manager // setting io manager
context.setIO(new WorkbenchIOManager(new NumassIO(), this)); context.setIO(new WorkbenchIOManager(new NumassIO(), this));

View File

@ -37,7 +37,7 @@ public class Workbench extends Application {
primaryStage.show(); primaryStage.show();
scene.getWindow().setOnCloseRequest((WindowEvent event) -> { scene.getWindow().setOnCloseRequest((WindowEvent event) -> {
controller.getContext().processManager().getRootProcess().cancel(true); controller.getContext().workManager().getRoot().cancel(true);
}); });
} }

View File

@ -56,6 +56,38 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *

View File

@ -17,7 +17,7 @@ package inr.numass.viewer;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.context.ProcessManager; import hep.dataforge.work.WorkManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.ConsoleFragment; import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.process.ProcessManagerFragment; import hep.dataforge.fx.process.ProcessManagerFragment;
@ -139,7 +139,7 @@ public class MainViewerController implements Initializable {
} }
private void loadDirectory(String path) { private void loadDirectory(String path) {
getContext().processManager().post("viewer.loadDirectory", (ProcessManager.Callback callback) -> { getContext().workManager().post("viewer.loadDirectory", (WorkManager.Callback callback) -> {
callback.updateTitle("Load storage (" + path + ")"); callback.updateTitle("Load storage (" + path + ")");
callback.setProgress(-1); callback.setProgress(-1);
callback.updateMessage("Building numass storage tree..."); callback.updateMessage("Building numass storage tree...");
@ -161,8 +161,8 @@ public class MainViewerController implements Initializable {
public void setRootStorage(NumassStorage root) { public void setRootStorage(NumassStorage root) {
getContext().processManager().cleanup(); getContext().workManager().cleanup();
getContext().processManager().post("viewer.storage.load", (ProcessManager.Callback callback) -> { getContext().workManager().post("viewer.storage.load", (WorkManager.Callback callback) -> {
callback.updateTitle("Fill data to UI (" + root.getName() + ")"); callback.updateTitle("Fill data to UI (" + root.getName() + ")");
callback.setProgress(-1); callback.setProgress(-1);
Platform.runLater(() -> statusBar.setProgress(-1)); Platform.runLater(() -> statusBar.setProgress(-1));

View File

@ -21,7 +21,7 @@ package inr.numass.viewer;
* and open the template in the editor. * and open the template in the editor.
*/ */
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.ProcessManager; import hep.dataforge.work.WorkManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import hep.dataforge.plots.PlotUtils; import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.DynamicPlottable; import hep.dataforge.plots.data.DynamicPlottable;
@ -85,7 +85,7 @@ public class MspViewController {
public void fillMspData(Storage rootStorage) { public void fillMspData(Storage rootStorage) {
if (rootStorage != null) { if (rootStorage != null) {
context.processManager().post("viewer.msp.fill", (ProcessManager.Callback callback) -> { context.workManager().post("viewer.msp.fill", (WorkManager.Callback callback) -> {
try { try {
// callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")"); // callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.viewer; package inr.numass.viewer;
import hep.dataforge.context.ProcessManager; import hep.dataforge.work.WorkManager;
import hep.dataforge.exceptions.StorageException; import hep.dataforge.exceptions.StorageException;
import inr.numass.storage.NumassData; import inr.numass.storage.NumassData;
import inr.numass.storage.NumassStorage; import inr.numass.storage.NumassStorage;
@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
*/ */
public class NumassLoaderTreeBuilder { public class NumassLoaderTreeBuilder {
public void build(ProcessManager.Callback callback, public void build(WorkManager.Callback callback,
TreeTableView<TreeItemValue> numassLoaderDataTree, TreeTableView<TreeItemValue> numassLoaderDataTree,
NumassStorage rootStorage, NumassStorage rootStorage,
Consumer<NumassData> numassViewBuilder) throws StorageException { Consumer<NumassData> numassViewBuilder) throws StorageException {
@ -81,7 +81,7 @@ public class NumassLoaderTreeBuilder {
} }
private TreeItem<TreeItemValue> buildNode(NumassStorage storage, private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException { Consumer<NumassData> numassViewBuilder, WorkManager.Callback callback) throws StorageException {
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage)); TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback)); node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
return node; return node;
@ -92,7 +92,7 @@ public class NumassLoaderTreeBuilder {
} }
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage, private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
Consumer<NumassData> numassViewBuilder, ProcessManager.Callback callback) throws StorageException { Consumer<NumassData> numassViewBuilder, WorkManager.Callback callback) throws StorageException {
List<TreeItem<TreeItemValue>> list = new ArrayList<>(); List<TreeItem<TreeItemValue>> list = new ArrayList<>();
storage.shelves().values().stream().forEach(subStorage -> { storage.shelves().values().stream().forEach(subStorage -> {

View File

@ -21,7 +21,7 @@ package inr.numass.viewer;
* and open the template in the editor. * and open the template in the editor.
*/ */
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.ProcessManager; import hep.dataforge.work.WorkManager;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder; import hep.dataforge.meta.MetaBuilder;
@ -227,7 +227,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
public void loadData(NumassData data) { public void loadData(NumassData data) {
this.data = data; this.data = data;
if (data != null) { if (data != null) {
context.processManager().<List<NMPoint>>post("viewer.numass.load", (ProcessManager.Callback callback) -> { context.workManager().<List<NMPoint>>post("viewer.numass.load", (WorkManager.Callback callback) -> {
callback.updateTitle("Load numass data (" + data.getName() + ")"); callback.updateTitle("Load numass data (" + data.getName() + ")");
points = data.getNMPoints(); points = data.getNMPoints();
@ -252,7 +252,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
} }
private void setupHVPane(Supplier<Table> hvData) { private void setupHVPane(Supplier<Table> hvData) {
context.processManager().post("viewer.numass.hv", (ProcessManager.Callback callback) -> { context.workManager().post("viewer.numass.hv", (WorkManager.Callback callback) -> {
Table t = hvData.get(); Table t = hvData.get();
Platform.runLater(() -> { Platform.runLater(() -> {
if (t != null) { if (t != null) {
@ -356,7 +356,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
detectorPlot.removePlot(); detectorPlot.removePlot();
} }
context.processManager().post("viewer.numass.load.detector", (ProcessManager.Callback callback) -> { context.workManager().post("viewer.numass.load.detector", (WorkManager.Callback callback) -> {
Meta plottableConfig = new MetaBuilder("plot") Meta plottableConfig = new MetaBuilder("plot")
.setValue("connectionType", "step") .setValue("connectionType", "step")
.setValue("thickness", 2) .setValue("thickness", 2)