Package com.taobao.zeus.web.platform.client.module.tablemanager.model

Examples of com.taobao.zeus.web.platform.client.module.tablemanager.model.TableModel


   */
  private TableModel convert(Table t) {
    if (t == null) {
      return null;
    }
    TableModel tm = new TableModel();
    tm.setName(t.getTableName());
    tm.setDbName(t.getDbName());
    tm.setCreateDate(new Date(t.getCreateTime() * 1000L));
    tm.setOwner(t.getOwner());
    StorageDescriptor sd = t.getSd();
    tm.setPath(sd.getLocation());
    tm.setSerDeClass(sd.getSerdeInfo().getSerializationLib());

    // 如果分隔符是数字,需要转义为对应的ascll字符
    String fieldDelim = tansToStringIfInt(sd.getSerdeInfo().getParameters()
        .get(FIELD_DELIMITER_KEY));
    String lineDelim = tansToStringIfInt(sd.getSerdeInfo().getParameters()
        .get(LINE_DELIMITER_KEY));
    tm.setFieldDelim(fieldDelim);
    tm.setLineDelim(lineDelim);

    tm.setInputFormat(sd.getInputFormat());
    tm.setComment(t.getParameters().get("comment"));
    tm.setCols(convert(sd.getCols()));
    return tm;
  }
View Full Code Here


    resp.setContentType("text/csv");
    resp.setHeader("Content-disposition", "attachment;filename="
        + tableName + ".csv");
    PrintWriter w = resp.getWriter();

    TableModel t = tableManager.getTableModel(tableName);
    String inputFormatString = t.getInputFormat();
    char fieldDelim = t.getFieldDelim()==null? DEFAULT_FIELD_DELIM:t.getFieldDelim().toCharArray()[0];
    char lineDelim = t.getLineDelim() == null ? DEFAULT_LINE_DELIM : t
        .getLineDelim().toCharArray()[0];

    final Configuration conf = ConfUtil.getDefaultCoreSite();
    Profile profile = profileManager.findByUid(user.getUid());
    if (profile != null) {
      String ugi = profile.getHadoopConf().get("hadoop.hadoop.job.ugi");
      if (ugi != null) {
        conf.set("hadoop.job.ugi", ugi);
      }
    }
    JobConf confQ = new JobConf(conf);
    FileSystem fs = FileSystem.get(confQ);

    InputFormat inputFormat;
    try {
      inputFormat = (InputFormat) ReflectionUtils.newInstance(
          Class.forName(inputFormatString), conf);
    } catch (ClassNotFoundException e) {
      log.error("partition download error", e);
      w.write("分区下载失败");
      return;
    }
    RecordReader<Writable, Writable> reader;

    FileStatus[] files = fs.listStatus(new Path(pathString));
    if (files == null) {
      log("无法访问" + pathString + "\n路径不存在或没有访问权限! ");
      w.write("无法访问" + pathString + "\n路径不存在或没有访问权限! ");
      return;
    }
    boolean first = true;
    for (TableColumnModel col : t.getCols()) {
      if (first) {
        first = false;
      } else {
        w.write(',');
      }
View Full Code Here

    this.context = context;
  }

  @Override
  public boolean isEnableDelete() {
    TableModel selectedItem = getTableManagerView().getSelectedItem();
    if (selectedItem == null) {
      return false;
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of com.taobao.zeus.web.platform.client.module.tablemanager.model.TableModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.