Package org.kitesdk.data

Examples of org.kitesdk.data.FieldMapping


  }

  public SingleFieldEntityFilter(EntitySchema entitySchema,
      EntitySerDe<?> entitySerDe, String fieldName, Object filterValue,
      CompareFilter.CompareOp equalityOperator) {
    FieldMapping fieldMapping = entitySchema.getColumnMappingDescriptor()
        .getFieldMapping(fieldName);
    if (fieldMapping.getMappingType() != MappingType.COLUMN) {
      throw new DatasetException(
          "SingleColumnValueFilter only compatible with COLUMN mapping types.");
    }

    byte[] family = fieldMapping.getFamily();
    byte[] qualifier = fieldMapping.getQualifier();
    byte[] comparisonBytes = entitySerDe.serializeColumnValueToBytes(fieldName,
        filterValue);

    this.filter = new SingleColumnValueFilter(family, qualifier,
        equalityOperator, comparisonBytes);
View Full Code Here


   */
  private static boolean mappingCompatible(EntitySchema oldSchema,
      EntitySchema newSchema) {
    for (FieldMapping oldFieldMapping : oldSchema.getColumnMappingDescriptor()
        .getFieldMappings()) {
      FieldMapping newFieldMapping = newSchema.getColumnMappingDescriptor()
          .getFieldMapping(oldFieldMapping.getFieldName());
      if (newFieldMapping != null) {
        if (!oldFieldMapping.equals(newFieldMapping)) {
          return false;
        }
View Full Code Here

  private final Filter filter;

  public RegexEntityFilter(EntitySchema entitySchema,
      EntitySerDe<?> entitySerDe, String fieldName, String regex,
      boolean isEqual) {
    FieldMapping fieldMapping = entitySchema.getColumnMappingDescriptor()
        .getFieldMapping(fieldName);
    if (fieldMapping.getMappingType() != MappingType.COLUMN) {
      throw new DatasetException(
          "SingleColumnValueFilter only compatible with COLUMN mapping types.");
    }

    this.filter = constructFilter(regex, isEqual, fieldMapping);
View Full Code Here

      for (Schema.Field field : schema.getFields()) {
        if (field.getJsonProp(MAPPING) != null) {
          // parse the String because Avro uses com.codehaus.jackson
          JsonNode mappingNode = JsonUtil.parse(
              field.getJsonProp(MAPPING).toString());
          FieldMapping fm = parseFieldMapping(field.name(), mappingNode);
          if (FieldMapping.MappingType.KEY == fm.getMappingType() &&
              mappingNode.has(VALUE)) {
            Integer index = mappingNode.get(VALUE).asInt();
            keyMappings.put(index, fm);
          }
        }
View Full Code Here

  }

  @Override
  public Increment mapToIncrement(PartitionKey key, String fieldName,
      long amount) {
    FieldMapping fieldMapping = entitySchema.getColumnMappingDescriptor()
        .getFieldMapping(fieldName);
    if (fieldMapping == null) {
      throw new DatasetException("Unknown field in the schema: "
          + fieldName);
    }
    if (fieldMapping.getMappingType() != MappingType.COUNTER) {
      throw new DatasetException("Field is not a counter type: "
          + fieldName);
    }

    byte[] keyBytes;
    if (keySerDe == null) {
      keyBytes = new byte[] { (byte) 0 };
    } else {
      keyBytes = keySerDe.serialize(key);
    }
    Increment increment = new Increment(keyBytes);
    increment.addColumn(fieldMapping.getFamily(), fieldMapping.getQualifier(),
        amount);
    return increment;
  }
View Full Code Here

    return increment;
  }

  @Override
  public long mapFromIncrementResult(Result result, String fieldName) {
    FieldMapping fieldMapping = entitySchema.getColumnMappingDescriptor()
        .getFieldMapping(fieldName);
    if (fieldMapping == null) {
      throw new DatasetException("Unknown field in the schema: "
          + fieldName);
    }
    if (fieldMapping.getMappingType() != MappingType.COUNTER) {
      throw new DatasetException("Field is not a counter type: "
          + fieldName);
    }
    return (Long) entitySerDe.deserialize(fieldMapping, result);
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.data.FieldMapping

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.