Example usage for org.apache.hadoop.io LongWritable LongWritable

List of usage examples for org.apache.hadoop.io LongWritable LongWritable

Introduction

In this page you can find the example usage for org.apache.hadoop.io LongWritable LongWritable.

Prototype

public LongWritable(long value) 

Source Link

Usage

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowPEmailNoID_EmailEnrichWithDateAndFileUsed() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p2").setValue("_p", "just@gmail.com");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("km_timestamp", "1397577453")
            .setValue("user_email", "just@gmail.com").setValue("user_email_back", "just@gmail.com")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowNoEmailNoID_DateAndFileUsed() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p").removePair("_p2");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("km_timestamp", "1397577453")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowWithSameTAndMobileDeviceTime_validDates() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p").removePair("_p2").setValue("_server_timestamp", "1397577453")
            .setValue("_c", "mobile_app").setValue("_t", "1397577453");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("filename", "somefile").setValue("event", jsonRowbuilder.getValue("_n"))
            .setValue("km_timestamp", "1397577453").setValue("km_timestamp_mobile", "1397577453")
            .setValue("event_timedate", "2014-04-15 16:57:33")
            .setValue("event_timedate_mobile", "2014-04-15 16:57:33").setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowWithDifferentTAndMobileDeviceTime_validDates() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p").removePair("_p2").setValue("_t", "1397577453")
            .setValue("_server_timestamp", "1397577456").setValue("_c", "mobile_app");

    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("filename", "somefile").setValue("event", jsonRowbuilder.getValue("_n"))
            .setValue("km_timestamp", "1397577456").setValue("km_timestamp_mobile", "1397577453")
            .setValue("event_timedate", "2014-04-15 16:57:36")
            .setValue("event_timedate_mobile", "2014-04-15 16:57:33").setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowWithMobileDeviceTimeNoC_validDate() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p").removePair("_p2").setValue("_t", "1397577453").setValue("_server_timestamp",
            "1397577456");

    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("filename", "somefile").setValue("event", jsonRowbuilder.getValue("_n"))
            .setValue("km_timestamp", "1397577453").setValue("event_timedate", "2014-04-15 16:57:33")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_ValidRowWithNoMobileDeviceTimeAndC_validDate() throws IOException, JSONException {

    jsonRowbuilder.removePair("_p").removePair("_p2").setValue("_c", "mobile_app").setValue("_t", "1397577453");

    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("filename", "somefile").setValue("event", jsonRowbuilder.getValue("_n"))
            .setValue("km_timestamp", "1397577453").setValue("event_timedate", "2014-04-15 16:57:33")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_PoundSignInRow_PoundSignOuputCorrectly() throws IOException, JSONException {
    jsonRowbuilder.setValue("amount_raised", "\302\243121.00");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("user_email", "justgiving@gmail.com")
            .setValue("user_email_back", "justgiving@gmail.com")
            .setValue("user_km_id", "3lwlxqlulqe24q/jl4aqlibrtte=").setValue("km_timestamp", "1397577453")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_AccentEncoding_AccentResolved() throws IOException, JSONException {
    jsonRowbuilder.setValue("title", "R BROWNE is fundraising for M\303\251decins Sans Fronti\303\250res (UK)");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("user_email", "justgiving@gmail.com")
            .setValue("user_email_back", "justgiving@gmail.com")
            .setValue("title", "R BROWNE is fundraising for Mdecins Sans Frontires (UK)")
            .setValue("user_km_id", "3lwlxqlulqe24q/jl4aqlibrtte=").setValue("km_timestamp", "1397577453")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_UserAgentSlashChar_UserAgent() throws IOException, JSONException {
    jsonRowbuilder.setValue("user_agent",
            "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("user_email", "justgiving@gmail.com")
            .setValue("user_email_back", "justgiving@gmail.com")
            .setValue("user_agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0")
            .setValue("user_km_id", "3lwlxqlulqe24q/jl4aqlibrtte=").setValue("km_timestamp", "1397577453")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}

From source file:com.justgiving.raven.kissmetrics.jsonenricher.KissmetricsJsonToEnrichedJsonMapperTest.java

License:Open Source License

@Test
public void mapper_testMapperNonLatinChar_EscapedOutputrow() throws IOException, JSONException {
    jsonRowbuilder.setValue("page_title",
            "\346\215\220\350\264\210\347\265\246sumatranelephantemergency - JustGiving");
    mapDriver.withInput(new LongWritable(1), new Text(jsonRowbuilder.toString()));

    jsonRowbuilder.setValue("event_timedate", "2014-04-15 16:57:33").setValue("filename", "somefile")
            .setValue("event", jsonRowbuilder.getValue("_n")).setValue("user_email", "justgiving@gmail.com")
            .setValue("user_email_back", "justgiving@gmail.com")
            .setValue("page_title", "??sumatranelephantemergency - JustGiving")
            .setValue("user_km_id", "3lwlxqlulqe24q/jl4aqlibrtte=").setValue("km_timestamp", "1397577453")
            .setValue("bucket", "somefile");
    String expectedJSON = jsonRowbuilder.toString();

    List<Pair<Text, Text>> output = mapDriver.run();
    String actualJSON = output.get(0).getSecond().toString();

    JSONAssert.assertEquals(expectedJSON, actualJSON, true);
}