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

Method init

src/org/apache/pig/builtin/Bloom.java:136–163  ·  view source on GitHub ↗
(Tuple input)

Source from the content-addressed store, hash-verified

134 }
135
136 private void init(Tuple input) throws IOException {
137 if (bloomFile == null) {
138 if (input.get(0) instanceof DataByteArray) {
139 filter = BuildBloomBase.bloomIn((DataByteArray) input.get(0));
140 } else {
141 throw new IllegalArgumentException("The first argument to the Bloom UDF should be"
142 + " the bloom filter if a bloom file is not specified in the constructor");
143 }
144 } else {
145 filter = new BloomFilter();
146 String dir = "./" + getFilenameFromPath(bloomFile);
147 String[] partFiles = new File(dir)
148 .list(new FilenameFilter() {
149 @Override
150 public boolean accept(File current, String name) {
151 return name.startsWith("part");
152 }
153 });
154
155 String dcFile = dir + "/" + partFiles[0];
156 DataInputStream dis = new DataInputStream(new FileInputStream(dcFile));
157 try {
158 filter.readFields(dis);
159 } finally {
160 dis.close();
161 }
162 }
163 }
164
165 /**
166 * For testing only, do not use directly.

Callers 1

execMethod · 0.95

Calls 6

bloomInMethod · 0.95
getFilenameFromPathMethod · 0.95
listMethod · 0.80
getMethod · 0.65
closeMethod · 0.65
readFieldsMethod · 0.45

Tested by

no test coverage detected