func NewForUtilFrom(in DataInput) (fu *ForUtil, err error) {
	self := &ForUtil{}
	packedIntsVersion, err := in.ReadVInt()
	if err != nil {
		return self, err
	}
	packed.CheckVersion(packedIntsVersion)
	self.encodedSizes = make([]int32, 33)
	self.encoders = make([]packed.PackedIntsEncoder, 33)
	self.decoders = make([]packed.PackedIntsDecoder, 33)
	self.iterations = make([]int32, 33)
	for bpv := 1; bpv <= 32; bpv++ {
		code, err := in.ReadVInt()
		if err != nil {
			return self, err
		}
		formatId := uint32(code) >> 5
		bitsPerValue := (uint32(code) & 31) + 1
		format := packed.PackedFormat(formatId)
		self.encodedSizes[bpv] = encodedSize(format, packedIntsVersion, bitsPerValue)
		self.encoders[bpv] = packed.GetPackedIntsEncoder(format, packedIntsVersion, bitsPerValue)
		self.decoders[bpv] = packed.GetPackedIntsDecoder(format, packedIntsVersion, bitsPerValue)
		self.iterations[bpv] = computeIterations(self.decoders[bpv])
	}
	return self, nil
}
/* Restore a ForUtil from a DataInput.
package lucene41
import (
	"fmt"
	"github.com/balzaczyy/golucene/core/util"
	"github.com/balzaczyy/golucene/core/util/packed"
	"math"
)
const (
	ALL_VALUES_EQUAL = 0
	MAX_ENCODED_SIZE = LUCENE41_BLOCK_SIZE * 4
)
var MAX_DATA_SIZE int = computeMaxDataSize()
func computeMaxDataSize() int {
	maxDataSize := 0
	for version := packed.PACKED_VERSION_START; version <= packed.VERSION_CURRENT; version++ {
		for format := packed.PACKED; format <= packed.PACKED_SINGLE_BLOCK; format++ {
			for bpv := 1; bpv <= 32; bpv++ {
				if !packed.PackedFormat(format).IsSupported(bpv) {
					continue
				}
				decoder := packed.GetPackedIntsDecoder(packed.PackedFormat(format), int32(version), uint32(bpv))
				iterations := int(computeIterations(decoder))
				if n := iterations * decoder.ByteValueCount(); n > maxDataSize {
					maxDataSize = n
				}
			}
		}
	}
	return maxDataSize
}
type ForUtil struct {
	encodedSizes []int32
	encoders     []packed.PackedIntsEncoder
	decoders     []packed.PackedIntsDecoder
	iterations   []int32
}
func NewForUtilInto(accetableOverheadRatio float32, out util.DataOutput) (*ForUtil, error) {
	ans, err := &ForUtil{}, out.WriteVInt(packed.VERSION_CURRENT)
	if err != nil {
		return ans, err
	}
	ans.encodedSizes = make([]int32, 33)
	ans.encoders = make([]packed.PackedIntsEncoder, 33)
	ans.decoders = make([]packed.PackedIntsDecoder, 33)
	ans.iterations = make([]int32, 33)
	packedIntsVersion := int32(packed.VERSION_CURRENT)
	for bpv := 1; bpv <= 32; bpv++ {
		formatAndBits := packed.FastestFormatAndBits(
			LUCENE41_BLOCK_SIZE, bpv, accetableOverheadRatio)
		format := formatAndBits.Format
		bitsPerValue := formatAndBits.BitsPerValue
		assert(format.IsSupported(bitsPerValue))
		assert(bitsPerValue <= 32)
		ans.encodedSizes[bpv] = encodedSize(format, packedIntsVersion, uint32(bitsPerValue))
		ans.encoders[bpv] = packed.GetPackedIntsEncoder(format, packedIntsVersion, uint32(bitsPerValue))
		ans.decoders[bpv] = packed.GetPackedIntsDecoder(format, packedIntsVersion, uint32(bitsPerValue))
		ans.iterations[bpv] = computeIterations(ans.decoders[bpv])
		err = out.WriteVInt(int32(format.Id()<<5 | (bitsPerValue - 1)))
		if err != nil {
			return ans, err
		}
	}
	return ans, err
}
func assert(ok bool) {
	if !ok {
		panic("assert fail")
	}
}
func assert2(ok bool, msg string, args ...interface{}) {
	if !ok {
		panic(fmt.Sprintf(msg, args...))
	}
}
type DataInput interface {
	ReadVInt() (n int32, err error)
}