PhastDecoder { public static String decodeString(ChannelReader reader, Boolean isOptional){ if (reader.readPackedInt() == INCOMING_VARIABLE){ return reader.readUTF(); } else return null; }  static long decodeDeltaLong(long[] longDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static int decodeDefaultInt(ChannelReader reader, long map, int[] defaultValues, long bitMask, int idx, Boolean isOptional); static int decodeDeltaInt(int[] intDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static int decodeCopyInt(int[] intDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static int decodeIncrementInt(int[] intDictionary, long map, int idx, long bitMask, Boolean isOptional); static int decodePresentInt(ChannelReader reader, long map, long bitMask, Boolean isOptional); static String decodeString(ChannelReader reader, Boolean isOptional); static long decodeIncrementLong(long[] longDictionary, long map, int idx, long bitMask, Boolean isOptional); static long decodePresentLong(ChannelReader reader, long map, long bitMask, Boolean isOptional); static long decodeDefaultLong(ChannelReader reader, long map, long[] defaultValues, long bitMask, int idx, Boolean isOptional); static long decodeCopyLong(long[] longDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static short decodeIncrementShort(short[] shortDictionary, long map, int idx, long bitMask, Boolean isOptional); static short decodePresentShort(ChannelReader reader, long map, long bitMask, Boolean isOptional); static short decodeDefaultShort(ChannelReader reader, long map, short[] defaultValues, long bitMask, int idx, Boolean isOptional); static short decodeCopyShort(short[] shortDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static short decodeDeltaShort(short[] shortDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional); static final int INCOMING_VARIABLE; static final long MOST_FREQUENT_CASE; static final long LEAST_FREQUENT_CASE; }
@Test public void decodeStringTest() throws IOException{ Pipe<RawDataSchema> pipe = new Pipe<RawDataSchema>(new PipeConfig<RawDataSchema>(RawDataSchema.instance, 100, 4000)); pipe.initBuffers(); DataOutputBlobWriter<RawDataSchema> writer = new DataOutputBlobWriter<RawDataSchema>(pipe); DataOutputBlobWriter.writePackedInt(writer, -63); writer.writeUTF("This is a test"); writer.close(); DataInputBlobReader<RawDataSchema> reader = new DataInputBlobReader<RawDataSchema>(pipe); String stest = PhastDecoder.decodeString(reader, false); reader.close(); assertTrue(stest.compareTo("This is a test") == 0); }