Package com.squareup.cascading2.generated

Examples of com.squareup.cascading2.generated.Example$Person$Builder


  public void testAsGroupByValue() throws Exception {
    FileSystem.get(new Configuration()).delete(new Path("/tmp/input"), true);
    FileSystem.get(new Configuration()).delete(new Path("/tmp/output"), true);

    Tap t = new Hfs(new ProtobufScheme("value", Example.Person.class), "/tmp/input");
    TupleEntryCollector tec = t.openForWrite(new HadoopFlowProcess(new JobConf()));

    HashSet<Tuple> expectedTuples = new HashSet<Tuple>(){{
      add(new Tuple(Example.Person.newBuilder().setName("bryan").setId(1).build()));
      add(new Tuple(Example.Person.newBuilder().setName("lucas").setId(2).build()));
    }};

    for (Tuple tuple : expectedTuples) {
      tec.add(tuple);
    }

    tec.close();

    Pipe inPipe = new Pipe("input");
    Pipe injectedPipe = new Each(inPipe, Fields.NONE, new Insert(new Fields("key"), 7), new Fields("key", "value"));
    Pipe groupByPipe = new GroupBy(injectedPipe, new Fields("key"));

    Hfs sink = new Hfs(new ProtobufScheme("value", Example.Person.class), "/tmp/output");
    Map<Object, Object> properties = new HashMap<Object, Object>(){{
      put("io.serializations", new JobConf().get("io.serializations") + "," + ProtobufSerialization.class.getName());
    }};
    new HadoopFlowConnector(properties).connect(t, sink, groupByPipe).complete();
View Full Code Here


  public void testAsGroupByKey() throws Exception {
    FileSystem.get(new Configuration()).delete(new Path("/tmp/input"), true);
    FileSystem.get(new Configuration()).delete(new Path("/tmp/output"), true);

    Tap t = new Hfs(new ProtobufScheme("value", Example.Person.class), "/tmp/input");
    TupleEntryCollector tec = t.openForWrite(new HadoopFlowProcess(new JobConf()));

    HashSet<Tuple> expectedTuples = new HashSet<Tuple>(){{
      add(new Tuple(Example.Person.newBuilder().setName("bryan").setId(1).build()));
      add(new Tuple(Example.Person.newBuilder().setName("lucas").setId(2).build()));
    }};

    for (Tuple tuple : expectedTuples) {
      tec.add(tuple);
    }

    tec.close();

    Pipe inPipe = new Pipe("input");
    Pipe groupByPipe = new GroupBy(inPipe, new Fields("value"));

    Hfs sink = new Hfs(new ProtobufScheme("value", Example.Person.class), "/tmp/output");
    Map<Object, Object> properties = new HashMap<Object, Object>(){{
      put("io.serializations",
          new JobConf().get("io.serializations") + "," + ProtobufSerialization.class.getName());
    }};
    new HadoopFlowConnector(properties).connect(t, sink, groupByPipe).complete();
View Full Code Here

    Pipe p = new Each("input", new ExtractProto(Example.Partnership.class, "leader.name"));

    final String INPUT_PATH = "/tmp/ExtractProtoTest/input";
    final String OUTPUT_PATH = "/tmp/ExtractProtoTest/output";

    Hfs inputTap = new Hfs(new ProtobufScheme("partnership", Example.Partnership.class),
        INPUT_PATH);
    Hfs outputTap = new Hfs(new ProtobufScheme("leader.name", Example.Partnership.class),
        OUTPUT_PATH);

    // make sure the input path exists
    inputTap.openForWrite(new HadoopFlowProcess()).close();
    // make sure the output path does not exist
View Full Code Here

  public void testInFlow() throws Exception {
    FileSystem.get(new Configuration()).delete(new Path("/tmp/input"), true);
    FileSystem.get(new Configuration()).delete(new Path("/tmp/output"), true);

    Hfs inTap = new Hfs(new ProtobufScheme("value", Example.Person.class), "/tmp/input");
    TupleEntryCollector collector = inTap.openForWrite(new HadoopFlowProcess());
    collector.add(new TupleEntry(new Fields("value"), new Tuple(BRYAN.build())));
    collector.add(new TupleEntry(new Fields("value"), new Tuple(LUCAS.build())));
    collector.close();
View Full Code Here

     * @see Person#getAge()
     */
    @Test
    public void getAllPersonsEligibleToVote() {
        List<Person> potentialVoters =
                new ArrayList<>(asList(new Person("Tom", 24), new Person("Dick", 75), new Person("Harry", 17)));

        int legalAgeOfVoting = 18;
        List<Person> eligibleVoters = VotingRules.eligibleVoters(potentialVoters, legalAgeOfVoting);

        assertThat(eligibleVoters, hasSize(2));
View Full Code Here

   }
  
   public void test1() throws Exception
   {
      MyStateful stateful = (MyStateful) getInitialContext(0).lookup("MyStatefulBean/remote");
      Person p = new Person("Brian");
      stateful.save(p);
      String expected = "Changing SFSB state";
      stateful.setDescription(expected);
      stateful.setUpFailover("once");
      try
View Full Code Here

    public void test_Person_binding() throws IOException, SAXException {
        XMLBinding xmlBinding = new XMLBinding().add(getClass().getResourceAsStream("config5/person-binding-config.xml"));
        xmlBinding.intiailize();

        Person person = xmlBinding.fromXML("<person name='Max' age='50' />", Person.class);
        String xml = xmlBinding.toXML(person);
        XMLUnit.setIgnoreWhitespace(true);
        XMLAssert.assertXMLEqual("<person name='Max' age='50' />", xml);

    }
View Full Code Here

  private static final long serialVersionUID = 1L;

  public HomePage(final PageParameters parameters) {
    super(parameters);

    setDefaultModel(new CompoundPropertyModel<Person>(new Person()));
   
    Form<Void> form = new Form<Void>("form");
   
    form.add(new TextField("name").add(new PropertyValidator()));
    form.add(new TextField("email").add(new PropertyValidator()));
View Full Code Here

  private static Log log = LogFactory.getInstance().getLog("firefly-system");
  public static ApplicationContext xmlApplicationContext = new XmlApplicationContext();

  @Test
  public void testXmlInject() {
    Person person = xmlApplicationContext.getBean("person");
    Assert.assertThat(person.getName(), is("Jack"));
    PersonService personService = xmlApplicationContext
        .getBean("personService");
    List<Object> l = personService.getTestList();
    Assert.assertThat(l.size(), greaterThan(0));
    int i = 0;
    for (Object p : l) {
      if (p instanceof Person) {
        person = (Person) p;
        i++;
        log.debug(person.getName());
      } else if (p instanceof Map) {
        @SuppressWarnings("unchecked")
        Map<Object, Object> map = (Map<Object, Object>)p;
        log.info(map.toString());
        Assert.assertThat(map.entrySet().size(), greaterThan(0));
View Full Code Here

TOP

Related Classes of com.squareup.cascading2.generated.Example$Person$Builder

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.