MCPcopy Create free account
hub / github.com/apache/pig / writeChararray

Method writeChararray

src/org/apache/pig/data/utils/SedesHelper.java:61–74  ·  view source on GitHub ↗
(DataOutput out, String s)

Source from the content-addressed store, hash-verified

59 }
60
61 public static void writeChararray(DataOutput out, String s) throws IOException {
62 // a char can take up to 3 bytes in the modified utf8 encoding
63 // used by DataOutput.writeUTF, so use UNSIGNED_SHORT_MAX/3
64 byte[] utfBytes = s.getBytes(BinInterSedes.UTF8);
65 int length = utfBytes.length;
66 if (length < BinInterSedes.UNSIGNED_SHORT_MAX) {
67 out.writeByte(BinInterSedes.SMALLCHARARRAY);
68 out.writeShort(length);
69 } else {
70 out.writeByte(BinInterSedes.CHARARRAY);
71 out.writeInt(length);
72 }
73 out.write(utfBytes);
74 }
75
76 public static String readChararray(DataInput in, byte type) throws IOException {
77 int size;

Callers 2

writeDatumMethod · 0.95
writeMethod · 0.95

Calls 2

getBytesMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected