Package com.datasalt.pangool.examples.topnhashtags.Beans

Examples of com.datasalt.pangool.examples.topnhashtags.Beans.SimpleTweet


   
    for(int i = 0; i < nTweets; i++) {
      long date = dates.get((int)(Math.random() * dates.size()));
      String location = locations.get((int)(Math.random() * locations.size()));
      String hashTag = hashTags.get((int)(Math.random() * hashTags.size()));
      SimpleTweet tweet = new SimpleTweet();
      tweet.setCreated_at(SimpleTweet.dateFormat.format(new Date(date)));
      tweet.setEntities(new Entities());
      tweet.getEntities().setHashtags(new ArrayList<HashTag>());
      tweet.getEntities().getHashtags().add(new HashTag());
      tweet.getEntities().getHashtags().get(0).setText(hashTag);
      tweet.setUser(new UserInfo());
      tweet.getUser().setLocation(location);
      writer.write(mapper.writeValueAsString(tweet) + "\n");
    }
   
    writer.close();
  }
View Full Code Here


    @Override
    public void map(LongWritable key, Text value, TupleMRContext context, Collector collector) throws IOException,
        InterruptedException {

      SimpleTweet tweet = jsonMapper.readValue(value.toString(), SimpleTweet.class);
      DateTime dateTime = new DateTime(tweet.getCreated_at_date());
      tuple.set("date", dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
      tuple.set("location", tweet.getUser().getLocation());
      for(HashTag hashTag : tweet.getEntities().getHashtags()) {
        tuple.set("hashtag", hashTag.getText());
        tuple.set("count", 1);
        collector.write(tuple);
      }
    }
View Full Code Here

    @Override
    public void map(LongWritable key, Text value, TupleMRContext context, Collector collector) throws IOException,
        InterruptedException {

      SimpleTweet tweet = jsonMapper.readValue(value.toString(), SimpleTweet.class);
      DateTime dateTime = new DateTime(tweet.getCreated_at_date());
      tuple.set("date", dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
      tuple.set("location", tweet.getUser().getLocation());
      for(HashTag hashTag : tweet.getEntities().getHashtags()) {
        tuple.set("hashtag", hashTag.getText());
        tuple.set("count", 1);
        collector.write(tuple);
      }
    }
View Full Code Here

    @Override
    public void map(LongWritable key, Text value, TupleMRContext context, Collector collector)
        throws IOException, InterruptedException {

      SimpleTweet tweet = jsonMapper.readValue(value.toString(), SimpleTweet.class);
      DateTime dateTime = new DateTime(tweet.getCreated_at_date());
      tuple.set("date",
          dateTime.getYear() + "-" + dateTime.getMonthOfYear() + "-" + dateTime.getDayOfMonth());
      tuple.set("location", tweet.getUser().getLocation());
      for(HashTag hashTag : tweet.getEntities().getHashtags()) {
        tuple.set("hashtag", hashTag.getText());
        tuple.set("count", 1);
        collector.write(tuple);
      }
    }
View Full Code Here

    trash(INPUT, OUTPUT);
  }
 
  public String getTweet(long date, String hashTag, String location) throws ParseException, JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    SimpleTweet tweet = new SimpleTweet();
    tweet.setCreated_at(SimpleTweet.dateFormat.format(new Date(date)));
    tweet.setEntities(new Entities());
    tweet.getEntities().setHashtags(new ArrayList<HashTag>());
    tweet.getEntities().getHashtags().add(new HashTag());
    tweet.getEntities().getHashtags().get(0).setText(hashTag);
    tweet.setUser(new UserInfo());
    tweet.getUser().setLocation(location);
    return mapper.writeValueAsString(tweet);
  }
View Full Code Here

TOP

Related Classes of com.datasalt.pangool.examples.topnhashtags.Beans.SimpleTweet

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.