public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
@Override public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
@Override public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
@Override public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
@Override public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
@Override public String toString() { try { ByteArrayOutputStream s = new ByteArrayOutputStream(); CsvRecordOutput a = new CsvRecordOutput(s); this.serialize(a); return new String(s.toByteArray(), "UTF-8"); } catch (Throwable ex) { throw new RuntimeException(ex); } } }
private void write(CharSequence label, Record record, BufferedWriter writer) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream() ; CsvRecordOutput cro = new CsvRecordOutput(outStream) ; cro.writeString(label.toString(), "labelText"); record.serialize(cro) ; writer.write(outStream.toString("UTF-8")) ; }
private void write(Integer id, Record record, BufferedWriter writer) throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream() ; CsvRecordOutput cro = new CsvRecordOutput(outStream) ; cro.writeInt(id, "pageId") ; record.serialize(cro) ; writer.write(outStream.toString("UTF-8")) ; }
private static void runCsvBench(String type, int numRecords, Times times) throws IOException { Record[] records = makeArray(type, numRecords, times); ByteArrayOutputStream bout = new ByteArrayOutputStream(); CsvRecordOutput rout = new CsvRecordOutput(bout); for(int idx = 0; idx < numRecords; idx++) { records[idx].serialize(rout); } bout.reset(); times.serialize = System.nanoTime(); for(int idx = 0; idx < numRecords; idx++) { records[idx].serialize(rout); } times.serialize = System.nanoTime() - times.serialize; byte[] serialized = bout.toByteArray(); ByteArrayInputStream bin = new ByteArrayInputStream(serialized); CsvRecordInput rin = new CsvRecordInput(bin); times.deserialize = System.nanoTime(); for(int idx = 0; idx < numRecords; idx++) { records[idx].deserialize(rin); } times.deserialize = System.nanoTime() - times.deserialize; }
public void testCsv() { File tmpfile; try { tmpfile = new File("/tmp/hadooptemp.txt"); FileOutputStream ostream = new FileOutputStream(tmpfile); CsvRecordOutput out = new CsvRecordOutput(ostream); 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>()); r1.serialize(out, ""); ostream.close(); } catch (IOException ex) { ex.printStackTrace(); } }
CsvRecordOutput cro = new CsvRecordOutput(outStream) ; cro.writeString(e.getKey(), null) ; e.getValue().serialize(cro) ;
tmpfile = File.createTempFile("hadooprec", ".txt"); FileOutputStream ostream = new FileOutputStream(tmpfile); CsvRecordOutput out = new CsvRecordOutput(ostream); RecRecord1 r1 = new RecRecord1(); r1.setBoolVal(true);