HADOOP-6492. Make some Avro serialization APIs public. Contributed by Aaron Kimball.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@899866 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2010-01-16 01:06:57 +00:00
parent a90d3205d2
commit 4cd159e83e
6 changed files with 17 additions and 14 deletions

View File

@ -101,6 +101,9 @@ Trunk (unreleased changes)
HADOOP-6155. Deprecate RecordIO anticipating Avro. (Tom White via cdouglas)
HADOOP-6492. Make some Avro serialization APIs public.
(Aaron Kimball via cutting)
OPTIMIZATIONS
BUG FIXES

View File

@ -77,8 +77,8 @@ public Serializer<T> getSerializer(Class<T> c) {
*/
public abstract DeserializerBase<T> getDeserializer(
Map<String, String> metadata);
protected Class<?> getClassFromMetadata(Map<String, String> metadata) {
public Class<?> getClassFromMetadata(Map<String, String> metadata) {
String classname = metadata.get(CLASS_KEY);
if (classname == null) {
return null;

View File

@ -46,18 +46,18 @@ public boolean accept(Map<String, String> metadata) {
}
@Override
protected DatumReader getReader(Map<String, String> metadata) {
public DatumReader getReader(Map<String, String> metadata) {
Schema schema = Schema.parse(metadata.get(AVRO_SCHEMA_KEY));
return new GenericDatumReader<Object>(schema);
}
@Override
protected Schema getSchema(Map<String, String> metadata) {
public Schema getSchema(Map<String, String> metadata) {
return Schema.parse(metadata.get(AVRO_SCHEMA_KEY));
}
@Override
protected DatumWriter getWriter(Map<String, String> metadata) {
public DatumWriter getWriter(Map<String, String> metadata) {
return new GenericDatumWriter<Object>();
}

View File

@ -76,7 +76,7 @@ private void getPackages() {
}
@Override
protected DatumReader getReader(Map<String, String> metadata) {
public DatumReader getReader(Map<String, String> metadata) {
try {
return new ReflectDatumReader(getClassFromMetadata(metadata));
} catch (Exception e) {
@ -85,13 +85,13 @@ protected DatumReader getReader(Map<String, String> metadata) {
}
@Override
protected Schema getSchema(Map<String, String> metadata) {
public Schema getSchema(Map<String, String> metadata) {
Class<?> c = getClassFromMetadata(metadata);
return ReflectData.get().getSchema(c);
}
@Override
protected DatumWriter getWriter(Map<String, String> metadata) {
public DatumWriter getWriter(Map<String, String> metadata) {
return new ReflectDatumWriter();
}

View File

@ -51,17 +51,17 @@ public SerializerBase<T> getSerializer(Map<String, String> metadata) {
/**
* Return an Avro Schema instance for the given class and metadata.
*/
protected abstract Schema getSchema(Map<String, String> metadata);
public abstract Schema getSchema(Map<String, String> metadata);
/**
* Create and return Avro DatumWriter for the given metadata.
*/
protected abstract DatumWriter<T> getWriter(Map<String, String> metadata);
public abstract DatumWriter<T> getWriter(Map<String, String> metadata);
/**
* Create and return Avro DatumReader for the given metadata.
*/
protected abstract DatumReader<T> getReader(Map<String, String> metadata);
public abstract DatumReader<T> getReader(Map<String, String> metadata);
class AvroSerializer extends SerializerBase<T> {

View File

@ -47,7 +47,7 @@ public boolean accept(Map<String, String> metadata) {
}
@Override
protected DatumReader getReader(Map<String, String> metadata) {
public DatumReader getReader(Map<String, String> metadata) {
try {
return new SpecificDatumReader(getClassFromMetadata(metadata));
} catch (Exception e) {
@ -56,13 +56,13 @@ protected DatumReader getReader(Map<String, String> metadata) {
}
@Override
protected Schema getSchema(Map<String, String> metadata) {
public Schema getSchema(Map<String, String> metadata) {
Class<?> c = getClassFromMetadata(metadata);
return SpecificData.get().getSchema(c);
}
@Override
protected DatumWriter getWriter(Map<String, String> metadata) {
public DatumWriter getWriter(Map<String, String> metadata) {
return new SpecificDatumWriter();
}