当前位置: 首页>>代码示例>>Java>>正文


Java FileStatus.getLen方法代码示例

本文整理汇总了Java中org.apache.flink.core.fs.FileStatus.getLen方法的典型用法代码示例。如果您正苦于以下问题:Java FileStatus.getLen方法的具体用法?Java FileStatus.getLen怎么用?Java FileStatus.getLen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.fs.FileStatus的用法示例。


在下文中一共展示了FileStatus.getLen方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFileStats

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
protected FileBaseStatistics getFileStats(FileBaseStatistics cachedStats, Path filePath, FileSystem fs,
		ArrayList<FileStatus> files) throws IOException {
	
	// get the file info and check whether the cached statistics are still valid.
	final FileStatus file = fs.getFileStatus(filePath);
	long totalLength = 0;

	// enumerate all files
	if (file.isDir()) {
		totalLength += addFilesInDir(file.getPath(), files, false);
	} else {
		files.add(file);
		testForUnsplittable(file);
		totalLength += file.getLen();
	}

	// check the modification time stamp
	long latestModTime = 0;
	for (FileStatus f : files) {
		latestModTime = Math.max(f.getModificationTime(), latestModTime);
	}

	// check whether the cached statistics are still valid, if we have any
	if (cachedStats != null && latestModTime <= cachedStats.getLastModificationTime()) {
		return cachedStats;
	}

	// sanity check
	if (totalLength <= 0) {
		totalLength = BaseStatistics.SIZE_UNKNOWN;
	}
	return new FileBaseStatistics(latestModTime, totalLength, BaseStatistics.AVG_RECORD_BYTES_UNKNOWN);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:34,代码来源:FileInputFormat.java

示例2: addFilesInDir

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Enumerate all files in the directory and recursive if enumerateNestedFiles is true.
 * @return the total length of accepted files.
 */
private long addFilesInDir(Path path, List<FileStatus> files, boolean logExcludedFiles)
		throws IOException {
	final FileSystem fs = path.getFileSystem();

	long length = 0;

	for(FileStatus dir: fs.listStatus(path)) {
		if (dir.isDir()) {
			if (acceptFile(dir) && enumerateNestedFiles) {
				length += addFilesInDir(dir.getPath(), files, logExcludedFiles);
			} else {
				if (logExcludedFiles && LOG.isDebugEnabled()) {
					LOG.debug("Directory "+dir.getPath().toString()+" did not pass the file-filter and is excluded.");
				}
			}
		}
		else {
			if(acceptFile(dir)) {
				files.add(dir);
				length += dir.getLen();
				testForUnsplittable(dir);
			} else {
				if (logExcludedFiles && LOG.isDebugEnabled()) {
					LOG.debug("Directory "+dir.getPath().toString()+" did not pass the file-filter and is excluded.");
				}
			}
		}
	}
	return length;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:35,代码来源:FileInputFormat.java

示例3: createStatistics

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Fill in the statistics. The last modification time and the total input size are prefilled.
 *
 * @param files
 *        The files that are associated with this block input format.
 * @param stats
 *        The pre-filled statistics.
 */
protected SequentialStatistics createStatistics(List<FileStatus> files, FileBaseStatistics stats)
		throws IOException {
	if (files.isEmpty()) {
		return null;
	}

	BlockInfo blockInfo = new BlockInfo();
	long totalCount = 0;
	for (FileStatus file : files) {
		// invalid file
		if (file.getLen() < blockInfo.getInfoSize()) {
			continue;
		}

		FileSystem fs = file.getPath().getFileSystem();
		try (FSDataInputStream fdis = fs.open(file.getPath(), blockInfo.getInfoSize())) {
			fdis.seek(file.getLen() - blockInfo.getInfoSize());

			blockInfo.read(new DataInputViewStreamWrapper(fdis));
			totalCount += blockInfo.getAccumulatedRecordCount();
		}
	}

	final float avgWidth = totalCount == 0 ? 0 : ((float) stats.getTotalInputSize() / totalCount);
	return new SequentialStatistics(stats.getLastModificationTime(), stats.getTotalInputSize(), avgWidth,
		totalCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:36,代码来源:BinaryInputFormat.java

示例4: createStatistics

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
/**
 * Fill in the statistics. The last modification time and the total input size are prefilled.
 * 
 * @param files
 *        The files that are associated with this block input format.
 * @param stats
 *        The pre-filled statistics.
 */
protected SequentialStatistics createStatistics(List<FileStatus> files, FileBaseStatistics stats)
		throws IOException {
	if (files.isEmpty()) {
		return null;
	}

	BlockInfo blockInfo = this.createBlockInfo();

	long totalCount = 0;
	for (FileStatus file : files) {
		// invalid file
		if (file.getLen() < blockInfo.getInfoSize()) {
			continue;
		}

		FSDataInputStream fdis = file.getPath().getFileSystem().open(file.getPath(), blockInfo.getInfoSize());
		fdis.seek(file.getLen() - blockInfo.getInfoSize());

		DataInputStream input = new DataInputStream(fdis);
		blockInfo.read(new InputViewDataInputStreamWrapper(input));
		totalCount += blockInfo.getAccumulatedRecordCount();
	}

	final float avgWidth = totalCount == 0 ? 0 : ((float) stats.getTotalInputSize() / totalCount);
	return new SequentialStatistics(stats.getLastModificationTime(), stats.getTotalInputSize(), avgWidth,
		totalCount);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:36,代码来源:BinaryInputFormat.java

示例5: getFileBlockLocations

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
@Override
public BlockLocation[] getFileBlockLocations(final FileStatus file, final long start, final long len)
		throws IOException {

	final BlockLocation[] blockLocations = new BlockLocation[1];
	blockLocations[0] = new LocalBlockLocation(this.hostName, file.getLen());

	return blockLocations;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:10,代码来源:LocalFileSystem.java

示例6: getFileBlockLocations

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
@Override
public BlockLocation[] getFileBlockLocations(final FileStatus file, final long start, final long len)
		throws IOException {

	if ((start + len) > file.getLen()) {
		return null;
	}

	final S3BlockLocation bl = new S3BlockLocation(this.host, file.getLen());

	return new BlockLocation[] { bl };
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:13,代码来源:S3FileSystem.java

示例7: getFileBlockLocations

import org.apache.flink.core.fs.FileStatus; //导入方法依赖的package包/类
@Override
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException {
	return new BlockLocation[] {
			new LocalBlockLocation(hostName, file.getLen())
	};
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:LocalFileSystem.java


注:本文中的org.apache.flink.core.fs.FileStatus.getLen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。