2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.impl
.eval
.window
;
7 import java
.io
.IOException
;
10 import com
.yahoo
.pig
.data
.*;
12 public class TupleWindowSpec
extends WindowSpec
{
16 public TupleWindowSpec(windowType type
, int numTuples
){
18 this.numTuples
= numTuples
;
19 window
= new LinkedList
<Tuple
>();
23 public DataCollector
collector(final DataCollector output
) {
24 return new DataCollector() {
26 public void add(Tuple t
) throws IOException
{
29 if (t
instanceof TimestampedTuple
){
30 if (((TimestampedTuple
) t
).isHeartbeat
) return;
34 while (window
.size() > numTuples
) {
41 // emit entire window content to output collector
42 for (Iterator
<Tuple
> it
= window
.iterator(); it
.hasNext(); ) {
43 output
.add(it
.next());