Package com.datasalt.pangool.io

Examples of com.datasalt.pangool.io.Schema


    // Configure schema, sort and group by
    List<Field> fields = new ArrayList<Field>();
    fields.add(Field.create("first",Type.INT));
    fields.add(Field.create("second",Type.INT));
   
    return new Schema("my_schema",fields);   
  }
View Full Code Here


  }

  private static Schema getPangoolRetweetSchema() {
    Field userId = Field.create("username", Schema.Field.Type.STRING);
    Field tweetId = Field.create("tweet_id", Schema.Field.Type.INT);
    return new Schema("retweet", Arrays.asList(userId, tweetId));
  }
View Full Code Here

    super("Usage: AvroTopicalWordCount [input_path] [output_path]");
  }

  static Schema getSchema() {
    Field avroField = Fields.createAvroField("my_avro",getAvroSchema(),false);
    return new Schema("schema",Arrays.asList(avroField));
  }
View Full Code Here

    List<Field> fields = new ArrayList<Field>();
    // The schema has 3 fields: word, topicId and count
    fields.add(Field.create("word", Type.STRING));
    fields.add(Field.create("topic", Type.INT));
    fields.add(Field.create("count", Type.INT));
    return new Schema("schema", fields);
  }
View Full Code Here

    final int maxY = conf.getInt("gol.max_y", 32);
    final int iterations = conf.getInt("gol.iterations", 1000);
    Log.info("using parameters: maxX grid: " + maxX + " maxY grid: " + maxY + " max #iterations: " + iterations);
   
    // Define the intermediate schema: a pair of ints
    final Schema schema = new Schema("minMax", Fields.parse("min:int, max:int"));

    TupleMRBuilder job = new TupleMRBuilder(conf);
    job.addIntermediateSchema(schema);
    job.setGroupByFields("min", "max");
    job.setCustomPartitionFields("min");
View Full Code Here

  static Schema getURLRegisterSchema() {
    List<Field> urlRegisterFields = new ArrayList<Field>();
    urlRegisterFields.add(Field.create("url",Type.STRING));
    urlRegisterFields.add(Field.create("timestamp",Type.LONG));
    urlRegisterFields.add(Field.create("ip",Type.STRING));
    return new Schema("urlRegister", urlRegisterFields);   
  }
View Full Code Here

  static Schema getURLMapSchema() {
    List<Field> urlMapFields = new ArrayList<Field>();
    urlMapFields.add(Field.create("nonCanonicalUrl",Type.STRING));
    urlMapFields.add(Field.create("canonicalUrl",Type.STRING));
    return new Schema("urlMap", urlMapFields);
  }
View Full Code Here

  static Schema getSchema() {
    org.apache.avro.Schema avroSchema = getAvroSchema();
    Field avroField = Field.createObject("my_avro",AvroFieldSerializer.class,AvroFieldDeserializer.class);
    avroField.addProp("avro.schema",avroSchema.toString());
    return new Schema("schema",Arrays.asList(avroField));
  }
View Full Code Here

      this.input = new DataInputStream(input);
    }
  }

  public void readFields(ITuple tuple, Deserializer[] customDeserializers) throws IOException {
    Schema schema = tuple.getSchema();
    // If there are fields with nulls, read the bit field and set the values that are null
    if (schema.containsNullableFields()) {
      List<Integer> nullableFields = schema.getNullableFieldsIdx();
      nullsAbsolute.ensureSize(schema.getFields().size());
      nullsAbsolute.clear(nullableFields);
      nullsRelative.deser(input);
      for (int i = 0; i < nullableFields.size(); i++) {
        if (nullsRelative.isSet(i)) {
          int field = nullableFields.get(i);
          tuple.set(field, null);
          nullsAbsolute.flags[field] = true;
        }
      }
    }

    // Field by field deseralization
    for(int index = 0; index < schema.getFields().size(); index++) {
      Deserializer customDeser = customDeserializers[index];
      Field field = schema.getField(index);

      // Nulls control
      if (field.isNullable() && nullsAbsolute.flags[index]) {
        // Null field. Nothing to deserialize.
        continue;
View Full Code Here

    }
  }

  @Override
  public void serialize(ITuple tuple) throws IOException {
    Schema schema = (this.schema != null) ? this.schema : tuple.getSchema();
    write(schema, tuple, null, customSerializers);
  }
View Full Code Here

TOP

Related Classes of com.datasalt.pangool.io.Schema

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.