org.apache.hadoop.hive.ql.exec.Utilities.serializeExpressionToKryo()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中org.apache.hadoop.hive.ql.exec.Utilities.serializeExpressionToKryo()方法的一些代码示例,展示了Utilities.serializeExpressionToKryo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.serializeExpressionToKryo()方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.exec.Utilities
类名称:Utilities
方法名:serializeExpressionToKryo

Utilities.serializeExpressionToKryo介绍

[英]Serializes expression via Kryo.
[中]通过Kryo序列化表达式。

代码示例

代码示例来源:origin: com.facebook.presto.hive/hive-apache

public static String serializeExpression(ExprNodeGenericFuncDesc expr) {
 try {
  return new String(Base64.encodeBase64(serializeExpressionToKryo(expr)), "UTF-8");
 } catch (UnsupportedEncodingException ex) {
  throw new RuntimeException("UTF-8 support required", ex);
 }
}

代码示例来源:origin: org.spark-project.hive.hcatalog/hive-webhcat-java-client

private void dropPartitionsUsingExpressions(Table table, Map<String, String> partitionSpec,
                      boolean ifExists, boolean deleteData)
  throws SemanticException, TException {
 LOG.info("HCatClient: Dropping partitions using partition-predicate Expressions.");
 ExprNodeGenericFuncDesc partitionExpression = new ExpressionBuilder(table, partitionSpec).build();
 ObjectPair<Integer, byte[]> serializedPartitionExpression =
   new ObjectPair<Integer, byte[]>(partitionSpec.size(),
     Utilities.serializeExpressionToKryo(partitionExpression));
 hmsClient.dropPartitions(table.getDbName(), table.getTableName(), Arrays.asList(serializedPartitionExpression),
   deleteData && !isExternal(table),  // Delete data?
   false,                             // Ignore Protection?
   ifExists,                          // Fail if table doesn't exist?
   false);                            // Need results back?
}

代码示例来源:origin: com.github.hyukjinkwon.hcatalog/hive-webhcat-java-client

private void dropPartitionsUsingExpressions(Table table, Map<String, String> partitionSpec,
                      boolean ifExists, boolean deleteData)
  throws SemanticException, TException {
 LOG.info("HCatClient: Dropping partitions using partition-predicate Expressions.");
 ExprNodeGenericFuncDesc partitionExpression = new ExpressionBuilder(table, partitionSpec).build();
 ObjectPair<Integer, byte[]> serializedPartitionExpression =
   new ObjectPair<Integer, byte[]>(partitionSpec.size(),
     Utilities.serializeExpressionToKryo(partitionExpression));
 hmsClient.dropPartitions(table.getDbName(), table.getTableName(), Arrays.asList(serializedPartitionExpression),
   deleteData && !isExternal(table),  // Delete data?
   false,                             // Ignore Protection?
   ifExists,                          // Fail if table doesn't exist?
   false);                            // Need results back?
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

public List<Partition> dropPartitions(String dbName, String tblName,
  List<DropTableDesc.PartSpec> partSpecs, PartitionDropOptions dropOptions) throws HiveException {
 try {
  Table tbl = getTable(dbName, tblName);
  List<ObjectPair<Integer, byte[]>> partExprs =
    new ArrayList<ObjectPair<Integer,byte[]>>(partSpecs.size());
  for (DropTableDesc.PartSpec partSpec : partSpecs) {
   partExprs.add(new ObjectPair<Integer, byte[]>(partSpec.getPrefixLength(),
     Utilities.serializeExpressionToKryo(partSpec.getPartSpec())));
  }
  List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().dropPartitions(
    dbName, tblName, partExprs, dropOptions);
  return convertFromMetastore(tbl, tParts, null);
 } catch (NoSuchObjectException e) {
  throw new HiveException("Partition or table doesn't exist.", e);
 } catch (Exception e) {
  throw new HiveException(e.getMessage(), e);
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * Get a list of Partitions by expr.
 * @param tbl The table containing the partitions.
 * @param expr A serialized expression for partition predicates.
 * @param conf Hive config.
 * @param result the resulting list of partitions
 * @return whether the resulting list contains partitions which may or may not match the expr
 */
public boolean getPartitionsByExpr(Table tbl, ExprNodeGenericFuncDesc expr, HiveConf conf,
  List<Partition> result) throws HiveException, TException {
 assert result != null;
 byte[] exprBytes = Utilities.serializeExpressionToKryo(expr);
 String defaultPartitionName = HiveConf.getVar(conf, ConfVars.DEFAULTPARTITIONNAME);
 List<org.apache.hadoop.hive.metastore.api.Partition> msParts =
   new ArrayList<org.apache.hadoop.hive.metastore.api.Partition>();
 boolean hasUnknownParts = getMSC().listPartitionsByExpr(tbl.getDbName(),
   tbl.getTableName(), exprBytes, defaultPartitionName, (short)-1, msParts);
 convertFromMetastore(tbl, msParts, result);
 return hasUnknownParts;
}

相关文章

微信公众号

最新文章

更多

Utilities类方法