Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowedOperator initial value #246

Open
AlexP11223 opened this issue Feb 6, 2018 · 0 comments
Open

WindowedOperator initial value #246

AlexP11223 opened this issue Feb 6, 2018 · 0 comments

Comments

@AlexP11223
Copy link

AlexP11223 commented Feb 6, 2018

WindowedOperator initializes maxWindowTime to 0, so if we use real timestamps or something else starting not from 0 in time column, then we will get a lot of empty panes until it reaches these values.

Is it intended to work like that?

I think it can be easily fixed/improved by adding setter for this value allowing the client to initialize it to any needed value,

For example like this

--- a/lib/src/main/java/edu/stanford/futuredata/macrobase/operator/WindowedOperator.java
+++ b/lib/src/main/java/edu/stanford/futuredata/macrobase/operator/WindowedOperator.java
@@ -19,7 +19,7 @@ public class WindowedOperator<O>
     private double windowLength = 60.0;
     private double slideLength = 10.0;

-    private double maxWindowTime;
+    private double maxWindowTime = Double.MAX_VALUE;
     private IncrementalOperator<O> op;

     private ArrayList<DataFrame> batchBuffer;
@@ -28,7 +28,9 @@ public class WindowedOperator<O>
         this.op = op;
     }
     public WindowedOperator<O> initialize() {
-        this.maxWindowTime = 0.0;
+        if (maxWindowTime == Double.MAX_VALUE) {
+            this.maxWindowTime = 0.0;
+        }
         this.batchBuffer = new ArrayList<>();

         int numPanes = (int)Math.ceil(windowLength / slideLength);
@@ -134,6 +136,10 @@ public class WindowedOperator<O>
         return maxWindowTime;
     }

+    public void setMaxWindowTime(double maxWindowTime) {
+        this.maxWindowTime = maxWindowTime;
+    }
+
     public int getBufferSize() {
         return batchBuffer.size();
     }

By the way, what's the reason for adding initialize method instead of doing it in the constructor?

UPD: ah, I guess it's because windowSize has to be set via setter from the interface. But maxWindowTime probably can be initialized during construction.

--- a/lib/src/main/java/edu/stanford/futuredata/macrobase/operator/WindowedOperator.java
+++ b/lib/src/main/java/edu/stanford/futuredata/macrobase/operator/WindowedOperator.java
@@ -19,7 +19,7 @@ public class WindowedOperator<O>
     private double windowLength = 60.0;
     private double slideLength = 10.0;

-    private double maxWindowTime;
+    private double maxWindowTime = 0.0;
     private IncrementalOperator<O> op;

     private ArrayList<DataFrame> batchBuffer;
@@ -28,7 +28,6 @@ public class WindowedOperator<O>
         this.op = op;
     }
     public WindowedOperator<O> initialize() {
-        this.maxWindowTime = 0.0;
         this.batchBuffer = new ArrayList<>();

         int numPanes = (int)Math.ceil(windowLength / slideLength);
@@ -134,6 +133,10 @@ public class WindowedOperator<O>
         return maxWindowTime;
     }

+    public void setMaxWindowTime(double maxWindowTime) {
+        this.maxWindowTime = maxWindowTime;
+    }
+
     public int getBufferSize() {
         return batchBuffer.size();
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant