MCPcopy Create free account
hub / github.com/apache/pig / SingleTupleBag

Class SingleTupleBag

src/org/apache/pig/data/SingleTupleBag.java:38–212  ·  view source on GitHub ↗

A simple performant implementation of the DataBag interface which only holds a single tuple. This will be used from POPreCombinerLocalRearrange and wherever else a single Tuple non-serializable DataBag is required.

Source from the content-addressed store, hash-verified

36 * a single Tuple non-serializable DataBag is required.
37 */
38public class SingleTupleBag implements DataBag {
39
40 private static final long serialVersionUID = 1L;
41 Tuple item;
42
43 public SingleTupleBag(Tuple t) {
44 item = t;
45 }
46
47 /* (non-Javadoc)
48 * @see org.apache.pig.data.DataBag#add(org.apache.pig.data.Tuple)
49 * NOTE: It is the user's responsibility to ensure only a single
50 * Tuple is ever added into a SingleTupleBag
51 */
52 @Override
53 public void add(Tuple t) {
54 item = t;
55 }
56
57 /* (non-Javadoc)
58 * @see org.apache.pig.data.DataBag#addAll(org.apache.pig.data.DataBag)
59 */
60 @Override
61 public void addAll(DataBag b) {
62 throw new RuntimeException("Cannot create SingleTupleBag from another DataBag");
63 }
64
65 /* (non-Javadoc)
66 * @see org.apache.pig.data.DataBag#clear()
67 */
68 @Override
69 public void clear() {
70 throw new RuntimeException("Cannot clear SingleTupleBag");
71 }
72
73 /* (non-Javadoc)
74 * @see org.apache.pig.data.DataBag#isDistinct()
75 */
76 @Override
77 public boolean isDistinct() {
78 return false;
79 }
80
81 /* (non-Javadoc)
82 * @see org.apache.pig.data.DataBag#isSorted()
83 */
84 @Override
85 public boolean isSorted() {
86 return false;
87 }
88
89 /* (non-Javadoc)
90 * @see org.apache.pig.data.DataBag#iterator()
91 */
92 @Override
93 public Iterator<Tuple> iterator() {
94 return new TBIterator();
95 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected