Package org.apache.hadoop.record

Examples of org.apache.hadoop.record.RecordWriter


    public void testBinary() {
        File tmpfile;
        try {
            tmpfile = File.createTempFile("hadooprec", ".dat");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "binary");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
            FileInputStream istream = new FileInputStream(tmpfile);
            RecordReader in = new RecordReader(istream, "binary");
            RecRecord1 r2 = new RecRecord1();
            in.read(r2);
View Full Code Here


    public void testCsv() {
        File tmpfile;
        try {
            tmpfile = File.createTempFile("hadooprec", ".txt");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "csv");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
            FileInputStream istream = new FileInputStream(tmpfile);
            RecordReader in = new RecordReader(istream, "csv");
            RecRecord1 r2 = new RecRecord1();
            in.read(r2);
View Full Code Here

    public void testXml() {
        File tmpfile;
        try {
            tmpfile = File.createTempFile("hadooprec", ".xml");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "xml");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
            FileInputStream istream = new FileInputStream(tmpfile);
            RecordReader in = new RecordReader(istream, "xml");
            RecRecord1 r2 = new RecRecord1();
            in.read(r2);
View Full Code Here

    public void testBinary() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.dat");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "binary");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void testCsv() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.txt");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "csv");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void testXml() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.xml");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "xml");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new ByteArrayOutputStream(20));
            r1.setVectorVal(new ArrayList());
            r1.setMapVal(new TreeMap());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void testBinary() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.dat");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "binary");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new Buffer());
            r1.setVectorVal(new ArrayList<String>());
            r1.setMapVal(new TreeMap<String,String>());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void testCsv() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.txt");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "csv");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new Buffer());
            r1.setVectorVal(new ArrayList<String>());
            r1.setMapVal(new TreeMap<String,String>());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

    public void testXml() {
        File tmpfile;
        try {
            tmpfile = new File("/temp/hadooptemp.xml");
            FileOutputStream ostream = new FileOutputStream(tmpfile);
            RecordWriter out = new RecordWriter(ostream, "xml");
            RecRecord1 r1 = new RecRecord1();
            r1.setBoolVal(true);
            r1.setByteVal((byte)0x66);
            r1.setFloatVal(3.145F);
            r1.setDoubleVal(1.5234);
            r1.setIntVal(4567);
            r1.setLongVal(0x5a5a5a5a5a5aL);
            r1.setStringVal("random text");
            r1.setBufferVal(new Buffer());
            r1.setVectorVal(new ArrayList<String>());
            r1.setMapVal(new TreeMap<String,String>());
            out.write(r1);
            ostream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.record.RecordWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.