使用java/jdbc的配置单元表大小

ss2ws0br  于 2021-06-28  发布在  Hive
关注(0)|答案(2)|浏览(249)

是否可以使用java/jdbc查找配置单元表的大小(以gb为单位)?我不想依赖hdfs中的hivewarehouse文件夹(如链接中所述),因为不同的表可能有不同的位置

fquxozlt

fquxozlt1#

目前不可能,但可以做到。
要获得文件大小,必须运行文件系统(hdfs)命令。
对于rdms数据库,ie sql server在sys视图和sys函数(dmf和dmv)中封装了文件系统命令。
如果有人编写或开发这样的自定义项,这将是可能的,但在内部自定义项将调用相同的命令。

o2g1uqev

o2g1uqev2#

如果您在“tblproperty”中提到“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
        }

相关问题