当前位置: 首页>>代码示例>>Java>>正文


Java SchemaParseException类代码示例

本文整理汇总了Java中org.apache.avro.SchemaParseException的典型用法代码示例。如果您正苦于以下问题:Java SchemaParseException类的具体用法?Java SchemaParseException怎么用?Java SchemaParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchemaParseException类属于org.apache.avro包,在下文中一共展示了SchemaParseException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNewSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
private Schema createNewSchema(Schema currentSchema, SchemaField newField) {
    List<Schema.Field> avroFields = currentSchema.getFields().stream()
            .filter(field -> field.schema().getType() != Schema.Type.NULL)
            .map(field -> new Schema.Field(field.name(), field.schema(), field.doc(), field.defaultValue()))
            .collect(toList());
    try {
        avroFields.add(AvroUtil.generateAvroField(newField));
    } catch (SchemaParseException e) {
        throw new RakamException("Couldn't create new column: " + e.getMessage(), BAD_REQUEST);
    }

    conditionalMagicFields.keySet().stream()
            .filter(s -> !avroFields.stream().anyMatch(af -> af.name().equals(s)))
            .map(n -> new Schema.Field(n, Schema.create(NULL), "", null))
            .forEach(x -> avroFields.add(x));

    Schema avroSchema = Schema.createRecord("collection", null, null, false);
    avroSchema.setFields(avroFields);

    return avroSchema;
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:22,代码来源:JsonEventDeserializer.java

示例2: readerWithUnparseableSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
@Test(expected = SchemaParseException.class)
public void readerWithUnparseableSchema() throws Throwable {
    Map<String, Object> cfg = new HashMap<String, Object>() {{
        put(ParquetFileReader.FILE_READER_PARQUET_SCHEMA, "invalid schema");
        put(AgnosticFileReader.FILE_READER_AGNOSTIC_EXTENSIONS_PARQUET, getFileExtension());
    }};
    getReader(FileSystem.newInstance(fsUri, new Configuration()), dataFile, cfg);
}
 
开发者ID:mmolimar,项目名称:kafka-connect-fs,代码行数:9,代码来源:ParquetFileReaderTest.java

示例3: readerWithUnparseableSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
@Test(expected = SchemaParseException.class)
public void readerWithUnparseableSchema() throws Throwable {
    Map<String, Object> cfg = new HashMap<String, Object>() {{
        put(AvroFileReader.FILE_READER_AVRO_SCHEMA, "invalid schema");
        put(AgnosticFileReader.FILE_READER_AGNOSTIC_EXTENSIONS_AVRO, getFileExtension());
    }};
    getReader(fs, dataFile, cfg);
}
 
开发者ID:mmolimar,项目名称:kafka-connect-fs,代码行数:9,代码来源:AvroFileReaderTest.java

示例4: readerWithUnparseableSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
@Test(expected = SchemaParseException.class)
public void readerWithUnparseableSchema() throws Throwable {
    Map<String, Object> cfg = new HashMap<String, Object>() {{
        put(ParquetFileReader.FILE_READER_PARQUET_SCHEMA, "invalid schema");
    }};
    getReader(FileSystem.newInstance(fsUri, new Configuration()), dataFile, cfg);
}
 
开发者ID:mmolimar,项目名称:kafka-connect-fs,代码行数:8,代码来源:ParquetFileReaderTest.java

示例5: readerWithUnparseableSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
@Test(expected = SchemaParseException.class)
public void readerWithUnparseableSchema() throws Throwable {
    Map<String, Object> cfg = new HashMap<String, Object>() {{
        put(AvroFileReader.FILE_READER_AVRO_SCHEMA, "invalid schema");
    }};
    getReader(fs, dataFile, cfg);
}
 
开发者ID:mmolimar,项目名称:kafka-connect-fs,代码行数:8,代码来源:AvroFileReaderTest.java

示例6: parseSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
private static Schema parseSchema(String schemaString) {
  try {
    Schema.Parser parser1 = new Schema.Parser();
    Schema schema = parser1.parse(schemaString);
    return schema;
  } catch (SchemaParseException e) {
    return null;
  }
}
 
开发者ID:HotelsDotCom,项目名称:avro-compatibility,代码行数:10,代码来源:CompatibilityTest.java

示例7: parseSchema

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
public static Schema parseSchema(String schemaString) {
	try {
		Schema.Parser parser1 = new Schema.Parser();
		return parser1.parse(schemaString);
	} catch (SchemaParseException e) {
		return null;
	}
}
 
开发者ID:Comcast,项目名称:pipeclamp,代码行数:9,代码来源:AvroUtil.java

示例8: schemaBackwardCompatibility

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
public SchemaCompatiblityCheck schemaBackwardCompatibility(SchemaDTO schemaDto) {

    String schemaContent = schemaDto.getContents();

    SchemaCompatibility.SchemaPairCompatibility schemaCompatibility;
    Schema writer;

    TypedQuery<SchemaTopics> query = em.createNamedQuery(
        "SchemaTopics.findByName", SchemaTopics.class);
    query.setParameter("name", schemaDto.getName());

    try {
      Schema reader = new Schema.Parser().parse(schemaContent);

      for (SchemaTopics schemaTopic : query.getResultList()) {

        writer = new Schema.Parser().parse(schemaTopic.getContents());

        schemaCompatibility = SchemaCompatibility.
            checkReaderWriterCompatibility(reader, writer);

        switch (schemaCompatibility.getType()) {

          case COMPATIBLE:
            break;
          case INCOMPATIBLE:
            return SchemaCompatiblityCheck.INCOMPATIBLE;
          case RECURSION_IN_PROGRESS:
            break;
        }
      }
    } catch (SchemaParseException ex) {
      return SchemaCompatiblityCheck.INVALID;
    }
    return SchemaCompatiblityCheck.COMPATIBLE;
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:37,代码来源:KafkaFacade.java

示例9: isValid

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
@Override
public boolean isValid(String definition) {
	boolean result = true;
	try {
		new org.apache.avro.Schema.Parser().parse(definition);
	}
	catch (SchemaParseException ex) {
		result = false;
	}
	return result;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:12,代码来源:AvroSchemaValidator.java

示例10: compile

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
protected void compile() throws IOException {
    File sourceDirectory = getSourcesDirectory();
    File outputDirectory = getOutputDirectory();

    if (!outputDirectory.exists()) {
        outputDirectory.mkdirs();
    }

    Scanner fileScanner = context.newScanner(sourceDirectory, true);
    fileScanner.setIncludes(includes);
    fileScanner.setExcludes(excludes);
    fileScanner.scan();
    File basedir = fileScanner.getBasedir();

    List<File> changedFiles = new ArrayList<File>();
    for (String fileName : fileScanner.getIncludedFiles()) {
        File file = new File(basedir, fileName);
        changedFiles.add(file);
        context.removeMessages(file);
    }
    if (!changedFiles.isEmpty()) {
        try {
            File[] schemaFile = changedFiles.toArray(new File[changedFiles.size()]);
            GoraCompiler.compileSchema(schemaFile, outputDirectory);
        } catch (SchemaParseException e) {
            if (e.getCause() != null && e.getCause() instanceof JsonParseException) {
                attachErrorMessage((JsonParseException) e.getCause());
            } else {
                throw e;
            }
        }
    }
    context.refresh(outputDirectory);
}
 
开发者ID:dobromyslov,项目名称:gora-maven-plugin,代码行数:35,代码来源:AbstractGoraMojo.java

示例11: compile

import org.apache.avro.SchemaParseException; //导入依赖的package包/类
protected void compile() throws IOException {
  File sourceDirectory = getSourcesDirectory();
  File outputDirectory = getOutputDirectory();

  if (!outputDirectory.exists()) {
    outputDirectory.mkdirs();
  }

  Scanner fileScanner = context.newScanner(sourceDirectory, true);
  fileScanner.setIncludes(includes);
  fileScanner.setExcludes(excludes);
  fileScanner.scan();
  File basedir = fileScanner.getBasedir();

  List<File> changedFiles = new ArrayList<File>();
  for (String fileName : fileScanner.getIncludedFiles()) {
    File file = new File(basedir, fileName);
    changedFiles.add(file);
    context.removeMessages(file);
  }
  if (!changedFiles.isEmpty()) {
    try {
      File[] schemaFile = changedFiles.toArray(new File[changedFiles.size()]);
      GoraCompiler.compileSchema(schemaFile, outputDirectory);
    } catch (SchemaParseException e) {
      if (e.getCause() != null && e.getCause() instanceof JsonParseException) {
        attachErrorMessage((JsonParseException) e.getCause());
      } else {
        throw e;
      }
    }
  }
  context.refresh(outputDirectory);
}
 
开发者ID:apache,项目名称:gora,代码行数:35,代码来源:AbstractGoraMojo.java


注:本文中的org.apache.avro.SchemaParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。