示例#1
0
  public static byte[] encodeIteratorSettings(IteratorConfig iterators) {
    TSerializer tser = new TSerializer(new TBinaryProtocol.Factory());

    try {
      return tser.serialize(iterators);
    } catch (TException e) {
      throw new RuntimeException(e);
    }
  }
 private static String thriftToString(TBase object) {
   assert object != null;
   // this is so awful it's kind of cool!
   TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
   try {
     return Hex.bytesToHex(serializer.serialize(object));
   } catch (TException e) {
     throw new RuntimeException(e);
   }
 }
示例#3
0
  /** Executes a HiveServer2 metadata operation and returns a TMetadataOpResponse */
  public byte[] execHiveServer2MetadataOp(byte[] metadataOpsParams) throws ImpalaException {
    TMetadataOpRequest params = new TMetadataOpRequest();
    deserializeThrift(params, metadataOpsParams);
    TMetadataOpResponse result = frontend.execHiveServer2MetadataOp(params);

    TSerializer serializer = new TSerializer(protocolFactory);
    try {
      return serializer.serialize(result);
    } catch (TException e) {
      throw new InternalException(e.getMessage());
    }
  }
示例#4
0
  /**
   * Returns a list of the columns making up a table. The argument is a serialized
   * TDescribeTableParams object. The return type is a serialised TDescribeTableResult object.
   *
   * @see Frontend#describeTable
   */
  public byte[] describeTable(byte[] thriftDescribeTableParams) throws ImpalaException {
    TDescribeTableParams params = new TDescribeTableParams();
    deserializeThrift(params, thriftDescribeTableParams);
    TDescribeTableResult result = new TDescribeTableResult();
    result.setColumns(frontend.describeTable(params.getDb(), params.getTable_name()));

    TSerializer serializer = new TSerializer(protocolFactory);
    try {
      return serializer.serialize(result);
    } catch (TException e) {
      throw new InternalException(e.getMessage());
    }
  }
示例#5
0
  /**
   * Returns a list of table names matching an optional pattern. The argument is a serialized
   * TGetTablesParams object. The return type is a serialised TGetTablesResult object.
   *
   * @see Frontend#getTableNames
   */
  public byte[] getDbNames(byte[] thriftGetTablesParams) throws ImpalaException {
    TGetDbsParams params = new TGetDbsParams();
    deserializeThrift(params, thriftGetTablesParams);
    List<String> dbs = frontend.getDbNames(params.pattern);

    TGetDbsResult result = new TGetDbsResult();
    result.setDbs(dbs);

    TSerializer serializer = new TSerializer(protocolFactory);
    try {
      return serializer.serialize(result);
    } catch (TException e) {
      throw new InternalException(e.getMessage());
    }
  }
示例#6
0
  /**
   * Jni wrapper for Frontend.createQueryExecRequest2(). Accepts a serialized TClientRequest;
   * returns a serialized TQueryExecRequest2.
   */
  public byte[] createExecRequest(byte[] thriftClientRequest) throws ImpalaException {
    TClientRequest request = new TClientRequest();
    deserializeThrift(request, thriftClientRequest);

    StringBuilder explainString = new StringBuilder();
    TExecRequest result = frontend.createExecRequest(request, explainString);
    LOG.info(explainString.toString());

    // LOG.info("returned TQueryExecRequest2: " + result.toString());
    // TODO: avoid creating serializer for each query?
    TSerializer serializer = new TSerializer(protocolFactory);
    try {
      return serializer.serialize(result);
    } catch (TException e) {
      throw new InternalException(e.getMessage());
    }
  }
 public static byte[] serialize(HostConfig config) throws Exception {
   TSerializer serializer = new TSerializer();
   return serializer.serialize(config);
 }