Package org.kitesdk.data

Examples of org.kitesdk.data.ValidationException


  @Override
  public CharSequence deserializeKeyAsColumnKeyFromBytes(String fieldName,
      byte[] columnKeyBytes) {
    Field field = avroSchema.getAvroSchema().getField(fieldName);
    if (field == null) {
      throw new ValidationException("Invalid field name " + fieldName
          + " for schema " + avroSchema.toString());
    }

    Schema.Type schemaType = field.schema().getType();
    if (schemaType == Schema.Type.MAP) {
      String stringProp = field.schema().getProp("avro.java.string");
      if (stringProp != null && stringProp.equals("String")) {
        return new String(columnKeyBytes);
      } else {
        return new Utf8(columnKeyBytes);
      }
    } else if (schemaType == Schema.Type.RECORD) {
      return new String(columnKeyBytes);
    } else {
      throw new ValidationException("Unsupported type for keyAsColumn: "
          + schemaType);
    }
  }
View Full Code Here


      serializeKeyAsColumn(fieldName, fieldMapping.getFamily(),
          fieldMapping.getPrefix(), fieldValue, put);
    } else if (fieldMapping.getMappingType() == MappingType.OCC_VERSION) {
      serializeOCCColumn(fieldValue, putAction);
    } else {
      throw new ValidationException(
          "Invalid field mapping for field with name: "
              + fieldMapping.getFieldName());
    }
    return putAction;
  }
View Full Code Here

      return deserializeKeyAsColumn(fieldMapping.getFieldName(),
          fieldMapping.getFamily(), fieldMapping.getPrefix(), result);
    } else if (mappingType == MappingType.OCC_VERSION) {
      return deserializeOCCColumn(result);
    } else {
      throw new ValidationException(
          "Invalid field mapping for field with name: " + fieldName);
    }
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    JsonNode avroRecordSchemaJson;
    try {
      avroRecordSchemaJson = mapper.readValue(rawSchema, JsonNode.class);
    } catch (IOException e) {
      throw new ValidationException(
          "Could not parse the avro record as JSON.", e);
    }
    return avroRecordSchemaJson;
  }
View Full Code Here

      List<String> entitySchemas = entry.getValue();
      if (entitySchemas.size() == 0) {
        String msg = "Table requested, but no entity schemas for Table: "
            + table;
        LOG.error(msg);
        throw new ValidationException(msg);
      }
      for (String entitySchema : entry.getValue()) {
        createOrMigrateSchema(table, entitySchema, createTableAndFamilies);
      }
    }
View Full Code Here

      if (!keySchema.equals(currentKeySchema)) {
        String msg = "Migrating schema with different keys. Current: "
            + currentKeySchema.getRawSchema() + " New: "
            + keySchema.getRawSchema();
        LOG.error(msg);
        throw new ValidationException(msg);
      }
      if (!schemaManager.hasSchemaVersion(tableName, entityName, entitySchema)) {
        LOG.info("Migrating Schema: (" + tableName + ", " + entityName + ")");
        schemaManager.migrateSchema(tableName, entityName, entitySchemaString);
      } else {
View Full Code Here

          .hasNext();) {
        result.add(it.next().getTextValue());
      }
      return result;
    } catch (JsonParseException e) {
      throw new ValidationException(e);
    } catch (IOException e) {
      throw new ValidationException(e);
    }
  }
View Full Code Here

      if (node.get("name") == null) {
        return null;
      }
      return node.get("name").getTextValue();
    } catch (JsonParseException e) {
      throw new ValidationException(e);
    } catch (IOException e) {
      throw new ValidationException(e);
    }
  }
View Full Code Here

      ValidationException.check(qualifier != null && !qualifier.isEmpty(),
          "Counter mapping %s must have a %s", source, QUALIFIER);
      return FieldMapping.counter(source, family, qualifier);

    } else {
      throw new ValidationException("Invalid mapping type: " + type);
    }
  }
View Full Code Here

        break;
      case OCC_VERSION:
        fieldMapping.set(TYPE, TextNode.valueOf("occVersion"));
        break;
      default:
        throw new ValidationException(
            "Unknown mapping type: " + fm.getMappingType());
    }
    return fieldMapping;
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.data.ValidationException

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.