while (is.available() > 0) {
final int storedDocId = is.readInt();
final byte section = is.readByte();
final int gidsCount = is.readInt();
//Read (variable) length of node IDs + frequency + offsets
final int length = is.readFixedInt();
if (storedDocId != document.getDocId()) {
// data are related to another document:
// copy them to any existing data
os.writeInt(storedDocId);
os.writeByte(section);