Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.Schema


  }
   
  @Test
  public void testSplitable() throws IOException {
    if (splitable) {
      Schema schema = new Schema();
      schema.addColumn("id", Type.INT4);
      schema.addColumn("age", Type.INT8);

      TableMeta meta = CatalogUtil.newTableMeta(schema, storeType);
      Path tablePath = new Path(testDir, "Splitable.data");
      Appender appender = StorageManagerFactory.getStorageManager(conf).getAppender(meta, tablePath);
      appender.enableStats();
View Full Code Here


    }
  }

  @Test
  public void testProjection() throws IOException {
    Schema schema = new Schema();
    schema.addColumn("id", Type.INT4);
    schema.addColumn("age", Type.INT8);
    schema.addColumn("score", Type.FLOAT4);

    TableMeta meta = CatalogUtil.newTableMeta(schema, storeType);

    Path tablePath = new Path(testDir, "testProjection.data");
    Appender appender = StorageManagerFactory.getStorageManager(conf).getAppender(meta, tablePath);
    appender.init();
    int tupleNum = 10000;
    VTuple vTuple;

    for(int i = 0; i < tupleNum; i++) {
      vTuple = new VTuple(3);
      vTuple.put(0, DatumFactory.createInt4(i + 1));
      vTuple.put(1, DatumFactory.createInt8(i + 2));
      vTuple.put(2, DatumFactory.createFloat4(i + 3));
      appender.addTuple(vTuple);
    }
    appender.close();

    FileStatus status = fs.getFileStatus(tablePath);
    Fragment fragment = new Fragment("testReadAndWrite", tablePath, meta, 0, status.getLen());

    Schema target = new Schema();
    target.addColumn("age", Type.INT8);
    target.addColumn("score", Type.FLOAT4);
    Scanner scanner = StorageManagerFactory.getStorageManager(conf).getScanner(meta, fragment, target);
    scanner.init();
    int tupleCnt = 0;
    Tuple tuple;
    while ((tuple = scanner.next()) != null) {
View Full Code Here

    assertEquals(tupleNum, tupleCnt);
  }

  @Test
  public void testVariousTypes() throws IOException {
    Schema schema = new Schema();
    schema.addColumn("col1", Type.BOOLEAN);
    schema.addColumn("col2", Type.BIT);
    schema.addColumn("col3", Type.CHAR, 7);
    schema.addColumn("col4", Type.INT2);
    schema.addColumn("col5", Type.INT4);
    schema.addColumn("col6", Type.INT8);
    schema.addColumn("col7", Type.FLOAT4);
    schema.addColumn("col8", Type.FLOAT8);
    schema.addColumn("col9", Type.TEXT);
    schema.addColumn("col10", Type.BLOB);
    schema.addColumn("col11", Type.INET4);
    schema.addColumn("col12", Type.NULL);

    Options options = new Options();
    TableMeta meta = CatalogUtil.newTableMeta(schema, storeType, options);

    Path tablePath = new Path(testDir, "testVariousTypes.data");
View Full Code Here

  // TODO - See https://issues.apache.org/jira/browse/HADOOP-9622
  //@Test
  public void testSplitCompressionData() throws IOException {

    Schema schema = new Schema();
    schema.addColumn("id", TajoDataTypes.Type.INT4);
    schema.addColumn("age", TajoDataTypes.Type.INT8);

    TableMeta meta = CatalogUtil.newTableMeta(schema, CatalogProtos.StoreType.CSV);
    meta.putOption("compression.codec", BZip2Codec.class.getCanonicalName());

    Path tablePath = new Path(testDir, "SplitCompression");
View Full Code Here

    scanner.close();
    assertEquals(tupleNum, tupleCnt);
  }

  private void storageCompressionTest(CatalogProtos.StoreType storeType, Class<? extends CompressionCodec> codec) throws IOException {
    Schema schema = new Schema();
    schema.addColumn("id", TajoDataTypes.Type.INT4);
    schema.addColumn("age", TajoDataTypes.Type.INT8);

    TableMeta meta = CatalogUtil.newTableMeta(schema, storeType);
    meta.putOption("compression.codec", codec.getCanonicalName());

    String fileName = "Compression_" + codec.getSimpleName();
View Full Code Here

  public void tearDown() throws Exception {
  }

  @Test
  public final void testGetScannerAndAppender() throws IOException {
    Schema schema = new Schema();
    schema.addColumn("id", TajoDataTypes.Type.INT4);
    schema.addColumn("age", TajoDataTypes.Type.INT4);
    schema.addColumn("name", TajoDataTypes.Type.TEXT);

    TableMeta meta = CatalogUtil.newTableMeta(schema, CatalogProtos.StoreType.CSV);

    Tuple[] tuples = new Tuple[4];
    for(int i=0; i < tuples.length; i++) {
View Full Code Here

    targets = updated;
    return updated;
  }

  public Schema getUpdatedSchema() {
    Schema schema = new Schema();
    for (int i = 0; i < resolvedFlags.length; i++) {
      if (resolvedFlags[i]) {
        Column col = getResolvedTargetToColumn(i);
        if (!schema.contains(col.getQualifiedName()))
        schema.addColumn(col);
      } else {
        Collection<Column> cols = getColumnRefs(i);
        for (Column col : cols) {
          if (!schema.contains(col.getQualifiedName())) {
            schema.addColumn(col);
          }
        }
      }
    }
    return schema;
View Full Code Here

  }

  private void verifySetStatement(VerificationState state, BinaryNode setNode) {
    Preconditions.checkArgument(setNode.getType() == NodeType.UNION || setNode.getType() == NodeType.INTERSECT ||
      setNode.getType() == NodeType.EXCEPT);
    Schema left = setNode.getLeftChild().getOutSchema();
    Schema right = setNode.getRightChild().getOutSchema();
    NodeType type = setNode.getType();

    if (left.getColumnNum() != right.getColumnNum()) {
      state.addVerification("each " + type.name() + " query must have the same number of columns");
      return;
    }

    Column[] leftColumns = left.toArray();
    Column[] rightColumns = right.toArray();

    for (int i = 0; i < leftColumns.length; i++) {
      if (!leftColumns[i].getDataType().equals(rightColumns[i].getDataType())) {
        state.addVerification(type + " types " + leftColumns[i].getDataType().getType() + " and "
            + rightColumns[i].getDataType().getType() + " cannot be matched");
View Full Code Here

    stack.push(node);
    LogicalNode outer = visitChild(leftContext, plan, node.getLeftChild(), stack);
    LogicalNode inner = visitChild(rightContext, plan, node.getRightChild(), stack);
    stack.pop();

    Schema merged = SchemaUtil.merge(outer.getOutSchema(), inner.getOutSchema());
    node.setInSchema(merged);
    pushDownProjectablePost(context, node, isTopmostProjectable(stack));

    return node;
  }
View Full Code Here

    newContext.upperRequired = new HashSet<Column>();
    newContext.upperRequired.addAll(PlannerUtil.targetToSchema(newContext.targetListManager.getTargets()).getColumns());

    LogicalNode child = visitChild(newContext, plan, subRoot, newStack);
    newStack.pop();
    Schema inSchema = (Schema) child.getOutSchema().clone();
    inSchema.setQualifier(node.getCanonicalName(), true);
    node.setInSchema(inSchema);
    return pushDownProjectablePost(context, node, isTopmostProjectable(stack));
  }
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.Schema

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.