Package org.apache.tajo.datum

Examples of org.apache.tajo.datum.TextDatum


    super(new Column[] {new Column("addr", TEXT)});
  }

  @Override
  public TextDatum eval(Tuple params) {
    return new TextDatum(GeoUtil.getCountryCode(params.get(0).asChars()));
  }
View Full Code Here


public class TestGeneralFunction {

  @Test
  public void testDate() {
    Date date = new Date();
    Tuple tuple = new VTuple(new Datum[] {new TextDatum("25/12/2012 00:00:00")});
    Int8Datum unixtime = (Int8Datum) date.eval(tuple);
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(unixtime.asInt8());
    assertEquals(2012, c.get(Calendar.YEAR));
    assertEquals(11, c.get(Calendar.MONTH));
View Full Code Here

          for (String eachTableName: tableNames) {
            if (eachTableName.matches(regtableNamePattern)) {
              MetaDataTuple tuple = new MetaDataTuple(5);

              int index = 0;
              tuple.put(index++, new TextDatum(databaseName));         // TABLE_CAT
              tuple.put(index++, new TextDatum(DEFAULT_SCHEMA_NAME));   // TABLE_SCHEM
              tuple.put(index++, new TextDatum(eachTableName));         // TABLE_NAME
              tuple.put(index++, new TextDatum("TABLE"));               // TABLE_TYPE
              tuple.put(index++, NullDatum.get());                      // REMARKS

              resultTables.add(tuple);
            }
          }
View Full Code Here

    } catch (ServiceException e) {
      throw new SQLException(e);
    }

    MetaDataTuple tuple = new MetaDataTuple(2);
    tuple.put(0, new TextDatum(DEFAULT_SCHEMA_NAME));
    tuple.put(1, new TextDatum(databaseName));

    return new TajoMetaDataResultSet(
        Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG"),
        Arrays.asList(Type.VARCHAR, Type.VARCHAR),
        Arrays.asList(tuple));
View Full Code Here

    }

    List<MetaDataTuple> tuples = new ArrayList<MetaDataTuple>();
    for (String databaseName : databaseNames) {
      MetaDataTuple tuple = new MetaDataTuple(1);
      tuple.put(0, new TextDatum(databaseName));
      tuples.add(tuple);
    }

    return new TajoMetaDataResultSet(
        Arrays.asList("TABLE_CAT"),
View Full Code Here

  @Override
  public ResultSet getTableTypes() throws SQLException {
    List<MetaDataTuple> columns = new ArrayList<MetaDataTuple>();
    MetaDataTuple tuple = new MetaDataTuple(2);
    tuple.put(0, new TextDatum("TABLE"));
    columns.add(tuple);

    ResultSet result = new TajoMetaDataResultSet(
        Arrays.asList("TABLE_TYPE")
        , Arrays.asList(Type.VARCHAR)
View Full Code Here

            for (Column column: tableDesc.getLogicalSchema().getColumns()) {
              if (column.getSimpleName().matches(regcolumnNamePattern)) {
                MetaDataTuple tuple = new MetaDataTuple(22);

                int index = 0;
                tuple.put(index++, new TextDatum(databaseName));            // TABLE_CAT
                tuple.put(index++, new TextDatum(DEFAULT_SCHEMA_NAME));     // TABLE_SCHEM
                tuple.put(index++, new TextDatum(table));                   // TABLE_NAME
                tuple.put(index++, new TextDatum(column.getSimpleName()))// COLUMN_NAME
                // TODO - DATA_TYPE
                tuple.put(index++, new TextDatum("" + ResultSetUtil.tajoTypeToSqlType(column.getDataType())));
                tuple.put(index++, new TextDatum(ResultSetUtil.toSqlType(column.getDataType())))//TYPE_NAME
                tuple.put(index++, new TextDatum("0"));                     // COLUMN_SIZE
                tuple.put(index++, new TextDatum("0"));                     // BUFFER_LENGTH
                tuple.put(index++, new TextDatum("0"));                     // DECIMAL_DIGITS
                tuple.put(index++, new TextDatum("0"));                     // NUM_PREC_RADIX
                tuple.put(index++, new TextDatum("" + DatabaseMetaData.columnNullable))// NULLABLE
                tuple.put(index++, NullDatum.get());                        // REMARKS
                tuple.put(index++, NullDatum.get());                        // COLUMN_DEF
                tuple.put(index++, NullDatum.get());                        // SQL_DATA_TYPE
                tuple.put(index++, NullDatum.get());                        // SQL_DATETIME_SUB
                tuple.put(index++, new TextDatum("0"));                     // CHAR_OCTET_LENGTH
                tuple.put(index++, new TextDatum("" + pos));                // ORDINAL_POSITION
                tuple.put(index++, new TextDatum("YES"));                   // IS_NULLABLE
                tuple.put(index++, NullDatum.get());                        // SCOPE_CATLOG
                tuple.put(index++, NullDatum.get());                        // SCOPE_SCHEMA
                tuple.put(index++, NullDatum.get());                        // SCOPE_TABLE
                tuple.put(index++, new TextDatum("0"));                     // SOURCE_DATA_TYPE
                columns.add(tuple);
              }
              pos++;
            }
          }
View Full Code Here

    } catch (ServiceException e) {
      throw new SQLException(e);
    }

    MetaDataTuple tuple = new MetaDataTuple(2);
    tuple.put(0, new TextDatum(DEFAULT_SCHEMA_NAME));
    tuple.put(1, new TextDatum(databaseName));

    return new TajoMetaDataResultSet(
        Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG"),
        Arrays.asList(Type.VARCHAR, Type.VARCHAR),
        Arrays.asList(tuple));
View Full Code Here

  public void testTupleCcaheBasicFunction() throws Exception {
    List<Tuple> tupleData = new ArrayList<Tuple>();
    for (int i = 0; i < 100; i++) {
      Datum[] datums = new Datum[5];
      for (int j = 0; j < 5; j++) {
        datums[j] = new TextDatum(i + "_" + j);
      }
      Tuple tuple = new VTuple(datums);
      tupleData.add(tuple);
    }
View Full Code Here

  public Datum eval(Tuple params) {
    Datum valueDatum = params.get(0);
    if (valueDatum instanceof NullDatum) {
      return NullDatum.get();
    }
    return new TextDatum(GeoIPUtil.getCountryCode(params.get(0).asChars()));
  }
View Full Code Here

TOP

Related Classes of org.apache.tajo.datum.TextDatum

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.