func (db *DB) findPosForIPV4(ip uint32) (uint32, error) {
	indexaddr := ip >> 16
	low := db.ipv4Indexes[indexaddr][0]
	high := db.ipv4Indexes[indexaddr][1]
	for low <= high {
		mid := (low + high) / 2
		rowOffset := db.header.BaseAddr + (mid * uint32(db.header.IPv4ColumnSize)) - 1
		ipFrom, err := db.readUint32(rowOffset)
		if err != nil {
			return 0, errors.Annotate(err, "cannot read db index")
		}
		ipTo, err := db.readUint32(rowOffset + uint32(db.header.IPv4ColumnSize))
		if err != nil {
			return 0, errors.Annotate(err, "cannot read db index")
		}
		if ipFrom <= ip && ipTo >= ip {
			return rowOffset, nil
		}
		if ipFrom > ip {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return 0, nil
}
// lookups a pos in db for an ipv4 addr
lookups a pos in db for an ipv4 addr
// lookups a pos in db for an ipv4 addr
func (db *DB) findPosForIPV4(ip uint32) (uint32, error) {
	indexaddr := ip >> 16
	low := db.ipv4Indexes[indexaddr][0]
	high := db.ipv4Indexes[indexaddr][1]
	for low <= high {
		mid := (low + high) / 2
		rowOffset := db.header.BaseAddr + (mid * uint32(db.header.IPv4ColumnSize)) - 1
		ipFrom, err := db.readUint32(rowOffset)
		if err != nil {
			return 0, errors.Annotate(err, "cannot read db index")
		}
		ipTo, err := db.readUint32(rowOffset + uint32(db.header.IPv4ColumnSize))
		if err != nil {
			return 0, errors.Annotate(err, "cannot read db index")
		}
		if ipFrom <= ip && ipTo >= ip {
			return rowOffset, nil
		}
		if ipFrom > ip {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return 0, nil
}
func ( db * DB ) findPosForIPV4 ( ip uint32 ) ( uint32 , error ) { indexaddr := ip >> 16 low := db . ipv4Indexes [ indexaddr ] [ 0 ] high := db . ipv4Indexes [ indexaddr ] [ 1 ] for low <= high { mid := ( low + high ) / 2 rowOffset := db . header . BaseAddr + ( mid * uint32 ( db . header . IPv4ColumnSize ) ) - 1 ipFrom , err := db . readUint32 ( rowOffset ) if err != nil { return 0 , errors . Annotate ( err , " " ) } ipTo , err := db . readUint32 ( rowOffset + uint32 ( db . header . IPv4ColumnSize ) ) if err != nil { return 0 , errors . Annotate ( err , " " ) } if ipFrom <= ip && ipTo >= ip { return rowOffset , nil } if ipFrom > ip { high = mid - 1 } else { low = mid + 1 } } return 0 , nil }
lookups a pos in db for an ipv4 addr
lookups a pos in db for an ipv4 addr