if ((offset = currentOffset + size) > limit) {
            throw new IndexOutOfBoundsException();
        }

package one.nio.serial;

import one.nio.mem.DirectMemory;
import one.nio.util.Utf8;
import java.io.Closeable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
import static one.nio.util.JavaInternals.*;

public class DataStream implements ObjectInput, ObjectOutput {

    protected static final byte REF_NULL = -1;

    protected static final byte REF_RECURSIVE = -2;

    protected static final byte REF_RECURSIVE2 = -3;

    protected static final byte REF_EMBEDDED = -4;

    protected static final byte FIRST_APP_UID = -10;

    protected byte[] array;

    protected long address;

    protected long limit;

    protected long offset;

    public DataStream(int capacity) {
        this(new byte[capacity], byteArrayOffset, capacity);
    }

    public DataStream(byte[] array) {
        this(array, byteArrayOffset, array.length);
    }

    public DataStream(long address, long length) {
        this(null, address, length);
    }

    protected DataStream(byte[] array, long address, long length) {
        this.array = array;
        this.address = address;
        this.limit = address + length;
        this.offset = address;
    }

    public byte[] array() {
        return array;
    }

    public long address() {
        return address;
    }

    public int count() {
        return (int) (offset - address);
    }

    public void write(int b) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) b);
    }

    public void write(byte[] b) throws IOException {
        long offset = alloc(b.length);
        unsafe.copyMemory(b, byteArrayOffset, array, offset, b.length);
    }

    public void write(byte[] b, int off, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(b, byteArrayOffset + off, array, offset, len);
    }

    public void writeBoolean(boolean v) throws IOException {
        long offset = alloc(1);
        unsafe.putBoolean(array, offset, v);
    }

    public void writeByte(int v) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) v);
    }

    public void writeShort(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putShort(array, offset, Short.reverseBytes((short) v));
    }

    public void writeChar(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putChar(array, offset, Character.reverseBytes((char) v));
    }

    public void writeInt(int v) throws IOException {
        long offset = alloc(4);
        unsafe.putInt(array, offset, Integer.reverseBytes(v));
    }

    public void writeLong(long v) throws IOException {
        long offset = alloc(8);
        unsafe.putLong(array, offset, Long.reverseBytes(v));
    }

    public void writeFloat(float v) throws IOException {
        writeInt(Float.floatToRawIntBits(v));
    }

    public void writeDouble(double v) throws IOException {
        writeLong(Double.doubleToRawLongBits(v));
    }

    public void writeBytes(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length);
        for (int i = 0; i < length; i++) {
            unsafe.putByte(array, offset++, (byte) s.charAt(i));
        }
    }

    public void writeChars(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length * 2);
        for (int i = 0; i < length; i++) {
            unsafe.putChar(array, offset, Character.reverseBytes(s.charAt(i)));
            offset += 2;
        }
    }

    public void writeUTF(String s) throws IOException {
        int utfLength = Utf8.length(s);
        if (utfLength <= 0x7fff) {
            writeShort(utfLength);
        } else {
            writeInt(utfLength | 0x80000000);
        }
        long offset = alloc(utfLength);
        Utf8.write(s, array, offset);
    }

    @SuppressWarnings("unchecked")
    public void writeObject(Object obj) throws IOException {
        if (obj == null) {
            writeByte(REF_NULL);
        } else {
            Serializer serializer = Repository.get(obj.getClass());
            if (serializer.uid < 0) {
                writeByte((byte) serializer.uid);
            } else {
                writeLong(serializer.uid);
            }
            serializer.write(obj, this);
        }
    }

    public void write(ByteBuffer src) throws IOException {
        int len = src.remaining();
        long offset = alloc(len);
        if (src.hasArray()) {
            unsafe.copyMemory(src.array(), byteArrayOffset + src.arrayOffset() + src.position(), array, offset, len);
        } else {
            unsafe.copyMemory(null, DirectMemory.getAddress(src) + src.position(), array, offset, len);
        }
        src.position(src.limit());
    }

    public void writeFrom(long address, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(null, address, array, offset, len);
    }

    public int read() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int read(byte[] b) throws IOException {
        readFully(b);
        return b.length;
    }

    public int read(byte[] b, int off, int len) throws IOException {
        readFully(b, off, len);
        return len;
    }

    public void readFully(byte[] b) throws IOException {
        unsafe.copyMemory(array, alloc(b.length), b, byteArrayOffset, b.length);
    }

    public void readFully(byte[] b, int off, int len) throws IOException {
        unsafe.copyMemory(array, alloc(len), b, byteArrayOffset + off, len);
    }

    public long skip(long n) throws IOException {
        alloc((int) n);
        return n;
    }

    public int skipBytes(int n) throws IOException {
        alloc(n);
        return n;
    }

    public boolean readBoolean() throws IOException {
        return unsafe.getBoolean(array, alloc(1));
    }

    public byte readByte() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int readUnsignedByte() throws IOException {
        return unsafe.getByte(array, alloc(1)) & 0xff;
    }

    public short readShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2)));
    }

    public int readUnsignedShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2))) & 0xffff;
    }

    public char readChar() throws IOException {
        return Character.reverseBytes(unsafe.getChar(array, alloc(2)));
    }

    public int readInt() throws IOException {
        return Integer.reverseBytes(unsafe.getInt(array, alloc(4)));
    }

    public long readLong() throws IOException {
        return Long.reverseBytes(unsafe.getLong(array, alloc(8)));
    }

    public float readFloat() throws IOException {
        return Float.intBitsToFloat(readInt());
    }

    public double readDouble() throws IOException {
        return Double.longBitsToDouble(readLong());
    }

    public String readLine() throws IOException {
        for (long ptr = offset; ptr < limit; ptr++) {
            if (unsafe.getByte(array, ptr) == '\n') {
                int length = (int) (ptr - offset);
                int cr = length > 0 && unsafe.getByte(array, ptr - 1) == '\r' ? 1 : 0;
                return Utf8.read(array, alloc(length + 1), length - cr);
            }
        }
        // The last line without CR
        int length = (int) (limit - offset);
        return length > 0 ? Utf8.read(array, alloc(length), length) : null;
    }

    public String readUTF() throws IOException {
        int length = readUnsignedShort();
        if (length == 0) {
            return "";
        }
        if (length > 0x7fff) {
            length = (length & 0x7fff) << 16 | readUnsignedShort();
        }
        return Utf8.read(array, alloc(length), length);
    }

    public Object readObject() throws IOException, ClassNotFoundException {
        Serializer serializer;
        byte b = readByte();
        if (b >= 0) {
            offset--;
            serializer = Repository.requestSerializer(readLong());
        } else if (b == REF_NULL) {
            return null;
        } else {
            serializer = Repository.requestBootstrapSerializer(b);
        }
        return serializer.read(this);
    }

    public void read(ByteBuffer dst) throws IOException {
        int len = dst.remaining();
        long offset = alloc(len);
        if (dst.hasArray()) {
            unsafe.copyMemory(array, offset, dst.array(), byteArrayOffset + dst.arrayOffset() + dst.position(), len);
        } else {
            unsafe.copyMemory(array, offset, null, DirectMemory.getAddress(dst) + dst.position(), len);
        }
        dst.position(dst.limit());
    }

    public void readTo(long address, int len) throws IOException {
        unsafe.copyMemory(array, alloc(len), null, address, len);
    }

    public ByteBuffer byteBuffer(int len) throws IOException {
        long offset = alloc(len);
        if (array != null) {
            return ByteBuffer.wrap(array, (int) (offset - byteArrayOffset), len);
        } else {
            return DirectMemory.wrap(offset, len);
        }
    }

    public int available() {
        return (int) (limit - offset);
    }

    public void flush() throws IOException {
        // Nothing to do
    }

    public void close() throws IOException {
        // Nothing to do
    }

    public void register(Object obj) {
        // Nothing to do
    }

    public Closeable newScope() {
        return null;
    }

    protected long alloc(int size) throws IOException {
        long currentOffset = offset;


for (int i = 0; i < length; i++) {
            unsafe.putChar(array, offset, Character.reverseBytes(s.charAt(i)));
            offset += 2;
        }

package one.nio.serial;

import one.nio.mem.DirectMemory;
import one.nio.util.Utf8;
import java.io.Closeable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
import static one.nio.util.JavaInternals.*;

public class DataStream implements ObjectInput, ObjectOutput {

    protected static final byte REF_NULL = -1;

    protected static final byte REF_RECURSIVE = -2;

    protected static final byte REF_RECURSIVE2 = -3;

    protected static final byte REF_EMBEDDED = -4;

    protected static final byte FIRST_APP_UID = -10;

    protected byte[] array;

    protected long address;

    protected long limit;

    protected long offset;

    public DataStream(int capacity) {
        this(new byte[capacity], byteArrayOffset, capacity);
    }

    public DataStream(byte[] array) {
        this(array, byteArrayOffset, array.length);
    }

    public DataStream(long address, long length) {
        this(null, address, length);
    }

    protected DataStream(byte[] array, long address, long length) {
        this.array = array;
        this.address = address;
        this.limit = address + length;
        this.offset = address;
    }

    public byte[] array() {
        return array;
    }

    public long address() {
        return address;
    }

    public int count() {
        return (int) (offset - address);
    }

    public void write(int b) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) b);
    }

    public void write(byte[] b) throws IOException {
        long offset = alloc(b.length);
        unsafe.copyMemory(b, byteArrayOffset, array, offset, b.length);
    }

    public void write(byte[] b, int off, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(b, byteArrayOffset + off, array, offset, len);
    }

    public void writeBoolean(boolean v) throws IOException {
        long offset = alloc(1);
        unsafe.putBoolean(array, offset, v);
    }

    public void writeByte(int v) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) v);
    }

    public void writeShort(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putShort(array, offset, Short.reverseBytes((short) v));
    }

    public void writeChar(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putChar(array, offset, Character.reverseBytes((char) v));
    }

    public void writeInt(int v) throws IOException {
        long offset = alloc(4);
        unsafe.putInt(array, offset, Integer.reverseBytes(v));
    }

    public void writeLong(long v) throws IOException {
        long offset = alloc(8);
        unsafe.putLong(array, offset, Long.reverseBytes(v));
    }

    public void writeFloat(float v) throws IOException {
        writeInt(Float.floatToRawIntBits(v));
    }

    public void writeDouble(double v) throws IOException {
        writeLong(Double.doubleToRawLongBits(v));
    }

    public void writeBytes(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length);
        for (int i = 0; i < length; i++) {
            unsafe.putByte(array, offset++, (byte) s.charAt(i));
        }
    }

    public void writeChars(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length * 2);

    }

    public void writeUTF(String s) throws IOException {
        int utfLength = Utf8.length(s);
        if (utfLength <= 0x7fff) {
            writeShort(utfLength);
        } else {
            writeInt(utfLength | 0x80000000);
        }
        long offset = alloc(utfLength);
        Utf8.write(s, array, offset);
    }

    @SuppressWarnings("unchecked")
    public void writeObject(Object obj) throws IOException {
        if (obj == null) {
            writeByte(REF_NULL);
        } else {
            Serializer serializer = Repository.get(obj.getClass());
            if (serializer.uid < 0) {
                writeByte((byte) serializer.uid);
            } else {
                writeLong(serializer.uid);
            }
            serializer.write(obj, this);
        }
    }

    public void write(ByteBuffer src) throws IOException {
        int len = src.remaining();
        long offset = alloc(len);
        if (src.hasArray()) {
            unsafe.copyMemory(src.array(), byteArrayOffset + src.arrayOffset() + src.position(), array, offset, len);
        } else {
            unsafe.copyMemory(null, DirectMemory.getAddress(src) + src.position(), array, offset, len);
        }
        src.position(src.limit());
    }

    public void writeFrom(long address, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(null, address, array, offset, len);
    }

    public int read() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int read(byte[] b) throws IOException {
        readFully(b);
        return b.length;
    }

    public int read(byte[] b, int off, int len) throws IOException {
        readFully(b, off, len);
        return len;
    }

    public void readFully(byte[] b) throws IOException {
        unsafe.copyMemory(array, alloc(b.length), b, byteArrayOffset, b.length);
    }

    public void readFully(byte[] b, int off, int len) throws IOException {
        unsafe.copyMemory(array, alloc(len), b, byteArrayOffset + off, len);
    }

    public long skip(long n) throws IOException {
        alloc((int) n);
        return n;
    }

    public int skipBytes(int n) throws IOException {
        alloc(n);
        return n;
    }

    public boolean readBoolean() throws IOException {
        return unsafe.getBoolean(array, alloc(1));
    }

    public byte readByte() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int readUnsignedByte() throws IOException {
        return unsafe.getByte(array, alloc(1)) & 0xff;
    }

    public short readShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2)));
    }

    public int readUnsignedShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2))) & 0xffff;
    }

    public char readChar() throws IOException {
        return Character.reverseBytes(unsafe.getChar(array, alloc(2)));
    }

    public int readInt() throws IOException {
        return Integer.reverseBytes(unsafe.getInt(array, alloc(4)));
    }

    public long readLong() throws IOException {
        return Long.reverseBytes(unsafe.getLong(array, alloc(8)));
    }

    public float readFloat() throws IOException {
        return Float.intBitsToFloat(readInt());
    }

    public double readDouble() throws IOException {
        return Double.longBitsToDouble(readLong());
    }

    public String readLine() throws IOException {
        for (long ptr = offset; ptr < limit; ptr++) {
            if (unsafe.getByte(array, ptr) == '\n') {
                int length = (int) (ptr - offset);
                int cr = length > 0 && unsafe.getByte(array, ptr - 1) == '\r' ? 1 : 0;
                return Utf8.read(array, alloc(length + 1), length - cr);
            }
        }
        // The last line without CR
        int length = (int) (limit - offset);
        return length > 0 ? Utf8.read(array, alloc(length), length) : null;
    }

    public String readUTF() throws IOException {
        int length = readUnsignedShort();
        if (length == 0) {
            return "";
        }
        if (length > 0x7fff) {
            length = (length & 0x7fff) << 16 | readUnsignedShort();
        }
        return Utf8.read(array, alloc(length), length);
    }

    public Object readObject() throws IOException, ClassNotFoundException {
        Serializer serializer;
        byte b = readByte();
        if (b >= 0) {
            offset--;
            serializer = Repository.requestSerializer(readLong());
        } else if (b == REF_NULL) {
            return null;
        } else {
            serializer = Repository.requestBootstrapSerializer(b);
        }
        return serializer.read(this);
    }

    public void read(ByteBuffer dst) throws IOException {
        int len = dst.remaining();
        long offset = alloc(len);
        if (dst.hasArray()) {
            unsafe.copyMemory(array, offset, dst.array(), byteArrayOffset + dst.arrayOffset() + dst.position(), len);
        } else {
            unsafe.copyMemory(array, offset, null, DirectMemory.getAddress(dst) + dst.position(), len);
        }
        dst.position(dst.limit());
    }

    public void readTo(long address, int len) throws IOException {
        unsafe.copyMemory(array, alloc(len), null, address, len);
    }

    public ByteBuffer byteBuffer(int len) throws IOException {
        long offset = alloc(len);
        if (array != null) {
            return ByteBuffer.wrap(array, (int) (offset - byteArrayOffset), len);
        } else {
            return DirectMemory.wrap(offset, len);
        }
    }

    public int available() {
        return (int) (limit - offset);
    }

    public void flush() throws IOException {
        // Nothing to do
    }

    public void close() throws IOException {
        // Nothing to do
    }

    public void register(Object obj) {
        // Nothing to do
    }

    public Closeable newScope() {
        return null;
    }

    protected long alloc(int size) throws IOException {
        long currentOffset = offset;
        if ((offset = currentOffset + size) > limit) {
            throw new IndexOutOfBoundsException();
        }
        return currentOffset;
    }
}


package one.nio.serial;

import one.nio.mem.DirectMemory;
import one.nio.util.Utf8;
import java.io.Closeable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
import static one.nio.util.JavaInternals.*;

public class DataStream implements ObjectInput, ObjectOutput {

    protected static final byte REF_NULL = -1;

    protected static final byte REF_RECURSIVE = -2;

    protected static final byte REF_RECURSIVE2 = -3;

    protected static final byte REF_EMBEDDED = -4;

    protected static final byte FIRST_APP_UID = -10;

    protected byte[] array;

    protected long address;

    protected long limit;

    protected long offset;

    public DataStream(int capacity) {
        this(new byte[capacity], byteArrayOffset, capacity);
    }

    public DataStream(byte[] array) {
        this(array, byteArrayOffset, array.length);
    }

    public DataStream(long address, long length) {
        this(null, address, length);
    }

    protected DataStream(byte[] array, long address, long length) {
        this.array = array;
        this.address = address;
        this.limit = address + length;
        this.offset = address;
    }

    public byte[] array() {
        return array;
    }

    public long address() {
        return address;
    }

    public int count() {
        return (int) (offset - address);
    }

    public void write(int b) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) b);
    }

    public void write(byte[] b) throws IOException {
        long offset = alloc(b.length);
        unsafe.copyMemory(b, byteArrayOffset, array, offset, b.length);
    }

    public void write(byte[] b, int off, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(b, byteArrayOffset + off, array, offset, len);
    }

    public void writeBoolean(boolean v) throws IOException {
        long offset = alloc(1);
        unsafe.putBoolean(array, offset, v);
    }

    public void writeByte(int v) throws IOException {
        long offset = alloc(1);
        unsafe.putByte(array, offset, (byte) v);
    }

    public void writeShort(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putShort(array, offset, Short.reverseBytes((short) v));
    }

    public void writeChar(int v) throws IOException {
        long offset = alloc(2);
        unsafe.putChar(array, offset, Character.reverseBytes((char) v));
    }

    public void writeInt(int v) throws IOException {
        long offset = alloc(4);
        unsafe.putInt(array, offset, Integer.reverseBytes(v));
    }

    public void writeLong(long v) throws IOException {
        long offset = alloc(8);
        unsafe.putLong(array, offset, Long.reverseBytes(v));
    }

    public void writeFloat(float v) throws IOException {
        writeInt(Float.floatToRawIntBits(v));
    }

    public void writeDouble(double v) throws IOException {
        writeLong(Double.doubleToRawLongBits(v));
    }

    public void writeBytes(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length);
        for (int i = 0; i < length; i++) {
            unsafe.putByte(array, offset++, (byte) s.charAt(i));
        }
    }

    public void writeChars(String s) throws IOException {
        int length = s.length();
        long offset = alloc(length * 2);
        for (int i = 0; i < length; i++) {
            unsafe.putChar(array, offset, Character.reverseBytes(s.charAt(i)));
            offset += 2;
        }
    }

    public void writeUTF(String s) throws IOException {
        int utfLength = Utf8.length(s);
        if (utfLength <= 0x7fff) {
            writeShort(utfLength);
        } else {
            writeInt(utfLength | 0x80000000);
        }
        long offset = alloc(utfLength);
        Utf8.write(s, array, offset);
    }

    @SuppressWarnings("unchecked")
    public void writeObject(Object obj) throws IOException {
        if (obj == null) {
            writeByte(REF_NULL);
        } else {
            Serializer serializer = Repository.get(obj.getClass());
            if (serializer.uid < 0) {
                writeByte((byte) serializer.uid);
            } else {
                writeLong(serializer.uid);
            }
            serializer.write(obj, this);
        }
    }

    public void write(ByteBuffer src) throws IOException {
        int len = src.remaining();
        long offset = alloc(len);
        if (src.hasArray()) {
            unsafe.copyMemory(src.array(), byteArrayOffset + src.arrayOffset() + src.position(), array, offset, len);
        } else {
            unsafe.copyMemory(null, DirectMemory.getAddress(src) + src.position(), array, offset, len);
        }
        src.position(src.limit());
    }

    public void writeFrom(long address, int len) throws IOException {
        long offset = alloc(len);
        unsafe.copyMemory(null, address, array, offset, len);
    }

    public int read() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int read(byte[] b) throws IOException {
        readFully(b);
        return b.length;
    }

    public int read(byte[] b, int off, int len) throws IOException {
        readFully(b, off, len);
        return len;
    }

    public void readFully(byte[] b) throws IOException {
        unsafe.copyMemory(array, alloc(b.length), b, byteArrayOffset, b.length);
    }

    public void readFully(byte[] b, int off, int len) throws IOE

xception {
        unsafe.copyMemory(array, alloc(len), b, byteArrayOffset + off, len);
    }

    public long skip(long n) throws IOException {
        alloc((int) n);
        return n;
    }

    public int skipBytes(int n) throws IOException {
        alloc(n);
        return n;
    }

    public boolean readBoolean() throws IOException {
        return unsafe.getBoolean(array, alloc(1));
    }

    public byte readByte() throws IOException {
        return unsafe.getByte(array, alloc(1));
    }

    public int readUnsignedByte() throws IOException {
        return unsafe.getByte(array, alloc(1)) & 0xff;
    }

    public short readShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2)));
    }

    public int readUnsignedShort() throws IOException {
        return Short.reverseBytes(unsafe.getShort(array, alloc(2))) & 0xffff;
    }

    public char readChar() throws IOException {
        return Character.reverseBytes(unsafe.getChar(array, alloc(2)));
    }

    public int readInt() throws IOException {
        return Integer.reverseBytes(unsafe.getInt(array, alloc(4)));
    }

    public long readLong() throws IOException {
        return Long.reverseBytes(unsafe.getLong(array, alloc(8)));
    }

    public float readFloat() throws IOException {
        return Float.intBitsToFloat(readInt());
    }

    public double readDouble() throws IOException {
        return Double.longBitsToDouble(readLong());
    }

    public String readLine() throws IOException {
        for (long ptr = offset; ptr < limit; ptr++) {
            if (unsafe.getByte(array, ptr) == '\n') {
                int length = (int) (ptr - offset);
                int cr = length > 0 && unsafe.getByte(array, ptr - 1) == '\r' ? 1 : 0;
                return Utf8.read(array, alloc(length + 1), length - cr);
            }
        }
        // The last line without CR
        int length = (int) (limit - offset);
        return length > 0 ? Utf8.read(array, alloc(length), length) : null;
    }

    public String readUTF() throws IOException {
        int length = readUnsignedShort();
        if (length == 0) {
            return "";
        }
        if (length > 0x7fff) {
            length = (length & 0x7fff) << 16 | readUnsignedShort();
        }
        return Utf8.read(array, alloc(length), length);
    }

    public Object readObject() throws IOException, ClassNotFoundException {
        Serializer serializer;
        byte b = readByte();
        if (b >= 0) {
            offset--;
            serializer = Repository.requestSerializer(readLong());
        } else if (b == REF_NULL) {
            return null;
        } else {
            serializer = Repository.requestBootstrapSerializer(b);
        }
        return serializer.read(this);
    }

    public void read(ByteBuffer dst) throws IOException {
        int len = dst.remaining();
        long offset = alloc(len);
        if (dst.hasArray()) {
            unsafe.copyMemory(array, offset, dst.array(), byteArrayOffset + dst.arrayOffset() + dst.position(), len);
        } else {
            unsafe.copyMemory(array, offset, null, DirectMemory.getAddress(dst) + dst.position(), len);
        }
        dst.position(dst.limit());
    }

    public void readTo(long address, int len) throws IOException {
        unsafe.copyMemory(array, alloc(len), null, address, len);
    }

    public ByteBuffer byteBuffer(int len) throws IOException {
        long offset = alloc(len);
        if (array != null) {
            return ByteBuffer.wrap(array, (int) (offset - byteArrayOffset), len);
        } else {
            return DirectMemory.wrap(offset, len);
        }
    }

    public int available() {
        return (int) (limit - offset);
    }

    public void flush() throws IOException {
        // Nothing to do
    }

    public void close() throws IOException {
        // Nothing to do
    }

    public void register(Object obj) {
        // Nothing to do
    }

    public Closeable newScope() {
        return null;
    }

    protected long alloc(int size) throws IOException {
        long currentOffset = offset;
        if ((offset = currentOffset + size) > limit) {
            throw new IndexOutOfBoundsException();
        }
        return currentOffset;
    }
}


@Override
    public SystemOutLogger make(String binding, LoggerFormatter formatter)

package com.speedment.common.logger.internal;

import com.speedment.common.logger.LoggerFormatter;

/**
 * @author pemi
 */
public final class SystemOutLoggerFactory extends AbstractLoggerFactory {

{
        return new SystemOutLogger(binding, formatter);
    }

    @Override
    public Class<SystemOutLogger> loggerClass() {
        return SystemOutLogger.class;
    }
}


{
        return SystemOutLogger.class;
    }

package com.speedment.common.logger.internal;

import com.speedment.common.logger.LoggerFormatter;

/**
 * @author pemi
 */
public final class SystemOutLoggerFactory extends AbstractLoggerFactory {

    @Override
    public SystemOutLogger make(String binding, LoggerFormatter formatter) {
        return new SystemOutLogger(binding, formatter);
    }

    @Override
    public Class<SystemOutLogger> loggerClass()


package com.speedment.common.logger.internal;

import com.speedment.common.logger.LoggerFormatter;

/**
 * @author pemi
 */
public final class SystemOutLoggerFactory extends AbstractLoggerFactory {

    @Override
    public SystemOutLogger make(String binding, LoggerFormatter formatter) {
        return new SystemOutLogger(binding, formatter)

    }

    @Override
    public Class<SystemOutLogger> loggerClass() {
        return SystemOutLogger.class;
    }
}


package com.speedment.common.logger.internal;

import com.speedment.common.logger.LoggerForma

tter;

/**
 * @author pemi
 */
public final class SystemOutLoggerFactory extends AbstractLoggerFactory {

    @Override
    public SystemOutLogger make(String binding, LoggerFormatter formatter) {
        return new SystemOutLogger(binding, formatter);
    }

    @Override
    public Class<SystemOutLogger> loggerClass() {
        return SystemOutLogger.class;
    }
}


@Override
    default MuJava<R, IExec> base()

package recaf.paper.full;

import recaf.paper.expr.IEval;
import recaf.paper.stm.IExec;
import recaf.paper.stm.MuJava;
import recaf.paper.stm.MuJavaBase;

public interface FullMuJavaDirect<R> extends FullMuJava<IExec, IEval>, MuStmIEvalJavaAdapter<R, IExec> {

{
        return new MuJavaBase<R>() {
        };
    }
}


{
        return new MuJavaBase<R>() {
        };
    }

package recaf.paper.full;

import recaf.paper.expr.IEval;
import recaf.paper.stm.IExec;
import recaf.paper.stm.MuJava;
import recaf.paper.stm.MuJavaBase;

public interface FullMuJavaDirect<R> extends FullMuJava<IExec, IEval>, MuStmIEvalJavaAdapter<R, IExec> {

    @Override
    default MuJava<R, IExec> base()


package recaf.paper.full;

import recaf.paper.expr.IEval;
import recaf.paper.stm.IExec;
imp

ort recaf.paper.stm.MuJava;
import recaf.paper.stm.MuJavaBase;

public interface FullMuJavaDirect<R> extends FullMuJava<IExec, IEval>, MuStmIEvalJavaAdapter<R, IExec> {

    @Override
    default MuJava<R, IExec> base() {
        return new MuJavaBase<R>() {
        };
    }
}


package com.RSen.Commandr.builtincommands;

import android.content.Context;
import android.media.AudioManager;
import com.RSen.Commandr.R;
import com.RSen.Commandr.core.MostWantedCommand;

/**
 * @author Ryan Senanayake
 *         Commandr for Google Now
 *         FlashlightCommand.java
 * @version 1.0
 *          5/28/14
 */
public class UnsilenceRingerCommand extends MostWantedCommand {

    private static String TITLE;

    private static String DEFAULT_PHRASE;

    public UnsilenceRingerCommand(Context ctx) {
        DEFAULT_PHRASE = ctx.getString(R.string.unsilence_ringer_phrase);
        TITLE = ctx.getString(R.string.unsilence_ringer_title);
    }

    /**
     * Execute this command (turn on flashlight)
     */
    @Override
    public void execute(Context context, String predicate) {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    }

    /**
     * It is enabled if the phone has a flash feature
     */
    @Override
    public boolean isAvailable(Context context) {
        return true;
    }

{
        return TITLE;
    }

    @Override
    public String getDefaultPhrase() {
        return DEFAULT_PHRASE;
    }
}


package com.RSen.Commandr.builtincommands;

import android.content.Context;
import android.media.AudioManager;
import com.RSen.Commandr.R;
import com.RSen.Commandr.core.MostWantedCommand;

/**
 * @author Ryan Senanayake
 *         Commandr for Google Now
 *         FlashlightCommand.java
 * @version 1.0
 *          5/28/14
 */
public class UnsilenceRingerCommand extends MostWantedCommand {

    private static String TITLE;

    private static String DEFAULT_PHRASE;

    public UnsilenceRingerCommand(Context ctx) {
        DEFAULT_PHRASE = ctx.getString(R.string.unsilence_ringer_phrase);
        TITLE = ctx.getString(R.string.unsilence_ringer_title);
    }

    /**
     * Execute this command (turn on flashlight)
     */
    @Override
    public void execute(Context context, String predicate) {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    }

    /**
     * It is enabled if the phone has a flash feature
     */
    @Override
    public boolean isAvailable(Context context) {
        return true;
    }

    @Override
    public String getTitle() {
        return TITLE;
    }

    @Override
    public String getDefaultPhrase()


package com.RSen.Commandr.builtincommands;

import android.content.Context;
import android.media.AudioManager;
import com.RSen.Commandr.R;
import com.RSen.Commandr.core.MostWantedCommand;

/**
 * @author Ryan Senanayake
 *         Commandr for Google Now
 *         FlashlightCommand.java
 * @version 1.0
 *          5/28/14
 */
public class UnsilenceRingerCommand extends MostWantedCommand {

    private static String TITLE;

    private static String DEFAULT_PHRASE;

    public UnsilenceRingerCommand(Context ctx) {
        DEFAULT_PHRASE = ctx.getString(R.string.unsilence_ringer_phrase);
        TITLE = ctx.getString(R.string.unsilence_ringer_title);
    }

    /**
     * Execute this command (turn on flashlight)
     */
    @Override
    public void execute(Context context, String predicate) {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    }

    /**
     * It is enabled if the phone has a flash feature
     */
    @Override
    public boolean isAvailable(Context context) {
        return

    }

    @Override
    public String getTitle() {
        return TITLE;
    }

    @Override
    public String getDefaultPhrase() {
        return DEFAULT_PHRASE;
    }
}


@Override
    public boolean isAvailable(Context context) {
        return true;
    }

package com.RSen.Commandr.builtincommands;

import android.content.Context;
import android.media.AudioManager;
import com.RSen.Commandr.R;
import com.RSen.Commandr.core.MostWantedCommand;

/**
 * @author Ryan Senanayake
 *         Commandr for Google Now
 *         FlashlightCommand.java
 * @version 1.0
 *          5/28/14
 */
public class UnsilenceRingerCommand extends MostWantedCommand {

    private static String TITLE;

    private static String DEFAULT_PHRASE;

    public UnsilenceRingerCommand(Context ctx) {
        DEFAULT_PHRASE = ctx.getString(R.string.unsilence_ringer_phrase);
        TITLE = ctx.getString(R.string.unsilence_ringer_title);
    }

    /**
     * Execute this command (turn on flashlight)
     */
    @Override
    public void execute(Context context, String predicate) {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
    }

    /**
     * It is enabled if the phone has a flash feature
     */

    @Override
    public String getTitle() {
        return TITLE;
    }

    @Override
    public String getDefaultPhrase() {
        return DEFAULT_PHRASE;
    }
}


package com.RSen.Commandr.builtincommands;

import android.content.Context;
import android.media.AudioManager;
import com.RSen.Commandr.R;
import com.RSen.Commandr.core.MostWantedCommand;

/**
 * @author Ryan Senanayake
 *         Commandr for Google Now
 *         FlashlightCommand.java
 * @version 1.0
 *          5/28/14
 */
public class UnsilenceRingerCommand extends MostWantedCommand {

    private static String TITLE;

    private static String DEFAULT_PHRASE;

    public UnsilenceRingerCommand(Context ctx) {
        DEFAULT_PHRASE = ctx.getString(R.string.unsilence_ringer_phrase);
        TITLE = ctx.getString(R.string.unsilence_ringer_title);
    }

    /**
     * Execute this command (turn on flashlight)
     */
    @Override
    public void execute(Context context, String predicate) {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

  }

    /**
     * It is enabled if the phone has a flash feature
     */
    @Override
    public boolean isAvailable(Context context) {
        return true;
    }

    @Override
    public String getTitle() {
        return TITLE;
    }

    @Override
    public String getDefaultPhrase() {
        return DEFAULT_PHRASE;
    }
}


@Override
    public String getParentEntityName()

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

{
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


{
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy)

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {

        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();

        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }


ECT way_id AS entity_id, node_id, sequence_id FROM ");

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SEL

        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }

        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");

        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }

package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowCount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {

    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


package org.openstreetmap.osmosis.pgsimple.v0_6.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.openstreetmap.osmosis.core.OsmosisRuntimeException;
import org.openstreetmap.osmosis.core.database.DbOrderedFeature;
import org.openstreetmap.osmosis.core.domain.v0_6.WayNode;

/**
 * Reads and writes way nodes to jdbc classes.
 *
 * @author Brett Henderson
 */
public class WayNodeMapper extends EntityFeatureMapper<DbOrderedFeature<WayNode>> {

    @Override
    public String getParentEntityName() {
        return "way";
    }

    @Override
    public String getEntityName() {
        return "way_nodes";
    }

    @Override
    public String getSqlSelect(boolean filterByEntityId, boolean orderBy) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("SELECT way_id AS entity_id, node_id, sequence_id FROM ");
        resultSql.append("way_nodes f");
        if (filterByEntityId) {
            resultSql.append(" WHERE entity_id = ?");
        }
        if (orderBy) {
            resultSql.append(getSqlDefaultOrderBy());
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDefaultOrderBy() {
        return super.getSqlDefaultOrderBy() + ", sequence_id";
    }

    @Override
    public String getSqlInsert(int rowC

ount) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("INSERT INTO way_nodes (");
        resultSql.append("way_id, node_id, sequence_id) VALUES ");
        for (int row = 0; row < rowCount; row++) {
            if (row > 0) {
                resultSql.append(", ");
            }
            resultSql.append("(?, ?, ?)");
        }
        return resultSql.toString();
    }

    @Override
    public String getSqlDelete(boolean filterByEntityId) {
        StringBuilder resultSql;
        resultSql = new StringBuilder();
        resultSql.append("DELETE FROM way_nodes");
        if (filterByEntityId) {
            resultSql.append(" WHERE ").append("way_id = ?");
        }
        return resultSql.toString();
    }

    @Override
    public DbOrderedFeature<WayNode> buildEntity(ResultSet resultSet) {
        try {
            return new DbOrderedFeature<WayNode>(resultSet.getLong("entity_id"), new WayNode(resultSet.getLong("node_id")), resultSet.getInt("sequence_id"));
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to build a way node from the current recordset row.", e);
        }
    }

    @Override
    public int populateEntityParameters(PreparedStatement statement, int initialIndex, DbOrderedFeature<WayNode> entityFeature) {
        try {
            int prmIndex;
            WayNode wayNode;
            wayNode = entityFeature.getFeature();
            prmIndex = initialIndex;
            statement.setLong(prmIndex++, entityFeature.getEntityId());
            statement.setLong(prmIndex++, wayNode.getNodeId());
            statement.setInt(prmIndex++, entityFeature.getSequenceId());
            return prmIndex;
        } catch (SQLException e) {
            throw new OsmosisRuntimeException("Unable to populate way node parameters for way " + entityFeature.getEntityId() + ".", e);
        }
    }
}


public static short slotForKey(byte[] key)

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */

{
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


{
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

    private static short crc16(byte[] key, int start, int end)


        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {

        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


// No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }

        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


// No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


crc16(key, startHashtag + 1, endHashtag);

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return

    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


if (key[endHashtag] == '}') {
                break;
            }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {

        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, endHashtag);
    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }

package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;


package org.apache.geode.redis.internal.data;

import static org.apache.geode.redis.internal.RegionProvider.REDIS_SLOTS;
import org.apache.geode.redis.internal.executor.cluster.CRC16;

/**
 * Utility for parsing the hashtags in a redis key and computing the redis slot of the key.
 */
public class KeyHashUtil {

    /**
     * Compute the slot of a given redis key
     *
     * @return the slot, a value between 0 and 16K.
     */
    public static short slotForKey(byte[] key) {
        int startHashtag;
        int endHashtag;
        for (startHashtag = 0; startHashtag < key.length; startHashtag++) {
            if (key[startHashtag] == '{') {
                break;
            }
        }
        // No starting hashtag, hash the whole thing
        if (startHashtag == key.length) {
            return crc16(key, 0, key.length);
        }
        for (endHashtag = startHashtag + 1; endHashtag < key.length; endHashtag++) {
            if (key[endHashtag] == '}') {
                break;
            }
        }
        // No ending hashtag, or empty hashtag. Hash the whole thing.
        if (endHashtag == key.length || endHashtag == startHashtag + 1) {
            return crc16(key, 0, key.length);
        }
        return crc16(key, startHashtag + 1, e

ndHashtag);
    }

    private static short crc16(byte[] key, int start, int end) {
        return (short) (CRC16.calculate(key, start, end) & (REDIS_SLOTS - 1));
    }
}


private static String handleDecimal(final BigDecimal value)

package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next();
            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

{
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


{
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next();
            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value)

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {

            final SimpleColumn column = columnIt.next();
            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


final SimpleColumn column = columnIt.next();

package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();

            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}