Java Code Examples for org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#forEachByteDesc()

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf#forEachByteDesc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractByteBufTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testForEachByteDesc2() {
    byte[] expected = {1, 2, 3, 4};
    ByteBuf buf = newBuffer(expected.length);
    try {
        buf.writeBytes(expected);
        final byte[] bytes = new byte[expected.length];
        int i = buf.forEachByteDesc(new ByteProcessor() {
            private int index = bytes.length - 1;

            @Override
            public boolean process(byte value) throws Exception {
                bytes[index--] = value;
                return true;
            }
        });
        assertEquals(-1, i);
        assertArrayEquals(expected, bytes);
    } finally {
        buf.release();
    }
}
 
Example 2
Source File: AbstractByteBufTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testForEachByteDesc2() {
    byte[] expected = {1, 2, 3, 4};
    ByteBuf buf = newBuffer(expected.length);
    try {
        buf.writeBytes(expected);
        final byte[] bytes = new byte[expected.length];
        int i = buf.forEachByteDesc(new ByteProcessor() {
            private int index = bytes.length - 1;

            @Override
            public boolean process(byte value) throws Exception {
                bytes[index--] = value;
                return true;
            }
        });
        assertEquals(-1, i);
        assertArrayEquals(expected, bytes);
    } finally {
        buf.release();
    }
}
 
Example 3
Source File: AbstractByteBufTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testForEachByteDesc2() {
    byte[] expected = {1, 2, 3, 4};
    ByteBuf buf = newBuffer(expected.length);
    try {
        buf.writeBytes(expected);
        final byte[] bytes = new byte[expected.length];
        int i = buf.forEachByteDesc(new ByteProcessor() {
            private int index = bytes.length - 1;

            @Override
            public boolean process(byte value) throws Exception {
                bytes[index--] = value;
                return true;
            }
        });
        assertEquals(-1, i);
        assertArrayEquals(expected, bytes);
    } finally {
        buf.release();
    }
}