/** * Determine the number of bytes of a given file. This method is not only a short-cut to * {@link FileSystem#getFileSize(String)} but also caches file sizes for performance reasons. * * @param fileUrl the URL of the file * @return the number of bytes of the file if it could be determined */ public static OptionalLong getFileSize(String fileUrl) { if (fileSizeCache.containsKey(fileUrl)) { return OptionalLong.of(fileSizeCache.get(fileUrl)); } final Optional<FileSystem> fileSystem = FileSystems.getFileSystem(fileUrl); if (fileSystem.isPresent()) { try { final long fileSize = fileSystem.get().getFileSize(fileUrl); fileSizeCache.put(fileUrl, fileSize); return OptionalLong.of(fileSize); } catch (FileNotFoundException e) { LOGGER.warn("Could not determine file size.", e); } } return OptionalLong.empty(); }
String graphName = tempFile.toString(); final int numShards = 2 + (int) inputFs.getFileSize(actualInputPath) / (10 * 1000000); if (!new File(ChiFilenames.getFilenameIntervals(graphName, numShards)).exists()) { FastSharder sharder = createSharder(graphName, numShards);