Example #1
0
    @Override
    public ReturnState createTable(RpcController controller, TableDescProto request) {

      String[] splitted = CatalogUtil.splitFQTableName(request.getTableName());

      String dbName = splitted[0];
      String tbName = splitted[1];

      if (linkedMetadataManager.existsDatabase(dbName)) {
        return errInsufficientPrivilege("drop a table in database '" + dbName + "'");
      }

      if (metaDictionary.isSystemDatabase(dbName)) {
        return errInsufficientPrivilege("create a table in database '" + dbName + "'");
      }

      wlock.lock();
      try {
        store.createTable(request);
        LOG.info(
            String.format(
                "relation \"%s\" is added to the catalog (%s)",
                CatalogUtil.getCanonicalTableName(dbName, tbName), bindAddressStr));
        return OK;

      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);
        return returnError(t);

      } finally {
        wlock.unlock();
      }
    }
Example #2
0
 public TableDesc(TableDescProto proto) {
   this(
       proto.getId(),
       new Schema(proto.getSchema()),
       new TableMeta(proto.getMeta()),
       new Path(proto.getPath()));
   if (proto.hasStats()) {
     this.stats = new TableStats(proto.getStats());
   }
   if (proto.hasPartition()) {
     this.partitionMethodDesc = new PartitionMethodDesc(proto.getPartition());
   }
 }
Example #3
0
 public Object clone() throws CloneNotSupportedException {
   TableDesc desc = (TableDesc) super.clone();
   desc.builder = TableDescProto.newBuilder();
   desc.tableName = tableName;
   desc.schema = (Schema) schema.clone();
   desc.meta = (TableMeta) meta.clone();
   desc.uri = uri;
   desc.stats = stats != null ? (TableStats) stats.clone() : null;
   desc.partitionMethodDesc =
       partitionMethodDesc != null ? (PartitionMethodDesc) partitionMethodDesc.clone() : null;
   return desc;
 }
Example #4
0
 public TableDesc() {
   builder = TableDescProto.newBuilder();
 }
Example #5
-1
  public TableDescProto getProto() {
    if (builder == null) {
      builder = TableDescProto.newBuilder();
    }
    if (this.tableName != null) {
      builder.setId(this.tableName);
    }
    if (this.schema != null) {
      builder.setSchema(schema.getProto());
    }
    if (this.meta != null) {
      builder.setMeta(meta.getProto());
    }
    if (this.uri != null) {
      builder.setPath(this.uri.toString());
    }
    if (this.stats != null) {
      builder.setStats(this.stats.getProto());
    }
    if (this.partitionMethodDesc != null) {
      builder.setPartition(this.partitionMethodDesc.getProto());
    }

    return builder.build();
  }