public static void save(ByteBufferWriter byteBufferWriter,
                            Holder<ByteBuffer> buffer,
                            List<? extends Serializable> saveList) throws IOException {
        ByteBuffer bb = buffer.get();
        while (true) {
            boolean serializeOk = true;
            bb.clear();
            for (Serializable s : saveList) {
                if (!s.serialize(bb)) {
                    serializeOk = false;
                    break;
                }
            }
            if (serializeOk) {
                bb.flip();
                byteBufferWriter.write(bb);
                return;
            } else {
                int nextCap = bb.capacity() << 1;
                ByteBufferUtil.free(bb);
                bb = ByteBufferUtil.allocateDirect(nextCap);
                buffer.set(bb);
            }
        }
    }
Save objects. Objects will first seralized into buffer, then flushed into writer.

@param byteBufferWriter the distination to save.
@param buffer           the buffer used to cache object data, which could be updated(expand size) by this method.
                        Normally it should be reused.
@param saveList         the objects to save.
indexr-common/src/main/java/io/indexr/util/Serializable.java