Package com.cloudera.cdk.morphline.api

Examples of com.cloudera.cdk.morphline.api.Record


        if (!next) {
          break;
        }

        incrementNumRecords();
        Record outputRecord = record.copy();       
        BytesRefArrayWritable rowBatchBytes = new BytesRefArrayWritable();
        rowBatchBytes.resetValid(columns.size());
        reader.getCurrentRow(rowBatchBytes);

        // Read all the columns configured and set it in the output record
        for (RCFileColumn rcColumn : columns) {
          BytesRefWritable columnBytes = rowBatchBytes.get(rcColumn.getInputField());
          outputRecord.put(rcColumn.getOutputField(), updateColumnValue(rcColumn, columnBytes));
        }
       
        // pass record to next command in chain:
        if (!getChild().process(outputRecord)) {
          return false;
View Full Code Here


          }

          BytesRefArrayWritable rowBatchBytes = reader.getColumn(rcColumn.getInputField(), null);
          for (int rowIndex = 0; rowIndex < rowBatchBytes.size(); rowIndex++) {
            incrementNumRecords();
            Record outputRecord = record.copy();
            BytesRefWritable rowBytes = rowBatchBytes.get(rowIndex);
            outputRecord.put(rcColumn.getOutputField(), updateColumnValue(rcColumn, rowBytes));
           
            // pass record to next command in chain:
            if (!getChild().process(outputRecord)) {
              return false;
            }
View Full Code Here

  @Test
  public void testIPv4() throws Exception {
    morphline = createMorphline("test-morphlines/geoIP");   
   
    Record record = new Record();
    String ip = "128.101.101.101";
    record.put("ip", ip);
    Record expected = new Record();
    expected.put("ip", ip);
    expected.put("/country/iso_code", "US");
    expected.put("/country/names/en", "United States");
    expected.put("/country/names/zh-CN", "美国");
    expected.put("/subdivisions[]/names/en", "Minnesota");
    expected.put("/subdivisions[]/iso_code", "MN");
    expected.put("/city/names/en", "Minneapolis");
    expected.put("/postal/code", "55455");
    expected.put("/location/latitude", 44.9733);
    expected.put("/location/longitude", -93.2323);
    expected.put("/location/latitude_longitude", "44.9733,-93.2323");
    expected.put("/location/longitude_latitude", "-93.2323,44.9733");
   
    processAndVerifySuccess(record, expected, false);
    Notifications.notifyShutdown(morphline);
    Notifications.notifyShutdown(morphline);
  }
View Full Code Here

        }
      }
     
      SolrInputDocument doc = handler.newDocument();
      LOG.debug("solr doc: {}", doc);     
      Record outputRecord = toRecord(doc);
      return getChild().process(outputRecord);
    }
View Full Code Here

          + factoryClass.getName(), config, e);
      }
    }

    private Record toRecord(SolrInputDocument doc) {
      Record record = new Record();
      for (Entry<String, SolrInputField> entry : doc.entrySet()) {
        record.getFields().putAll(entry.getKey(), entry.getValue().getValues());       
      }
      return record;
    }
View Full Code Here

 
  @Test
  public void testIPv6() throws Exception {
    morphline = createMorphline("test-morphlines/geoIP");   
   
    Record record = new Record();
    String ip = "2001:620::1";
    record.put("ip", ip);
    Record expected = new Record();
    expected.put("ip", ip);
    expected.put("/country/iso_code", "CH");
    expected.put("/country/names/en", "Switzerland");
    expected.put("/country/names/zh-CN", "瑞士");
    expected.put("/location/latitude", 47.00016);
    expected.put("/location/longitude", 8.01427);
    expected.put("/location/latitude_longitude", "47.00016,8.01427");
    expected.put("/location/longitude_latitude", "8.01427,47.00016");
   
    processAndVerifySuccess(record, expected, false);
    Notifications.notifyShutdown(morphline);
    Notifications.notifyShutdown(morphline);
  }
View Full Code Here

   
    long start = System.currentTimeMillis();
    long duration = durationSecs * 1000;
    int iters = 0;
    while (System.currentTimeMillis() < start + duration) {
      Record record = new Record();
      String msg = "128.101.101.101";
      record.put("ip", msg);
      collector.reset();
      startSession();
      assertEquals(1, collector.getNumStartEvents());
      assertTrue(morphline.process(record));   
      iters++;
View Full Code Here

      List attachments = record.get(Fields.ATTACHMENT_BODY);
      List mimeTypes = record.get(Fields.ATTACHMENT_MIME_TYPE);
      List charsets = record.get(Fields.ATTACHMENT_CHARSET);
      List names = record.get(Fields.ATTACHMENT_NAME);
      for (int i = 0; i < attachments.size(); i++) {
        Record outputRecord = record.copy();       
        outputRecord.getFields().replaceValues(Fields.ATTACHMENT_BODY, Collections.singletonList(attachments.get(i)));
       
        List replacement;
        replacement = i < mimeTypes.size() ? Collections.singletonList(mimeTypes.get(i)) : Collections.EMPTY_LIST;
        outputRecord.getFields().replaceValues(Fields.ATTACHMENT_MIME_TYPE, replacement);
       
        replacement = i < charsets.size() ? Collections.singletonList(charsets.get(i)) : Collections.EMPTY_LIST;
        outputRecord.getFields().replaceValues(Fields.ATTACHMENT_CHARSET, replacement);
       
        replacement = i < names.size() ? Collections.singletonList(names.get(i)) : Collections.EMPTY_LIST;
        outputRecord.getFields().replaceValues(Fields.ATTACHMENT_NAME, replacement);
       
        // pass record to next command in chain:
        if (!super.doProcess(outputRecord)) {
          return false;
        }
View Full Code Here

  @Test
  public void testBasic() throws Exception {
    morphline = createMorphline("test-morphlines/startReportingMetricsToHTTP");   
   
    Record record = new Record();
    String msg = "foo";
    record.put(Fields.MESSAGE, msg);
    Record expected = new Record();
    expected.put(Fields.MESSAGE, msg);
    processAndVerifySuccess(record, expected);

    if ("true".equals(System.getProperty("HttpMetricsMorphlineTest.isDemo"))) {
      // wait forever so user can browse to http://localhost:8080/ and interactively explore the features
      Thread.sleep(Long.MAX_VALUE);
View Full Code Here

  public void doTest() throws Exception {
   
    waitForRecoveriesToFinish(false);
   
    morphline = parse("test-morphlines/loadSolrBasic");   
    Record record = new Record();
    record.put(Fields.ID, "id0-innsbruck");
    record.put("text", "mytext");
    record.put("user_screen_name", "foo");
    record.put("first_name", "Nadja"); // will be sanitized
    startSession();
    assertEquals(1, collector.getNumStartEvents());
    Notifications.notifyBeginTransaction(morphline);
    assertTrue(morphline.process(record));
   
    record = new Record();
    record.put(Fields.ID, "id1-innsbruck");
    record.put("text", "mytext1");
    record.put("user_screen_name", "foo1");
    record.put("first_name", "Nadja1"); // will be sanitized
    assertTrue(morphline.process(record));
   
    Record expected = new Record();
    expected.put(Fields.ID, "id0-innsbruck");
    expected.put("text", "mytext");
    expected.put("user_screen_name", "foo");
    Iterator<Record> citer = collector.getRecords().iterator();
    assertEquals(expected, citer.next());
   
    Record expected2 = new Record();
    expected2.put(Fields.ID, "id1-innsbruck");
    expected2.put("text", "mytext1");
    expected2.put("user_screen_name", "foo1");
    assertEquals(expected2, citer.next());
   
    assertFalse(citer.hasNext());
   
    commit();
   
    QueryResponse rsp = cloudClient.query(new SolrQuery("*:*").setRows(100000).addSort(Fields.ID, SolrQuery.ORDER.asc));
    //System.out.println(rsp);
    Iterator<SolrDocument> iter = rsp.getResults().iterator();
    assertEquals(expected.getFields(), next(iter));
    assertEquals(expected2.getFields(), next(iter));
    assertFalse(iter.hasNext());
   
    Notifications.notifyRollbackTransaction(morphline);
    Notifications.notifyShutdown(morphline);
    cloudClient.shutdown();
View Full Code Here

TOP

Related Classes of com.cloudera.cdk.morphline.api.Record

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.