Package com.cloudera.flume.conf.avro

Examples of com.cloudera.flume.conf.avro.AvroFlumeChokeMap


   * Converts a ChokeMap into an Avro-serialized byte array
   */
  static protected byte[] serializeChokeMap(
      Map<String, Map<String, Integer>> chokeMap) throws IOException {
    DatumWriter<AvroFlumeChokeMap> datumWriter = new SpecificDatumWriter<AvroFlumeChokeMap>();
    AvroFlumeChokeMap avromap = new AvroFlumeChokeMap();

    Map<CharSequence, Map<CharSequence, Integer>> map = new HashMap<CharSequence, Map<CharSequence, Integer>>();

    for (Entry<String, Map<String, Integer>> e : chokeMap.entrySet()) {
      String name = e.getKey();

      HashMap<CharSequence, Integer> tempMap = new HashMap<CharSequence, Integer>();

      for (Entry<String, Integer> mape : e.getValue().entrySet()) {
        tempMap.put(new String(mape.getKey()), mape.getValue());
      }

      map.put(name, tempMap);
    }

    avromap.chokemap = map;

    datumWriter.setSchema(avromap.getSchema());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataFileWriter<AvroFlumeChokeMap> fileWriter = new DataFileWriter<AvroFlumeChokeMap>(
        datumWriter);
    fileWriter.create(avromap.getSchema(), baos);
    fileWriter.append(avromap);
    fileWriter.close();

    return baos.toByteArray();
  }
View Full Code Here


  static protected Map<String, Map<String, Integer>> deserializeChokeMap(
      byte[] data) throws IOException {
    SpecificDatumReader<AvroFlumeChokeMap> reader = new SpecificDatumReader<AvroFlumeChokeMap>();
    DataFileStream<AvroFlumeChokeMap> fileStream = new DataFileStream<AvroFlumeChokeMap>(
        new ByteArrayInputStream(data), reader);
    AvroFlumeChokeMap chkmap = fileStream.next();
    fileStream.close();
    Map<String, Map<String, Integer>> ret = new HashMap<String, Map<String, Integer>>();

    for (Entry<CharSequence, Map<CharSequence, Integer>> e : chkmap.chokemap
        .entrySet()) {
View Full Code Here

   * Converts a ChokeMap into an Avro-serialized byte array
   */
  static protected byte[] serializeChokeMap(
      Map<String, Map<String, Integer>> chokeMap) throws IOException {
    DatumWriter<AvroFlumeChokeMap> datumWriter = new SpecificDatumWriter<AvroFlumeChokeMap>();
    AvroFlumeChokeMap avromap = new AvroFlumeChokeMap();

    Map<CharSequence, Map<CharSequence, Integer>> map = new HashMap<CharSequence, Map<CharSequence, Integer>>();

    for (Entry<String, Map<String, Integer>> e : chokeMap.entrySet()) {
      String name = e.getKey();

      HashMap<CharSequence, Integer> tempMap = new HashMap<CharSequence, Integer>();

      for (Entry<String, Integer> mape : e.getValue().entrySet()) {
        tempMap.put(new String(mape.getKey()), mape.getValue());
      }

      map.put(name, tempMap);
    }

    avromap.chokemap = map;

    datumWriter.setSchema(avromap.getSchema());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataFileWriter<AvroFlumeChokeMap> fileWriter = new DataFileWriter<AvroFlumeChokeMap>(
        datumWriter);
    fileWriter.create(avromap.getSchema(), baos);
    fileWriter.append(avromap);
    fileWriter.close();

    return baos.toByteArray();
  }
View Full Code Here

  static protected Map<String, Map<String, Integer>> deserializeChokeMap(
      byte[] data) throws IOException {
    SpecificDatumReader<AvroFlumeChokeMap> reader = new SpecificDatumReader<AvroFlumeChokeMap>();
    DataFileStream<AvroFlumeChokeMap> fileStream = new DataFileStream<AvroFlumeChokeMap>(
        new ByteArrayInputStream(data), reader);
    AvroFlumeChokeMap chkmap = fileStream.next();
    fileStream.close();
    Map<String, Map<String, Integer>> ret = new HashMap<String, Map<String, Integer>>();

    for (Entry<CharSequence, Map<CharSequence, Integer>> e : chkmap.chokemap
        .entrySet()) {
View Full Code Here

TOP

Related Classes of com.cloudera.flume.conf.avro.AvroFlumeChokeMap

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.