コード例 #1
0
 @Override
 public void key(String key) throws IOException {
   DataSchema newSchema = null;
   if (_currentSchema != null) {
     switch (_currentSchema.getType()) {
       case RECORD:
         RecordDataSchema recordSchema = (RecordDataSchema) _currentSchema;
         RecordDataSchema.Field field = recordSchema.getField(key);
         if (field != null) {
           newSchema = field.getType();
         }
         break;
       case UNION:
         UnionDataSchema unionSchema = (UnionDataSchema) _currentSchema;
         newSchema = unionSchema.getType(key);
         break;
       case MAP:
         MapDataSchema mapSchema = (MapDataSchema) _currentSchema;
         newSchema = mapSchema.getValues();
         break;
     }
   }
   _pendingSchema = newSchema;
   super.key(key);
 }
コード例 #2
0
ファイル: SnapshotGenerator.java プロジェクト: h87kg/rest.li
  private void recordType(
      DataSchema schema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
    if (schema instanceof NamedDataSchema) {
      NamedDataSchema namedDataSchema = (NamedDataSchema) schema;

      if (!foundTypes.containsKey(namedDataSchema.getFullName())) {
        foundTypes.put(namedDataSchema.getFullName(), namedDataSchema);

        if (schema instanceof RecordDataSchema) // recurse into record, record any contained types.
        {
          RecordDataSchema recordDataSchema = (RecordDataSchema) schema;
          for (RecordDataSchema.Field field : recordDataSchema.getFields()) {
            recordType(field.getType(), foundTypes, typeOrder);
          }
        }

        typeOrder.add(namedDataSchema);
      }
    } else if (schema instanceof ArrayDataSchema) {
      ArrayDataSchema arraySchema = (ArrayDataSchema) schema;
      recordType(arraySchema.getItems(), foundTypes, typeOrder);
    } else if (schema instanceof MapDataSchema) {
      MapDataSchema mapSchema = (MapDataSchema) schema;
      recordType(mapSchema.getValues(), foundTypes, typeOrder);
    } else if (schema instanceof UnionDataSchema) {
      UnionDataSchema unionSchema = (UnionDataSchema) schema;
      for (DataSchema type : unionSchema.getTypes()) {
        recordType(type, foundTypes, typeOrder);
      }
    }
  }
コード例 #3
0
 private void checkMap(MapDataSchema older, MapDataSchema newer) {
   _path.addLast(DataSchemaConstants.VALUES_KEY);
   check(older.getValues(), newer.getValues());
   _path.removeLast();
 }