class BytesRefDataAccess extends AbstractData<BytesRef> implements DataAccess<BytesRef> {

    /** Cache field. */
    private transient BytesStore<?, ?> bs;

    /** State field. */
    private transient byte[] array;

    public BytesRefDataAccess() {
        initTransients();
    }

    private void initTransients() {
        bs = null;
    }

    @Override
    public RandomDataInput bytes() {
        return bs;
    }

    @Override
    public long offset() {
        return bs.start();
    }

    @Override
    public long size() {
        return bs.capacity();
    }

    @Override
    public BytesRef get() {
        return new BytesRef(array);
    }

    @Override
    public BytesRef getUsing(@Nullable BytesRef using) {<FILL_FUNCTION_BODY>}

    @Override
    public Data<BytesRef> getData(@NotNull BytesRef instance) {
        if (instance.bytes.length == instance.length) {
            array = instance.bytes;
        } else {
            array = new byte[instance.length];
            System.arraycopy(instance.bytes, instance.offset, array, 0, instance.length);
        }
        bs = BytesStore.wrap(array);
        return this;
    }

    @Override
    public void uninit() {
        array = null;
        bs = null;
    }

    @Override
    public DataAccess<BytesRef> copy() {
        return new BytesRefDataAccess();
    }

    @Override
    public void writeMarshallable(@NotNull WireOut wireOut) {
        // no fields to write
    }

    @Override
    public void readMarshallable(@NotNull WireIn wireIn) {
        // no fields to read
        initTransients();
    }

}

        using = Optional.ofNullable(using)
                .orElseGet( () ->
                        new BytesRef(new byte[array.length])
                );
        if (using.bytes.length < array.length) {
            using.bytes = new byte[array.length];
        }
        System.arraycopy(array, 0, using.bytes, 0, array.length);
        using.offset = 0;
        using.length = array.length;
        return using;
    
<no_super_class>