hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes.Lichtenberger" <Johannes.Lichtenber...@uni-konstanz.de>
Subject Re: ClassCastException
Date Fri, 08 Oct 2010 01:29:31 GMT
On 10/08/2010 02:52 AM, Ted Yu wrote:
> Have you checked
> http://download.oracle.com/javase/6/docs/api/javax/xml/stream/XMLEventReader.html?

Hm, I'm working really often with StAX and I'm using the event reader in
my custom input format to create the records and produce a List of
XMLEvents or more precisely now ListWritable which has a membervariable
List<XMLEventWritable> and extends ArrayWritable:

    /**
     * Constructor.
     *
     * @param paramList
     *            List of {@link XMLEvent}s.
     */
    public ListWritable(final List<XMLEventWritable> paramList) {
        super(XMLEventWritable.class, paramList.toArray(new
XMLEventWritable[paramList.size()]));
        mList = paramList;
    }

...

and in my XMLEventWritable:

    @Override
    public void write(final DataOutput paramOut) throws IOException {
        try {
        mEvent.writeAsEncodedUnicode(mWriter);
        } catch (final XMLStreamException e) {
            // Implement logging.
        }
        mWriter.flush();
        paramOut.writeUTF(mWriter.toString());
    }

But my problem is now readFields(final DataInput paramIn). I assume I
have to create an XMLEventFactory, but I'm not sure how to determine the
type of the event and so on (normally event.getEventType()). So I would
have to get the whole input:

final String line = paramIn.readUTF();

and parse it if it's a start tag, end tag, comment, character... and
then create the appropriate event?

Baaah, horrible ;-)

Mime
View raw message