Examples of StockPriceWritable


Examples of com.manning.hip.ch3.StockPriceWritable

  @Override
  protected void map(LongWritable key, Text value,
                     Context context)
      throws IOException, InterruptedException {

    StockPriceWritable stock =
        StockPriceWritable.fromLine(value.toString());

    byte[] rowkey = Bytes.add(
        Bytes.toBytes(stock.getSymbol()),
        Bytes.toBytes(stock.getDate()));

    Put put = new Put(rowkey);

    byte[] colValue = Bytes.toBytes(stock.getClose());
    put.add(STOCK_DETAILS_COLUMN_FAMILY_AS_BYTES,
        STOCK_COLUMN_QUALIFIER_AS_BYTES,
        colValue
    );
    context.write(stock, put);
View Full Code Here

Examples of com.manning.hip.ch3.StockPriceWritable

      return null;
    }
    if (!(value instanceof StockPriceWritable)) {
      return null;
    }
    StockPriceWritable w = (StockPriceWritable) value;

    return TupleFactory.getInstance().newTuple(Arrays.asList(
        w.getSymbol(), w.getDate(), w.getOpen(),
        w.getHigh(), w.getLow(), w.getClose(),
        w.getVolume(), w.getAdjClose()
    ));
  }
View Full Code Here

Examples of com.manning.hip.ch3.StockPriceWritable

            new DefaultCodec());
    try {
      Text key = new Text();

      for (String line : FileUtils.readLines(inputFile)) {   //<co id="ch03_comment_seqfile_write2"/>
        StockPriceWritable stock = StockPriceWritable.fromLine(line);
        key.set(stock.getSymbol());

        key.set(stock.getSymbol());
        writer.append(key,
            stock);        //<co id="ch03_comment_seqfile_write4"/>
      }
    } finally {
      writer.close();
View Full Code Here

Examples of com.manning.hip.ch3.StockPriceWritable

    }
  }

  public Object deserialize(Writable field) throws SerDeException {
    if (field instanceof StockPriceWritable) {
      StockPriceWritable stock = (StockPriceWritable) field;
      row.set(0, stock.getSymbol());
      row.set(1, stock.getDate());
      row.set(2, stock.getOpen());
      row.set(3, stock.getHigh());
      row.set(4, stock.getLow());
      row.set(5, stock.getClose());
      row.set(6, stock.getVolume());
      row.set(7, stock.getAdjClose());
      return row;
    }
      throw new SerDeException(this.getClass().getName()
          + " unexpected Writable type " + field.getClass().getName());
  }
View Full Code Here

Examples of com.manning.hip.ch3.StockPriceWritable

    try {
      System.out.println(
          "Is block compressed = " + reader.isBlockCompressed());

      Text key = new Text();
      StockPriceWritable value = new StockPriceWritable();

      while (reader.next(key, value)) {   //<co id="ch03_comment_seqfile_read2"/>
        System.out.println(key + "," + value);
      }
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.