Пример #1
0
 public TableDesc attachTable(String name, String path) throws ServiceException {
   AttachTableRequest.Builder builder = AttachTableRequest.newBuilder();
   builder.setName(name);
   builder.setPath(path);
   TableResponse res = service.attachTable(null, builder.build());
   return TCatUtil.newTableDesc(res.getTableDesc());
 }
Пример #2
0
 public Fragment(String fragmentId, Path path, TableMeta meta, long start, long length) {
   this();
   TableMeta newMeta = new TableMetaImpl(meta.getProto());
   SchemaProto newSchemaProto =
       TCatUtil.getQualfiedSchema(fragmentId, meta.getSchema().getProto());
   newMeta.setSchema(new Schema(newSchemaProto));
   this.set(fragmentId, path, newMeta, start, length);
 }
Пример #3
0
 public TableDesc createTable(String name, Path path, TableMeta meta) throws ServiceException {
   CreateTableRequest.Builder builder = CreateTableRequest.newBuilder();
   builder.setName(name);
   builder.setPath(path.toString());
   builder.setMeta(meta.getProto());
   TableResponse res = service.createTable(null, builder.build());
   return TCatUtil.newTableDesc(res.getTableDesc());
 }
Пример #4
0
 public TableDesc getTableDesc(String tableName) throws ServiceException {
   GetTableDescRequest.Builder build = GetTableDescRequest.newBuilder();
   build.setTableName(tableName);
   TableResponse res = service.getTableDesc(null, build.build());
   if (res == null) {
     return null;
   } else {
     return TCatUtil.newTableDesc(res.getTableDesc());
   }
 }
Пример #5
0
  public TableDesc getResultDesc(QueryId queryId) throws ServiceException {
    if (queryId.equals(TajoIdUtils.NullQueryId)) {
      return null;
    }

    GetQueryResultRequest.Builder builder = GetQueryResultRequest.newBuilder();
    builder.setQueryId(queryId.getProto());
    GetQueryResultResponse response = service.getQueryResult(null, builder.build());

    return TCatUtil.newTableDesc(response.getTableDesc());
  }
Пример #6
0
  @BeforeClass
  public static void setUp() throws Exception {
    util = new TajoTestingCluster();
    util.startCatalogCluster();
    cat = util.getMiniCatalogCluster().getCatalog();

    schema1 = new Schema();
    schema1.addColumn("id", DataType.INT);
    schema1.addColumn("name", DataType.STRING);
    schema1.addColumn("score", DataType.INT);
    schema1.addColumn("age", DataType.INT);

    Schema schema2 = new Schema();
    schema2.addColumn("id", DataType.INT);
    schema2.addColumn("people_id", DataType.INT);
    schema2.addColumn("dept", DataType.STRING);
    schema2.addColumn("year", DataType.INT);

    Schema schema3 = new Schema();
    schema3.addColumn("id", DataType.INT);
    schema3.addColumn("people_id", DataType.INT);
    schema3.addColumn("class", DataType.STRING);
    schema3.addColumn("branch_name", DataType.STRING);

    Schema schema4 = new Schema();
    schema4.addColumn("char_col", DataType.CHAR);
    schema4.addColumn("short_col", DataType.SHORT);
    schema4.addColumn("int_col", DataType.INT);
    schema4.addColumn("long_col", DataType.LONG);
    schema4.addColumn("float_col", DataType.FLOAT);
    schema4.addColumn("double_col", DataType.DOUBLE);
    schema4.addColumn("string_col", DataType.STRING);

    TableMeta meta = TCatUtil.newTableMeta(schema1, StoreType.CSV);
    TableDesc people = new TableDescImpl("people", meta, new Path("file:///"));
    cat.addTable(people);

    TableDesc student =
        TCatUtil.newTableDesc(
            "student", schema2, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(student);

    TableDesc branch =
        TCatUtil.newTableDesc(
            "branch", schema3, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(branch);

    TableDesc allType =
        TCatUtil.newTableDesc(
            "alltype", schema4, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(allType);

    TPCH tpch = new TPCH();
    tpch.loadSchemas();
    Schema lineitemSchema = tpch.getSchema("lineitem");
    Schema partSchema = tpch.getSchema("part");
    TableDesc lineitem =
        TCatUtil.newTableDesc(
            "lineitem", lineitemSchema, StoreType.CSV, new Options(), new Path("file:///"));
    TableDesc part =
        TCatUtil.newTableDesc(
            "part", partSchema, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(lineitem);
    cat.addTable(part);

    FunctionDesc funcMeta =
        new FunctionDesc(
            "sumtest",
            TestSum.class,
            FunctionType.GENERAL,
            new DataType[] {DataType.INT},
            new DataType[] {DataType.INT});

    cat.registerFunction(funcMeta);

    analyzer = new QueryAnalyzer(cat);
  }