Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.Schema


   
    return merged;
  }
 
  public static Schema getCommons(Schema left, Schema right) {
    Schema common = new Schema();
    for (Column outer : left.getColumns()) {
      for (Column inner : right.getColumns()) {
        if (outer.getColumnName().equals(inner.getColumnName()) &&
            outer.getDataType().equals(inner.getDataType())) {
          common.addColumn(outer.getColumnName(), outer.getDataType());
        }
      }
    }
   
    return common;
View Full Code Here


  }

  public static String [] rangesToQueries(final SortSpec[] sortSpec,
                                          final TupleRange[] ranges)
      throws UnsupportedEncodingException {
    Schema schema = PlannerUtil.sortSpecsToSchema(sortSpec);
    boolean ascendingFirstKey = sortSpec[0].isAscending();
    String [] params = new String[ranges.length];
    for (int i = 0; i < ranges.length; i++) {
      params[i] =
        rangeToQuery(schema, ranges[i], ascendingFirstKey,
View Full Code Here

      byte [] schemaBytes = new byte[schemaByteSize];
      indexIn.read(schemaBytes);
      SchemaProto.Builder builder = SchemaProto.newBuilder();
      builder.mergeFrom(schemaBytes);
      SchemaProto proto = builder.build();
      this.keySchema = new Schema(proto);

      // comparator
      int compByteSize = indexIn.readInt();
      byte [] compBytes = new byte[compByteSize];
      indexIn.read(compBytes);
View Full Code Here

  public static String PARTSUPP = "partsupp";
  public static String SUPPLIER = "supplier";

  @Override
  public void loadSchemas() {
    Schema lineitem = new Schema()
        .addColumn("l_orderkey", Type.INT8) // 0
        .addColumn("l_partkey", Type.INT4) // 1
        .addColumn("l_suppkey", Type.INT4) // 2
        .addColumn("l_linenumber", Type.INT4) // 3
        .addColumn("l_quantity", Type.FLOAT4) // 4
        .addColumn("l_extendedprice", Type.FLOAT4) // 5
        .addColumn("l_discount", Type.FLOAT4) // 6
        .addColumn("l_tax", Type.FLOAT4) // 7
            // TODO - This is temporal solution. 8 and 9 are actually Char type.
        .addColumn("l_returnflag", Type.TEXT) // 8
        .addColumn("l_linestatus", Type.TEXT) // 9
            // TODO - This is temporal solution. 10,11, and 12 are actually Date type.
        .addColumn("l_shipdate", Type.TEXT) // 10
        .addColumn("l_commitdate", Type.TEXT) // 11
        .addColumn("l_receiptdate", Type.TEXT) // 12
        .addColumn("l_shipinstruct", Type.TEXT) // 13
        .addColumn("l_shipmode", Type.TEXT) // 14
        .addColumn("l_comment", Type.TEXT); // 15
    schemas.put(LINEITEM, lineitem);

    Schema customer = new Schema()
        .addColumn("c_custkey", Type.INT4) // 0
        .addColumn("c_name", Type.TEXT) // 1
        .addColumn("c_address", Type.TEXT) // 2
        .addColumn("c_nationkey", Type.INT4) // 3
        .addColumn("c_phone", Type.TEXT) // 4
        .addColumn("c_acctbal", Type.FLOAT4) // 5
        .addColumn("c_mktsegment", Type.TEXT) // 6
        .addColumn("c_comment", Type.TEXT); // 7
    schemas.put(CUSTOMER, customer);

    Schema nation = new Schema()
        .addColumn("n_nationkey", Type.INT4) // 0
        .addColumn("n_name", Type.TEXT) // 1
        .addColumn("n_regionkey", Type.INT4) // 2
        .addColumn("n_comment", Type.TEXT); // 3
    schemas.put(NATION, nation);

    Schema part = new Schema()
        .addColumn("p_partkey", Type.INT4) // 0
        .addColumn("p_name", Type.TEXT) // 1
        .addColumn("p_mfgr", Type.TEXT) // 2
        .addColumn("p_brand", Type.TEXT) // 3
        .addColumn("p_type", Type.TEXT) // 4
        .addColumn("p_size", Type.INT4) // 5
        .addColumn("p_container", Type.TEXT) // 6
        .addColumn("p_retailprice", Type.FLOAT4) // 7
        .addColumn("p_comment", Type.TEXT); // 8
    schemas.put(PART, part);

    Schema region = new Schema()
        .addColumn("r_regionkey", Type.INT4) // 0
        .addColumn("r_name", Type.TEXT) // 1
        .addColumn("r_comment", Type.TEXT); // 2
    schemas.put(REGION, region);

    Schema orders = new Schema()
        .addColumn("o_orderkey", Type.INT8) // 0
        .addColumn("o_custkey", Type.INT4) // 1
        .addColumn("o_orderstatus", Type.TEXT) // 2
        .addColumn("o_totalprice", Type.FLOAT4) // 3
            // TODO - This is temporal solution. o_orderdate is actually Date type.
        .addColumn("o_orderdate", Type.TEXT) // 4
        .addColumn("o_orderpriority", Type.TEXT) // 5
        .addColumn("o_clerk", Type.TEXT) // 6
        .addColumn("o_shippriority", Type.INT4) // 7
        .addColumn("o_comment", Type.TEXT); // 8
    schemas.put(ORDERS, orders);

    Schema partsupp = new Schema()
        .addColumn("ps_partkey", Type.INT4) // 0
        .addColumn("ps_suppkey", Type.INT4) // 1
        .addColumn("ps_availqty", Type.INT4) // 2
        .addColumn("ps_supplycost", Type.FLOAT4) // 3
        .addColumn("ps_comment", Type.TEXT); // 4
    schemas.put(PARTSUPP, partsupp);

    Schema supplier = new Schema()
        .addColumn("s_suppkey", Type.INT4) // 0
        .addColumn("s_name", Type.TEXT) // 1
        .addColumn("s_address", Type.TEXT) // 2
        .addColumn("s_nationkey", Type.INT4) // 3
        .addColumn("s_phone", Type.TEXT) // 4
View Full Code Here

        .addColumn("s_comment", Type.TEXT); // 6
    schemas.put(SUPPLIER, supplier);
  }

  public void loadOutSchema() {
    Schema q2 = new Schema()
        .addColumn("s_acctbal", Type.FLOAT4)
        .addColumn("s_name", Type.TEXT)
        .addColumn("n_name", Type.TEXT)
        .addColumn("p_partkey", Type.INT4)
        .addColumn("p_mfgr", Type.TEXT)
View Full Code Here

import static org.junit.Assert.assertTrue;

public class TestTupleUtil {
  @Test
  public final void testToBytesAndToTuple() {
    Schema schema = new Schema();
    schema.addColumn("col1", Type.BOOLEAN);
    schema.addColumn("col2", Type.BIT);
    schema.addColumn("col3", Type.CHAR);
    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("col11", DataType.IPv6);
   
    Tuple tuple = new VTuple(11);
    tuple.put(new Datum[] {
        DatumFactory.createBool(true),
View Full Code Here

  @Test
  public final void testGetPartitions() {
    Tuple sTuple = new VTuple(7);
    Tuple eTuple = new VTuple(7);

    Schema schema = new Schema();
    schema.addColumn("numByte", Type.BIT);
    schema.addColumn("numChar", Type.CHAR);
    schema.addColumn("numShort", Type.INT2);
    schema.addColumn("numInt", Type.INT4);
    schema.addColumn("numLong", Type.INT8);
    schema.addColumn("numFloat", Type.FLOAT4);
    schema.addColumn("numDouble", Type.FLOAT4);

    sTuple.put(0, DatumFactory.createBit((byte) 44));
    sTuple.put(1, DatumFactory.createChar('a'));
    sTuple.put(2, DatumFactory.createInt2((short) 10));
    sTuple.put(3, DatumFactory.createInt4(5));
View Full Code Here

    }
  }

  @Test
  public void testQueryToRange() throws UnsupportedEncodingException {
    Schema schema = new Schema();
    schema.addColumn("intval", Type.INT4);
    schema.addColumn("floatval", Type.FLOAT4);

    Tuple s = new VTuple(2);
    s.put(0, DatumFactory.createInt4(5));
    s.put(1, DatumFactory.createFloat4(10));
View Full Code Here

    assertEquals(expected, range);
  }

  @Test
  public void testQueryToRangeWithOneRange() throws UnsupportedEncodingException {
    Schema schema = new Schema();
    schema.addColumn("partkey", Type.FLOAT4);

    Tuple s = new VTuple(1);
    s.put(0, DatumFactory.createFloat4(28082));
    Tuple e = new VTuple(1);
    e.put(0, DatumFactory.createFloat4(28082));
View Full Code Here

  @Test
  /**
   * It verifies NTA-805.
   */
  public void testRangeToQueryHeavyTest() throws UnsupportedEncodingException {
    Schema schema = new Schema();
    schema.addColumn("c_custkey", Type.INT4);
    Tuple s = new VTuple(1);
    s.put(0, DatumFactory.createInt4(4));
    Tuple e = new VTuple(1);
    e.put(0, DatumFactory.createInt4(149995));
    TupleRange expected = new TupleRange(schema, s, e);
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.