简体   繁体   English

使用Java / JDBC的Hive表大小

[英]Hive table sizes using Java/JDBC

Is it possible to find the sizes in GB of the hive tables using Java/jdbc? 是否可以使用Java / jdbc查找配置单元表的GB大小? I don't want to depend on the hive warehouse folder in HDFS (as described in link ) as different tables may have different locations 我不想依赖HDFS中的配置单元仓库文件夹(如链接中所述 ),因为不同的表可能具有不同的位置

Currently not be possible but it can be done . 目前尚不可能,但可以完成。

To get file size you have to run on file system( HDFS) commands . 要获取文件大小,您必须在文件系统(HDFS)命令上运行。

In case of RDMS data bases ie sql server have encapsulated file system commands in SYS views and SYS functions (DMF and DMVs) . 在RDMS数据库的情况下,即sql server在SYS视图和SYS函数(DMF和DMV)中具有封装的文件系统命令。

If some one write or develop such UDF it will be possible but Internally the UDF will be calling same comand. 如果有人编写或开发这样的UDF是可能的,但是内部UDF将调用相同的命令。

If you are mention 'totalSize' from 'tblproperties' then it is possible with similar approach: 如果从“ tblproperties”中提到“ totalSize”,则可以使用类似的方法:

String driverName = "org.apache.hive.jdbc.HiveDriver";
String connectionURL = "jdbc:hive2://HOSTNAME:PORT/default";

try {
     Class.forName(driverName);
     Connection connection = DriverManager.getConnection( connectionURL, "", "");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      System.exit(1);
    }

Statement stmt = connection.createStatement("show tblproperties TABLENAME");
ResultSet rs =  stmt.executeQuery(stmt);
while(rs.next()){
            //doWhatYouWant
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM