@Override public String[] getLocations() throws IOException { String[] locs = new String[locations.length]; for (int i = 0; i < locations.length; ++i) { locs[i] = locations[i].getLocation(); } return locs; }
private static String[] extractHosts(FileSplit split, boolean isInMemory) throws IOException { SplitLocationInfo[] locInfo = split.getLocationInfo(); if (locInfo == null) return new String[0]; List<String> hosts = null; // TODO: most of the time, there's no in-memory. Use an array? for (int i = 0; i < locInfo.length; i++) { if (locInfo[i].isInMemory() != isInMemory) continue; if (hosts == null) { hosts = new ArrayList<>(); } hosts.add(locInfo[i].getLocation()); } if (hosts == null) return new String[0]; return hosts.toArray(new String[hosts.size()]); }
@Override public void write(DataOutput out) throws IOException { out.writeInt(splitNum); out.writeInt(planBytes.length); out.write(planBytes); out.writeInt(fragmentBytes.length); out.write(fragmentBytes); if (fragmentBytesSignature != null) { out.writeInt(fragmentBytesSignature.length); out.write(fragmentBytesSignature); } else { out.writeInt(0); } out.writeInt(locations.length); for (int i = 0; i < locations.length; ++i) { out.writeUTF(locations[i].getLocation()); } schema.write(out); out.writeUTF(llapUser); if (tokenBytes != null) { out.writeInt(tokenBytes.length); out.write(tokenBytes); } else { out.writeInt(0); } }
@Override public String[] getLocations() throws IOException { String[] locs = new String[locations.length]; for (int i = 0; i < locations.length; ++i) { locs[i] = locations[i].getLocation(); } return locs; }
private static String[] extractHosts(FileSplit split, boolean isInMemory) throws IOException { SplitLocationInfo[] locInfo = split.getLocationInfo(); if (locInfo == null) return new String[0]; List<String> hosts = null; // TODO: most of the time, there's no in-memory. Use an array? for (int i = 0; i < locInfo.length; i++) { if (locInfo[i].isInMemory() != isInMemory) continue; if (hosts == null) { hosts = new ArrayList<>(); } hosts.add(locInfo[i].getLocation()); } if (hosts == null) return new String[0]; return hosts.toArray(new String[hosts.size()]); }
@Override public void write(DataOutput out) throws IOException { out.writeInt(splitNum); out.writeInt(planBytes.length); out.write(planBytes); out.writeInt(fragmentBytes.length); out.write(fragmentBytes); if (fragmentBytesSignature != null) { out.writeInt(fragmentBytesSignature.length); out.write(fragmentBytesSignature); } else { out.writeInt(0); } out.writeInt(locations.length); for (int i = 0; i < locations.length; ++i) { out.writeUTF(locations[i].getLocation()); } schema.write(out); out.writeUTF(llapUser); if (tokenBytes != null) { out.writeInt(tokenBytes.length); out.write(tokenBytes); } else { out.writeInt(0); } }
/** * Create a HashMap that has as key the hostname and values the splits that belong to this hostname; * * @return * @throws IOException */ public HashMap<String, ArrayList<Integer>> getLocationsOfSplits() throws IOException { HashMap<String, ArrayList<Integer>> splits_map = new HashMap<String, ArrayList<Integer>>(); ArrayList<Integer> temp; int i = 0; String hostname; for (InputSplit s : this.splits) { SplitLocationInfo info[] = s.getLocationInfo(); hostname = info[0].getLocation(); if (splits_map.containsKey(hostname)) { temp = splits_map.get(hostname); temp.add(i); } else { temp = new ArrayList<Integer>(); temp.add(i); splits_map.put(hostname, temp); } i++; } return splits_map; }