<commit_before>package adapters

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"

	"github.com/prebid/prebid-server/pbs"

	"golang.org/x/net/context/ctxhttp"

	"github.com/prebid/openrtb"
)

type RubiconAdapter struct {
	http         *HTTPAdapter
	URI          string
	usersyncInfo *pbs.UsersyncInfo
	XAPIUsername string
	XAPIPassword string
}

/* Name - export adapter name */
func (a *RubiconAdapter) Name() string {
	return "Rubicon"
}

// used for cookies and such
func (a *RubiconAdapter) FamilyName() string {
	return "rubicon"
}

func (a *RubiconAdapter) GetUsersyncInfo() *pbs.UsersyncInfo {
	return a.usersyncInfo
}

type rubiconParams struct {
	AccountId int `json:"accountId"`
	SiteId    int `json:"siteId"`
	ZoneId    int `json:"zoneId"`
}

type rubiconImpExtRP struct {
	ZoneID int `json:"zone_id"`
}

type rubiconImpExt struct {
	RP rubiconImpExtRP `json:"rp"`
}

type rubiconSiteExtRP struct {
	SiteID int `json:"site_id"`
}

type rubiconSiteExt struct {
	RP rubiconSiteExtRP `json:"rp"`
}

type rubiconPubExtRP struct {
	AccountID int `json:"account_id"`
}

type rubiconPubExt struct {
	RP rubiconPubExtRP `json:"rp"`
}

type rubiconBannerExtRP struct {
	SizeID     int    `json:"size_id,omitempty"`
	AltSizeIDs []int  `json:"alt_size_ids,omitempty"`
	MIME       string `json:"mime"`
}

type rubiconBannerExt struct {
	RP rubiconBannerExtRP `json:"rp"`
}

type rubiSize struct {
	w uint64
	h uint64
}

var rubiSizeMap = map[rubiSize]int{
	rubiSize{w: 468, h: 60}:    1,
	rubiSize{w: 728, h: 90}:    2,
	rubiSize{w: 120, h: 600}:   8,
	rubiSize{w: 160, h: 600}:   9,
	rubiSize{w: 300, h: 600}:   10,
	rubiSize{w: 300, h: 250}:   15,
	rubiSize{w: 336, h: 280}:   16,
	rubiSize{w: 300, h: 100}:   19,
	rubiSize{w: 980, h: 120}:   31,
	rubiSize{w: 250, h: 360}:   32,
	rubiSize{w: 180, h: 500}:   33,
	rubiSize{w: 980, h: 150}:   35,
	rubiSize{w: 468, h: 400}:   37,
	rubiSize{w: 930, h: 180}:   38,
	rubiSize{w: 320, h: 50}:    43,
	rubiSize{w: 300, h: 50}:    44,
	rubiSize{w: 300, h: 300}:   48,
	rubiSize{w: 300, h: 1050}:  54,
	rubiSize{w: 970, h: 90}:    55,
	rubiSize{w: 970, h: 250}:   57,
	rubiSize{w: 1000, h: 90}:   58,
	rubiSize{w: 320, h: 80}:    59,
	rubiSize{w: 1000, h: 1000}: 61,
	rubiSize{w: 640, h: 480}:   65,
	rubiSize{w: 320, h: 480}:   67,
	rubiSize{w: 1800, h: 1000}: 68,
	rubiSize{w: 320, h: 320}:   72,
	rubiSize{w: 320, h: 160}:   73,
	rubiSize{w: 980, h: 240}:   78,
	rubiSize{w: 980, h: 300}:   79,
	rubiSize{w: 980, h: 400}:   80,
	rubiSize{w: 480, h: 300}:   83,
	rubiSize{w: 970, h: 310}:   94,
	rubiSize{w: 970, h: 210}:   96,
	rubiSize{w: 480, h: 320}:   101,
	rubiSize{w: 768, h: 1024}:  102,
	rubiSize{w: 480, h: 280}:   103,
	rubiSize{w: 1000, h: 300}:  113,
	rubiSize{w: 320, h: 100}:   117,
	rubiSize{w: 800, h: 250}:   125,
	rubiSize{w: 200, h: 600}:   126,
}

func lookupSize(s openrtb.Format) (int, error) {
	if sz, ok := rubiSizeMap[rubiSize{w: s.W, h: s.H}]; ok {<commit_msg>Use uint16 for W&H in rubicon sizemap (#51)<commit_after>package adapters

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"

	"github.com/prebid/prebid-server/pbs"

	"golang.org/x/net/context/ctxhttp"

	"github.com/prebid/openrtb"
)

type RubiconAdapter struct {
	http         *HTTPAdapter
	URI          string
	usersyncInfo *pbs.UsersyncInfo
	XAPIUsername string
	XAPIPassword string
}

/* Name - export adapter name */
func (a *RubiconAdapter) Name() string {
	return "Rubicon"
}

// used for cookies and such
func (a *RubiconAdapter) FamilyName() string {
	return "rubicon"
}

func (a *RubiconAdapter) GetUsersyncInfo() *pbs.UsersyncInfo {
	return a.usersyncInfo
}

type rubiconParams struct {
	AccountId int `json:"accountId"`
	SiteId    int `json:"siteId"`
	ZoneId    int `json:"zoneId"`
}

type rubiconImpExtRP struct {
	ZoneID int `json:"zone_id"`
}

type rubiconImpExt struct {
	RP rubiconImpExtRP `json:"rp"`
}

type rubiconSiteExtRP struct {
	SiteID int `json:"site_id"`
}

type rubiconSiteExt struct {
	RP rubiconSiteExtRP `json:"rp"`
}

type rubiconPubExtRP struct {
	AccountID int `json:"account_id"`
}

type rubiconPubExt struct {
	RP rubiconPubExtRP `json:"rp"`
}

type rubiconBannerExtRP struct {
	SizeID     int    `json:"size_id,omitempty"`
	AltSizeIDs []int  `json:"alt_size_ids,omitempty"`
	MIME       string `json:"mime"`
}

type rubiconBannerExt struct {
	RP rubiconBannerExtRP `json:"rp"`
}

type rubiSize struct {
	w uint16
	h uint16
}

var rubiSizeMap = map[rubiSize]int{
	rubiSize{w: 468, h: 60}:    1,
	rubiSize{w: 728, h: 90}:    2,
	rubiSize{w: 120, h: 600}:   8,
	rubiSize{w: 160, h: 600}:   9,
	rubiSize{w: 300, h: 600}:   10,
	rubiSize{w: 300, h: 250}:   15,
	rubiSize{w: 336, h: 280}:   16,
	rubiSize{w: 300, h: 100}:   19,
	rubiSize{w: 980, h: 120}:   31,
	rubiSize{w: 250, h: 360}:   32,
	rubiSize{w: 180, h: 500}:   33,
	rubiSize{w: 980, h: 150}:   35,
	rubiSize{w: 468, h: 400}:   37,
	rubiSize{w: 930, h: 180}:   38,
	rubiSize{w: 320, h: 50}:    43,
	rubiSize{w: 300, h: 50}:    44,
	rubiSize{w: 300, h: 300}:   48,
	rubiSize{w: 300, h: 1050}:  54,
	rubiSize{w: 970, h: 90}:    55,
	rubiSize{w: 970, h: 250}:   57,
	rubiSize{w: 1000, h: 90}:   58,
	rubiSize{w: 320, h: 80}:    59,
	rubiSize{w: 1000, h: 1000}: 61,
	rubiSize{w: 640, h: 480}:   65,
	rubiSize{w: 320, h: 480}:   67,
	rubiSize{w: 1800, h: 1000}: 68,
	rubiSize{w: 320, h: 320}:   72,
	rubiSize{w: 320, h: 160}:   73,
	rubiSize{w: 980, h: 240}:   78,
	rubiSize{w: 980, h: 300}:   79,
	rubiSize{w: 980, h: 400}:   80,
	rubiSize{w: 480, h: 300}:   83,
	rubiSize{w: 970, h: 310}:   94,
	rubiSize{w: 970, h: 210}:   96,
	rubiSize{w: 480, h: 320}:   101,
	rubiSize{w: 768, h: 1024}:  102,
	rubiSize{w: 480, h: 280}:   103,
	rubiSize{w: 1000, h: 300}:  113,
	rubiSize{w: 320, h: 100}:   117,
	rubiSize{w: 800, h: 250}:   125,
	rubiSize{w: 200, h: 600}:   126,
}

func lookupSize(s openrtb.Format) (int, error) {
	if sz, ok := rubiSizeMap[rubiSize{w: uint16(s.W), h: uint16(s.H)}]; ok {
{'fraction_non_alphanumeric': 0.16265865063460253, 'fraction_numerical': 0.11356045424181696, 'mean_word_length': 3.738132911392405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2441362', 'n_tokens_mistral': 3256, 'n_tokens_neox': 2661, 'n_words': 707}