001
002package org.xbib.elasticsearch.common.bytes;
003
004import org.elasticsearch.ElasticsearchException;
005import org.elasticsearch.common.lease.Releasables;
006import org.elasticsearch.common.util.BigArrays;
007import org.elasticsearch.common.util.ByteArray;
008
009/**
010 * An extension to {@link org.elasticsearch.common.bytes.PagedBytesReference} that requires releasing its content. This
011 * class exists to make it explicit when a bytes reference needs to be released, and when not.
012 */
013public class ReleasablePagedBytesReference extends PagedBytesReference implements ReleasableBytesReference {
014
015    public ReleasablePagedBytesReference(BigArrays bigarrays, ByteArray bytearray, int length) {
016        super(bigarrays, bytearray, length);
017    }
018
019    public ReleasablePagedBytesReference(BigArrays bigarrays, ByteArray bytearray, int from, int length) {
020        super(bigarrays, bytearray, from, length);
021    }
022
023    @Override
024    public void close() throws ElasticsearchException {
025        Releasables.close(bytearray);
026    }
027}