test_class.file: contrib/src/test/java/macrobase/analysis/transform/aggregate/IncrementalWindowSumTest.java
test_class.identifier: IncrementalWindowSumTest
test_case.body: @Test
      public void testWindowUpdate() throws Exception {
          List<Datum> data = new ArrayList<>();
          for (int i = 0; i < 20; i++) {
              Datum d = TestUtils.createTimeDatum(i, i);
              data.add(d);
          }
  
          MacroBaseConf conf = new MacroBaseConf().set(MacroBaseConf.TIME_COLUMN, 0);
          conf.set(AggregateConf.AGGREGATE_TYPE, AggregateConf.AggregateType.SUM);
          IncrementalWindowSum windowSum = new IncrementalWindowSum(conf);
          // First window
          Datum sum = windowSum.updateWindow(data.subList(0, 10), new ArrayList<>());
          assert(sum.metrics().getEntry(1) == 45);
          // Update window
          sum = windowSum.updateWindow(data.subList(10, 11), data.subList(0, 1));
          assert(sum.metrics().getEntry(1) == 55);
          sum = windowSum.updateWindow(data.subList(11, 20), data.subList(1, 5));
          assert(sum.metrics().getEntry(1) == 180);
          sum = windowSum.updateWindow(new ArrayList<>(), data.subList(5, 10));
          assert(sum.metrics().getEntry(1) == 145);
      }
test_case.class_method_signature: IncrementalWindowSumTest.testWindowUpdate()
test_case.full_signature: @Test public void testWindowUpdate()
test_case.identifier: testWindowUpdate
test_case.invocations: createTimeDatum add set set updateWindow subList getEntry metrics updateWindow subList subList getEntry metrics updateWindow subList subList getEntry metrics updateWindow subList getEntry metrics
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWindowUpdate()
focal_class.file: contrib/src/main/java/macrobase/analysis/transform/aggregate/IncrementalWindowSum.java
focal_class.identifier: IncrementalWindowSum
focal_class.class_method_signature: IncrementalWindowSum.IncrementalWindowSum(MacroBaseConf conf)
focal_class.full_signature: public  IncrementalWindowSum(MacroBaseConf conf)
focal_class.identifier: IncrementalWindowSum
focal_class.modifiers: public
focal_class.parameters: (MacroBaseConf conf)
focal_class.signature:  IncrementalWindowSum(MacroBaseConf conf)
focal_class.class_method_signature: IncrementalWindowSum.updateWindow(List<Datum> new_data, List<Datum> old_data)
focal_class.full_signature: public Datum updateWindow(List<Datum> new_data, List<Datum> old_data)
focal_class.identifier: updateWindow
focal_class.modifiers: public
focal_class.parameters: (List<Datum> new_data, List<Datum> old_data)
focal_class.return: Datum
focal_class.signature: Datum updateWindow(List<Datum> new_data, List<Datum> old_data)
focal_class.superclass: extends IncrementalWindowAggregate
focal_method.body: public Datum updateWindow(List<Datum> new_data, List<Datum> old_data) {
          if (new_data.isEmpty() && old_data.isEmpty())
              return currWindow;
  
          RealVector results;
          if (currWindow != null) {
              results = new ArrayRealVector(currWindow.metrics());
          } else {
              dim = new_data.get(0).metrics().getDimension();
              results = new ArrayRealVector(dim);
          }
         // Add new data
          for (Datum d : new_data) {
              RealVector metrics = d.metrics();
              for (int i = 0; i < dim; i ++) {
                  if (timeColumn != null && i == timeColumn)
                      continue;
                  results.setEntry(i, results.getEntry(i) + metrics.getEntry(i));
              }
          }
          // Remove old data
          for (Datum d : old_data) {
              RealVector metrics = d.metrics();
              for (int i = 0; i < dim; i ++) {
                  if (timeColumn != null && i == timeColumn)
                      continue;
                  results.setEntry(i, results.getEntry(i) - metrics.getEntry(i));
              }
          }
          currWindow = new Datum(new ArrayList<>(), results);
          return currWindow;
      }
focal_method.class_method_signature: IncrementalWindowSum.updateWindow(List<Datum> new_data, List<Datum> old_data)
focal_method.full_signature: public Datum updateWindow(List<Datum> new_data, List<Datum> old_data)
focal_method.identifier: updateWindow
focal_method.invocations: isEmpty isEmpty metrics getDimension metrics get metrics setEntry getEntry getEntry metrics setEntry getEntry getEntry
focal_method.modifiers: public
focal_method.parameters: (List<Datum> new_data, List<Datum> old_data)
focal_method.return: Datum
focal_method.signature: Datum updateWindow(List<Datum> new_data, List<Datum> old_data)