Package org.spf4j.avro.csv
Class CsvDecoder
- java.lang.Object
-
- org.apache.avro.io.Decoder
-
- org.apache.avro.io.ParsingDecoder
-
- org.spf4j.avro.csv.CsvDecoder
-
- All Implemented Interfaces:
org.apache.avro.io.parsing.Parser.ActionHandler,org.apache.avro.io.parsing.SkipParser.SkipHandler
public final class CsvDecoder extends org.apache.avro.io.ParsingDecoderA Csv encoder for avro records. there are restrictions on the what schema's are supported.- Author:
- Zoltan Farkas
-
-
Constructor Summary
Constructors Constructor Description CsvDecoder(org.spf4j.io.csv.CsvReader csvReader, org.apache.avro.Schema readerSchema)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longarrayNext()org.apache.avro.io.parsing.SymboldoAction(org.apache.avro.io.parsing.Symbol symbol, org.apache.avro.io.parsing.Symbol symbol1)longmapNext()longreadArrayStart()booleanreadBoolean()ByteBufferreadBytes(ByteBuffer bb)doublereadDouble()intreadEnum()voidreadFixed(byte[] bytes, int i, int nrBytes)floatreadFloat()intreadIndex()intreadInt()longreadLong()longreadMapStart()voidreadNull()StringreadString()org.apache.avro.util.Utf8readString(org.apache.avro.util.Utf8 utf8)longskipArray()voidskipBytes()protected voidskipFixed()voidskipFixed(int i)voidskipHeader()longskipMap()voidskipString()StringtoString()static DecodedSchematryDecodeSchema(InputStream is, org.apache.avro.Schema readerSchema)Will try to decode the writer schema based on the csv headers, and the reader schema.
-
-
-
Constructor Detail
-
CsvDecoder
public CsvDecoder(org.spf4j.io.csv.CsvReader csvReader, org.apache.avro.Schema readerSchema) throws IOException- Throws:
IOException
-
-
Method Detail
-
skipHeader
public void skipHeader() throws IOException, org.spf4j.io.csv.CsvParseException- Throws:
IOExceptionorg.spf4j.io.csv.CsvParseException
-
readNull
public void readNull() throws IOException- Specified by:
readNullin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException- Specified by:
readBooleanin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readInt
public int readInt() throws IOException- Specified by:
readIntin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein classorg.apache.avro.io.Decoder- Throws:
IOException
-
readString
public org.apache.avro.util.Utf8 readString(org.apache.avro.util.Utf8 utf8) throws IOException- Specified by:
readStringin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readString
public String readString() throws IOException
- Specified by:
readStringin classorg.apache.avro.io.Decoder- Throws:
IOException
-
skipString
public void skipString() throws IOException- Specified by:
skipStringin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readBytes
public ByteBuffer readBytes(ByteBuffer bb) throws IOException
- Specified by:
readBytesin classorg.apache.avro.io.Decoder- Throws:
IOException
-
skipBytes
public void skipBytes() throws IOException- Specified by:
skipBytesin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readFixed
public void readFixed(byte[] bytes, int i, int nrBytes) throws IOException- Specified by:
readFixedin classorg.apache.avro.io.Decoder- Throws:
IOException
-
skipFixed
public void skipFixed(int i) throws IOException- Specified by:
skipFixedin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readEnum
public int readEnum() throws IOException- Specified by:
readEnumin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readArrayStart
public long readArrayStart() throws IOException- Specified by:
readArrayStartin classorg.apache.avro.io.Decoder- Throws:
IOException
-
arrayNext
public long arrayNext() throws IOException- Specified by:
arrayNextin classorg.apache.avro.io.Decoder- Throws:
IOException
-
skipArray
public long skipArray() throws IOException- Specified by:
skipArrayin classorg.apache.avro.io.Decoder- Throws:
IOException
-
readMapStart
public long readMapStart()
- Specified by:
readMapStartin classorg.apache.avro.io.Decoder
-
mapNext
public long mapNext()
- Specified by:
mapNextin classorg.apache.avro.io.Decoder
-
skipMap
public long skipMap()
- Specified by:
skipMapin classorg.apache.avro.io.Decoder
-
readIndex
public int readIndex() throws IOException- Specified by:
readIndexin classorg.apache.avro.io.Decoder- Throws:
IOException
-
skipFixed
protected void skipFixed() throws IOException- Specified by:
skipFixedin classorg.apache.avro.io.ParsingDecoder- Throws:
IOException
-
doAction
@Nullable public org.apache.avro.io.parsing.Symbol doAction(org.apache.avro.io.parsing.Symbol symbol, org.apache.avro.io.parsing.Symbol symbol1)
-
tryDecodeSchema
public static DecodedSchema tryDecodeSchema(InputStream is, @Nullable org.apache.avro.Schema readerSchema) throws IOException
Will try to decode the writer schema based on the csv headers, and the reader schema.- Parameters:
is-readerSchema-- Returns:
- Throws:
IOException
-
-