HBase、Hadoop:如何估计 HBase table 或 Hadoop 文件系统路径的大小?
HBase, Hadoop : How can I estimate the size of a HBase table or Hadoop File System Paths?
我有多个 HBase 表,如何估计 java 中使用的表的大概大小?
一种方法是您必须使用通常在 /hbase
文件夹下的 java 客户端访问 hdfs
table 的所有信息。将出席。
Hadoop shell :
您可以使用 hadoop fs -du -h **path to hbase**/hbase
检查
在/hbase下每个table多占一个文件夹...
hadoop fs -ls -R **path to hbase**/hbase
hadoop fs -du -h **path to hbase**/hbase/tablename
Java HDFS 客户端:
您可以使用 java hdfs 客户端,通过在 hbase 根目录下传递每个 table 路径,如下所示...
检查 getSizeOfPaths
& getSizeOfDirectory
方法
public class HdfsUtil {
/**
* Estimates the number of splits by taking the size of the paths and dividing by the splitSize.
*
* @param paths
* @param configuration
* @param splitSize
* @return
* @throws IOException
*/
public static long getNumOfSplitsForInputs(Path[] paths, Configuration configuration, long splitSize) throws IOException
{
long size = getSizeOfPaths(paths, configuration);
long splits = (int) Math.ceil( size / (splitSize)) ;
return splits;
}
public static long getSizeOfPaths(Path[] paths, Configuration configuration) throws IOException
{
long totalSize = 0L;
for(Path path: paths)
{
totalSize += getSizeOfDirectory(path, configuration);
}
return totalSize;
}
// here you can give hbase path folder which was described through shell
public static long getSizeOfDirectory(Path path, Configuration configuration) throws IOException {
//Get the file size of the unannotated Edges
FileSystem fileSystem = FileSystem.get(configuration);
long size = fileSystem.getContentSummary(path).getLength();
/**static String byteCountToDisplaySize(BigInteger size)
Returns a human-readable version of the file size, where the input represents a specific number of bytes.**/
System.out.println(FileUtils.byteCountToDisplaySize(size))
return size;
}
}
我有多个 HBase 表,如何估计 java 中使用的表的大概大小?
一种方法是您必须使用通常在 /hbase
文件夹下的 java 客户端访问 hdfs
table 的所有信息。将出席。
Hadoop shell :
您可以使用 hadoop fs -du -h **path to hbase**/hbase
在/hbase下每个table多占一个文件夹...
hadoop fs -ls -R **path to hbase**/hbase
hadoop fs -du -h **path to hbase**/hbase/tablename
Java HDFS 客户端:
您可以使用 java hdfs 客户端,通过在 hbase 根目录下传递每个 table 路径,如下所示...
检查 getSizeOfPaths
& getSizeOfDirectory
方法
public class HdfsUtil {
/**
* Estimates the number of splits by taking the size of the paths and dividing by the splitSize.
*
* @param paths
* @param configuration
* @param splitSize
* @return
* @throws IOException
*/
public static long getNumOfSplitsForInputs(Path[] paths, Configuration configuration, long splitSize) throws IOException
{
long size = getSizeOfPaths(paths, configuration);
long splits = (int) Math.ceil( size / (splitSize)) ;
return splits;
}
public static long getSizeOfPaths(Path[] paths, Configuration configuration) throws IOException
{
long totalSize = 0L;
for(Path path: paths)
{
totalSize += getSizeOfDirectory(path, configuration);
}
return totalSize;
}
// here you can give hbase path folder which was described through shell
public static long getSizeOfDirectory(Path path, Configuration configuration) throws IOException {
//Get the file size of the unannotated Edges
FileSystem fileSystem = FileSystem.get(configuration);
long size = fileSystem.getContentSummary(path).getLength();
/**static String byteCountToDisplaySize(BigInteger size)
Returns a human-readable version of the file size, where the input represents a specific number of bytes.**/
System.out.println(FileUtils.byteCountToDisplaySize(size))
return size;
}
}