Package org.apache.hcatalog.data

Examples of org.apache.hcatalog.data.HCatRecord


     */
    protected abstract I getTargetVertexId(HCatRecord record);

    @Override
    public I getCurrentSourceId() throws IOException, InterruptedException {
      HCatRecord record = getRecordReader().getCurrentValue();
      return getSourceVertexId(record);
    }
View Full Code Here


    }

    @Override
    public Edge<I, NullWritable> getCurrentEdge() throws IOException,
        InterruptedException {
      HCatRecord record = getRecordReader().getCurrentValue();
      return EdgeFactory.create(getTargetVertexId(record));
    }
View Full Code Here

    protected abstract Iterable<Edge<I, E>> getEdges(HCatRecord record);

    @Override
    public final Vertex<I, V, E, ?> getCurrentVertex()
      throws IOException, InterruptedException {
      HCatRecord record = getRecordReader().getCurrentValue();
      Vertex<I, V, E, ?> vertex = getConf().createVertex();
      vertex.initialize(getVertexId(record), getVertexValue(record),
          getEdges(record));
      ++recordCount;
      if (log.isInfoEnabled() &&
View Full Code Here

    }

    @Override
    public boolean nextVertex() throws IOException, InterruptedException {
      while (getRecordReader().nextKeyValue()) {
        HCatRecord record = getRecordReader().getCurrentValue();
        if (currentVertexId == null) {
          currentVertexId = getVertexId(record);
        }
        if (currentVertexId.equals(getVertexId(record))) {
          currentEdges.add(EdgeFactory.create(getTargetVertexId(record),
View Full Code Here

    @Override
    public void map(LongWritable key, Text value,
      Context context)
      throws IOException, InterruptedException {
      try {
        HCatRecord rec = recsToLoad.get(writtenRecordCount);
        context.write(null, rec);
        writtenRecordCount++;
      } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
          e.printStackTrace(System.err);
View Full Code Here

    });

    Object expectedVal = null;
    Object actualVal = null;
    for (int i = 0; i < recs.size(); ++i) {
      HCatRecord rec = recs.get(i);
      expectedVal = i;
      actualVal = rec.get("id", schema);
      LOG.info("Validating field: id (expected = "
        + expectedVal + ", actual = " + actualVal + ")");
      HCatalogTestUtils.assertEquals(expectedVal, actualVal);
      expectedVal = "textfield" + i;
      actualVal = rec.get("msg", schema);
      LOG.info("Validating field: msg (expected = "
        + expectedVal + ", actual = " + actualVal + ")");
      HCatalogTestUtils.assertEquals(rec.get("msg", schema), "textfield" + i);
      for (ColumnGenerator col : cols) {
        String name = col.getName().toLowerCase();
        expectedVal = col.getHCatValue(i);
        actualVal = rec.get(name, schema);
        LOG.info("Validating field: " + name + " (expected = "
          + expectedVal + ", actual = " + actualVal + ")");
        HCatalogTestUtils.assertEquals(expectedVal, actualVal);
      }
    }
View Full Code Here

  private final double DOUBLE_CONST = 3.141592654;
  private final String STRING_CONST = "hello world";


  public void testGet() throws Exception {
    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
    assertEquals(INT_CONST, ((Integer)r.get(0)).intValue());
    assertEquals(LONG_CONST, ((Long)r.get(1)).longValue());
    assertEquals(DOUBLE_CONST, ((Double)r.get(2)).doubleValue());
    assertEquals(STRING_CONST, (String)r.get(3));
  }
View Full Code Here

    assertEquals(STRING_CONST, (String)r.get(3));
  }

  public void testGetWithName() throws Exception {
    TypeInfo ti = getTypeInfo();
    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector(ti));
    HCatSchema schema = HCatSchemaUtils.getHCatSchema(ti)
                                          .get(0).getStructSubSchema();
    assertEquals(INT_CONST, ((Integer)r.get("an_int", schema)).intValue());
    assertEquals(LONG_CONST, ((Long)r.get("a_long", schema)).longValue());
    assertEquals(DOUBLE_CONST, ((Double)r.get("a_double", schema)).doubleValue());
    assertEquals(STRING_CONST, (String)r.get("a_string", schema));
  }
View Full Code Here

    assertEquals(DOUBLE_CONST, ((Double)r.get("a_double", schema)).doubleValue());
    assertEquals(STRING_CONST, (String)r.get("a_string", schema));
  }

  public void testGetAll() throws Exception {
    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
    List<Object> list = r.getAll();
    assertEquals(INT_CONST, ((Integer)list.get(0)).intValue());
    assertEquals(LONG_CONST, ((Long)list.get(1)).longValue());
    assertEquals(DOUBLE_CONST, ((Double)list.get(2)).doubleValue());
    assertEquals(STRING_CONST, (String)list.get(3));
  }
View Full Code Here

    assertEquals(DOUBLE_CONST, ((Double)list.get(2)).doubleValue());
    assertEquals(STRING_CONST, (String)list.get(3));
  }

  public void testSet() throws Exception {
    HCatRecord r = new LazyHCatRecord(getHCatRecord(), getObjectInspector());
    boolean sawException = false;
    try {
      r.set(3, "Mary had a little lamb");
    } catch (UnsupportedOperationException uoe) {
      sawException = true;
    }
    assertTrue(sawException);
  }
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.data.HCatRecord

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.