// Path: src/main/java/org/calrissian/flowmix/core/support/deque/LimitingDeque.java
// public class LimitingDeque<E> extends LinkedBlockingDeque<E> {
// 
//     private long maxSize;
// 
//     protected long getMaxSize() {
//       return maxSize;
//     }
// 
//   public LimitingDeque(long maxSize) {
//         this.maxSize = maxSize;
//     }
// 
//     @Override
//     public boolean offerFirst(E e) {
//         if(size() == maxSize)
//             removeLast();
// 
//         return super.offerFirst(e);
//     }
// 
//     @Override
//     public boolean offerLast(E e) {
//         if(size() == maxSize)
//             removeFirst();
// 
//         return super.offerLast(e);
//     }
// }


import org.calrissian.flowmix.core.support.deque.LimitingDeque;
import org.calrissian.mango.domain.event.Event;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import static java.lang.System.currentTimeMillis;
import static org.apache.commons.lang.StringUtils.join;
/*
 * Copyright (C) 2014 The Calrissian Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.calrissian.flowmix.core.support.window;




public class Window {

  protected String groupedIndex;        // a unique key given to the groupBy field/value combinations in the window buffer

  protected Deque<WindowItem> events;     // using standard array list for proof of concept.
                                             // Circular buffer needs to be used after concept is proven
  protected int triggerTicks = 0;

  /**
   * A progressive window buffer which automatically evicts by count
   */
  public Window(String groupedIndex, long size) {
    this(groupedIndex);
// Path: src/main/java/org/calrissian/flowmix/core/support/deque/LimitingDeque.java
// public class LimitingDeque<E> extends LinkedBlockingDeque<E> {
// 
//     private long maxSize;
// 
//     protected long getMaxSize() {
//       return maxSize;
//     }
// 
//   public LimitingDeque(long maxSize) {
//         this.maxSize = maxSize;
//     }
// 
//     @Override
//     public boolean offerFirst(E e) {
//         if(size() == maxSize)
//             removeLast();
// 
//         return super.offerFirst(e);
//     }
// 
//     @Override
//     public boolean offerLast(E e) {
//         if(size() == maxSize)
//             removeFirst();
// 
//         return super.offerLast(e);
//     }
// }


// Path: src/main/java/org/calrissian/flowmix/core/support/window/Window.java
import org.calrissian.flowmix.core.support.deque.LimitingDeque;
import org.calrissian.mango.domain.event.Event;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import static java.lang.System.currentTimeMillis;
import static org.apache.commons.lang.StringUtils.join;

/*
 * Copyright (C) 2014 The Calrissian Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.calrissian.flowmix.core.support.window;




public class Window {

  protected String groupedIndex;        // a unique key given to the groupBy field/value combinations in the window buffer

  protected Deque<WindowItem> events;     // using standard array list for proof of concept.
                                             // Circular buffer needs to be used after concept is proven
  protected int triggerTicks = 0;

  /**
   * A progressive window buffer which automatically evicts by count
   */
  public Window(String groupedIndex, long size) {
    this(groupedIndex);
    events = new LimitingDeque<WindowItem>(size);