(Tuple input)
| 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. |
no test coverage detected