2016-06-14 7 views
0
public void configure(JobConf job) { 
     inputFile = job.get("map.input.file"); 
      Path[] cacheFiles = new Path[2]; 
       try { 
        Path file0 = DistributedCache.getLocalCacheFiles(job)[0]; 
        Path file1 = DistributedCache.getLocalCacheFiles(job)[1]; 
       } catch (IOException ioe) { 
        System.err.println("Caught exception while getting cached files: " + StringUtils.stringifyException(ioe)); 
      } 
    } 

私はコードをconfigure関数に書いています。HDFSの分散キャッシュに保存されているファイルのパスからファイル名を取得する方法

パスファイル0とファイル1からファイル名を取得するにはどうすればよいですか?両方のファイルのデータを2つの別々のハッシュマップに格納する必要があるため、ファイル名が必要です。

答えて

0

次試してみてください。

Path file0 = DistributedCache.getLocalCacheFiles(job)[0]; 
Path file1 = DistributedCache.getLocalCacheFiles(job)[1]; 
String filename0 = file0.getName(); 
String filename1 = file1.getName(); 
関連する問題