Changeset 30945 for other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust/ClusterFileIO.java
- Timestamp:
- 2016-10-26T15:37:24+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust/ClusterFileIO.java
r30941 r30945 21 21 import org.apache.hadoop.fs.FileSystem; 22 22 import org.apache.hadoop.fs.Path; 23 import org.apache.spark.api.java.JavaSparkContext;24 23 25 24 public class ClusterFileIO { … … 58 57 */ 59 58 60 p ublicstatic FileSystem getFileSystemInstance(String input_dir)59 protected static FileSystem getFileSystemInstance(String input_dir) 61 60 { 62 61 if (__fs == null) { … … 82 81 } 83 82 84 p rotectedstatic boolean exists(String file)83 public static boolean exists(String file) 85 84 { 86 85 FileSystem fs = getFileSystemInstance(file); … … 100 99 return exists; 101 100 } 102 protected static BufferedInputStream getBufferedInputStream(String fileIn) 101 102 public static String removeSuffix(String file,String suffix) 103 { 104 return file.substring(0,file.length() - suffix.length()); 105 } 106 107 public static boolean createDirectoryAll(String dir) 108 { 109 FileSystem fs = getFileSystemInstance(dir); 110 boolean created_dir = false; 111 112 if (!exists(dir)) { 113 try { 114 URI uri = new URI(dir); 115 Path path = new Path(uri); 116 fs.mkdirs(path); 117 created_dir = true; 118 } catch (URISyntaxException e) { 119 e.printStackTrace(); 120 } catch (IOException e) { 121 e.printStackTrace(); 122 } 123 } 124 125 return created_dir; 126 } 127 128 public static BufferedInputStream getBufferedInputStream(String fileIn) 103 129 throws IOException 104 130 { … … 137 163 } 138 164 139 p rotectedstatic BufferedOutputStream getBufferedOutputStream(String fileOut)165 public static BufferedOutputStream getBufferedOutputStream(String fileOut) 140 166 throws IOException 141 167 { … … 163 189 } 164 190 165 p rotectedstatic BufferedReader getBufferedReaderForCompressedFile(String fileIn)191 public static BufferedReader getBufferedReaderForCompressedFile(String fileIn) 166 192 throws IOException, CompressorException 167 193 { … … 172 198 } 173 199 174 p rotectedstatic BufferedWriter getBufferedWriterForCompressedFile(String fileOut)200 public static BufferedWriter getBufferedWriterForCompressedFile(String fileOut) 175 201 throws IOException, CompressorException 176 202 {
Note:
See TracChangeset
for help on using the changeset viewer.