Code Examples
A repository of 155 code examples for BeepBeep
UnpackExample.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2018 Sylvain HallĂ©
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package util;
19 
20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.Pullable;
22 import ca.uqac.lif.cep.UtilityMethods;
23 import ca.uqac.lif.cep.tmf.QueueSource;
24 import ca.uqac.lif.cep.util.Lists;
25 
26 /**
27  * Use the {@link ca.uqac.lif.cep.util.Lists.Unpack Unpack} processor to
28  * feed events from a stream of lists.
29  * Graphically, this chain of processors can be represented as:
30  * <p>
31  * <img src="./doc-files/util/UnpackExample.png" alt="Processor graph">
32 * <p>
33  * The output of this program is:
34  * <pre>
35  * 1
36  * 3
37  * 5
38  * 4
39  * 2
40  * 4
41  * &hellip;
42  * </pre>
43  *
44  * @author Sylvain HallĂ©
45  * @difficulty Easy
46  */
47 public class UnpackExample
48 {
49 
50  public static void main(String[] args)
51  {
52  ///
53  QueueSource src1 = new QueueSource();
54  src1.addEvent(UtilityMethods.createList(1f, 3f, 5f));
55  src1.addEvent(UtilityMethods.createList(4f, 2f));
56  src1.addEvent(UtilityMethods.createList(4f, 4f, 8f));
57  src1.addEvent(UtilityMethods.createList(6f, 4f));
58  Lists.Unpack unpack = new Lists.Unpack();
59  Connector.connect(src1, 0, unpack, 0);
60  Pullable p = unpack.getPullableOutput();
61  for (int i = 0; i < 6; i++)
62  {
63  System.out.println(p.pull());
64  }
65  ///
66  }
67 }
Use the Unpack processor to feed events from a stream of lists.