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

Class ReadOnceBag

src/org/apache/pig/data/ReadOnceBag.java:37–255  ·  view source on GitHub ↗

This bag does not store the tuples in memory, but has access to an iterator typically provided by Hadoop. Use this when you already have an iterator over tuples and do not want to copy over again to a new bag.

Source from the content-addressed store, hash-verified

35 * tuples and do not want to copy over again to a new bag.
36 */
37public class ReadOnceBag implements DataBag {
38
39 // The Packager that created this
40 protected Packager pkgr;
41
42 //The iterator of Tuples. Marked transient because we will never serialize this.
43 protected transient Iterator<NullableTuple> tupIter;
44
45 // The key being worked on
46 protected PigNullableWritable keyWritable;
47
48 /**
49 *
50 */
51 private static final long serialVersionUID = 2L;
52
53 public ReadOnceBag() {
54 }
55
56 /**
57 * This constructor creates a bag out of an existing iterator
58 * of tuples by taking ownership of the iterator and NOT
59 * copying the elements of the iterator.
60 * @param pkg POPackageLite
61 * @param tupIter Iterator<NullableTuple>
62 * @param key Object
63 */
64 public ReadOnceBag(Packager pkgr, Iterator<NullableTuple> tupIter,
65 PigNullableWritable keyWritable) {
66 this.pkgr = pkgr;
67 this.tupIter = tupIter;
68 this.keyWritable = keyWritable;
69 }
70
71 /* (non-Javadoc)
72 * @see org.apache.pig.impl.util.Spillable#getMemorySize()
73 */
74 @Override
75 public long getMemorySize() {
76 return 0;
77 }
78
79 /* (non-Javadoc)
80 * @see org.apache.pig.impl.util.Spillable#spill()
81
82 */
83 @Override
84 public long spill() {
85 throw new RuntimeException("ReadOnceBag does not support spill operation");
86 }
87
88 /* (non-Javadoc)
89 * @see org.apache.pig.data.DataBag#add(org.apache.pig.data.Tuple)
90 */
91 @Override
92 public void add(Tuple t) {
93 throw new RuntimeException("ReadOnceBag does not support add operation");
94 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected