Specific embodiment
It is by the following examples and referring to the drawings, right to make the object, technical solutions and advantages of the present invention become more apparent
The present invention is further described.
Fig. 1 is a kind of structure chart of advertisement delivery system provided in an embodiment of the present invention, and the system includes:
Advertising database server A dDBServer, for storing the ad data related to advertisement putting, comprising:Client
Data, contract dataset, fixed condition, ad material etc..
Back-stage management server MServer, for timing ad data is extracted from advertising database server, is generated and is thrown
Put condition tree data object, and the fixed condition tree data object generated in local cache;It is pre- that MServer can be additionally used in advertisement
A series of management functions such as fixed, waiting, material setting.
Front end advertisement releasing server CastServer, throws for timing from the advertisement that back-stage management server extracts caching
Put condition tree data object and locally cached, when the ad-request of user terminal transmission is received, based on described wide
Accuse fixed condition tree and search and meet the advertisement of fixed condition, and return ad code to requesting party.
Ad material server I deaServer, for the ad material that storage is actually subjected to play, and is receiving use
During the request of the ad material of the acquisition actual play that family terminal is initiated, to user terminal the ad material of actual play is returned.
User terminal is received after the ad code that front end advertisement releasing server is returned, and obtains actual by parsing code
The ad material mark of needs, then initiates the request of the ad material of acquisition actual play, advertisement to ad material server
Material server returns corresponding ad material according to request.The ad material can be video, flash, picture etc..
In order to tackle large-scale concurrent ad-request, mitigate the load of database server, the present invention adopts two-stage
Data buffer storage mechanism, and throw on server CastServer using distribution in back-stage management server MServer and front end
Formula network-caching instrument (such as Memcache, redis) is carrying out the caching of data.Mserver timings are from advertising database clothes
Ad data to be put is obtained in business device AdDBServer, fixed condition tree data object is generated, then by distributed network
The write set operating functions that network cache tools is provided write the fixed condition tree data object for being generated in the caching of the machine;
The acquisition get that CastServer can be provided regularly by distributed network cache tools is operated and read from the caching of MServer
It is data cached, in being loaded into the machine caching.
The background server and front end are thrown in when server is cached to the ad data and are tied using tree data
Structure is fixed condition tree reflecting the priority of different fixed condition and fixed condition, each layer of correspondence of fixed condition tree
Rank advertisement throws in priority, the different fixed condition of each branch's correspondence, and specifically, the present invention uses Hash figure HashMap
Every first nodes in construct the fixed condition tree in addition to leaf node, by the key in HashMap key-value pairs come anti-
Fixed condition is reflected, next stage HashMap is linked by the value in HashMap key-value pairs, the correspondence one per one-level HashMap
Level advertisement putting priority;
The bottom leaf node of the fixed condition tree is the ad material for meeting fixed condition indicated by upper layer node
The set of mark, for depositing fixed condition identical ad material mark, the set can pass through list List, array, chain
The data types such as table are expressing.
Preferably, in order to ensure efficiently input, front end is thrown in and mounted between server CastServer and user terminal
Load-balanced server HaproxyServer, when certain behavior (as opened a video playback page) of user on website is touched
When having sent out an ad-request, the request can be obtained first by HaproxyServer, and then HaproxyServer can pass through one
Fixed strategy forwards the request to one in multiple CastServer, and this CastServer is again in the caching of its machine
Advertisement matching is carried out, if finding suitable advertisement, to requesting party the ad code to be thrown in is returned.
In the preferred embodiment of the present invention, fixed condition tree is constructed by multistage Hash figure HashMap and list List
Data object, in advertisement delivery system ad data to be put be exactly with this structure deposit in the buffer, its structure with
Java styles can be described as follows:
HashMap<String,HashMap<String,...,HashMap<String,List<String>>...>>
As described above as can be seen that the data structure be not completely fixed it is constant, can because of advertisement delivery system
The input function of required support and it is different.Wherein representing internal in ellipsis has several nested HashMap structures.
HashMap is to carry out data storage in key-value pair (key-value) mode, and it is stored in key assignments in put (key, value) method
It is right, value is obtained in get (key) method, its advantage can be that data search is completed in linear time complexity, without
Whole set is all traveled through when searching every time.Innermost layer is List objects, and it then provide not only in random access list and specifies
The element of position, can be with add (value) addition element, with the element that remove (index) method deletes specified location.
The building method of the fixed condition tree is as follows:
Step 1, determine that advertisement has which specific input requires;
For example video ads throw in priority level requirement be:
A, advertisement throw mode for override consideration surely:Video group throw surely advertisement priority highest, crowd throw surely advertisement take second place,
Third other throw mode surely, other advertisements must meet long advertisement (the at present advertisement more than 7 seconds is considered long advertisement, otherwise for
Short advertisement) only throw in long video, short advertisement is only thrown in short-sighted frequency;
Whether B, N+ advertisements are that second priority considers:N+ advertisements have precedence over non-N+ advertisements and are thrown in;
C, levels of clients are to pay the utmost attention to again:Levels of clients has V (VIP client), A, B, C, D, E etc., and rank is higher,
Release sequence is more forward;
D, mode is thrown surely and in the case of whether N+ restriction, levels of clients etc. are the same from, do specifically input restrictive condition
It is more harsh, more preferential input, such as:Surely the advertisement of the TV play of Beijing area is thrown, the advertisement for only throwing TV play surely is had precedence over;
Under E, identical fixed condition:By cost per thousand (Cost Per Mille, CPM) throw in advertisement, have precedence over by
The advertisement that full flow is thrown in.
Step 2, according to the specific functional requirement of advertisement delivery system determining the concrete structure of fixed condition tree, it is substantially former
It is then:Each advertisement putting condition priority does not require to take one-level HashMap, by key-value pair in the HashMap per one-level
(i.e. key-value to) is constituted, and different fixed conditions are reflected by the key in the key-value pair of HashMap, is passed through
Value in HashMap key-value pairs is finished linking next stage HashMap until the HashMap of all priority levels is created,
Value in afterbody HashMap key-value pairs then deposits a list List data object, and what is deposited in List is to throw in bar
The set of part identical ad material ID, ad material ID is the unique mark of an ad material.
For example, the requirement of priority level is thrown in based on the video ads given in step 1, it should use " 5 layers of HashMap+
1 layer of List " is described as constructing the fixed condition tree with java dictions:
HashMap<String,HashMap<String,HashMap<String,HashMap<String,HashMap<
String,List>>>>>CondTree;
The concrete structure of the fixed condition tree for being constructed can be found in the example of accompanying drawing 2.
That what is deposited in the List of innermost layer in step 3, above-mentioned data structure is only the ID of ad material, is actually carried out wide
Accusing needs the particularly relevant parameter that the advertisement specifically to be thrown in is obtained according to the ID of ad material when input, such as:Advertisement element
The related contents such as material url, exposure monitoring url, click monitoring url.Above-mentioned particularly relevant parameter can be organized as an object,
Then it is cached in HashMap modes, its structure is defined as with java styles:
HashMap<Interger, AdEntity>adEntityMap;
Key therein is ad material ID, and value is an AdEntity object, in object deposit ad material url,
The related contents such as exposure monitoring url, click monitoring url.During actual input, the fixed condition tree that first can be constructed in step 2
Advertisement matching is carried out in CondTree objects, suitable ad material ID is obtained, is then arrived further according to this ID
The relevant parameter one in the url of specific ad material detail parameters, these parameters and user's request is obtained in adEntityMap
Rise and be organized into ad code, be then returned to player, player is responsible for processing follow-up showing advertisement.
After acquirement one is currently at the advertisement of Fertilizing stage from advertising database, needs are loaded into the advertisement above-mentioned
In fixed condition tree.Below based on the building method of above-mentioned fixed condition tree, the input bar of the description advertisement delivery system that gives an actual example
The loading process of part tree, as shown in Figure 3:
Step 101, obtain from advertising database one it is current in ad material (idea) the list ideaList for throwing;
Step 102, the whether ad material of process also in need is judged in ideaList, from ideaList lists if having
One ad material of middle taking-up, then execution step 103;Otherwise terminate flow process;
Step 103, according to the association attributes of current ad material come determine taken out ad material the first order close
Key word key1;
The value of key1 determines by the association attributes of idea, for example:If the advertisement is video group or crowd throwing surely, for v;
Otherwise, then it is l if long advertisement;Then it is s if short advertisement;
Step 104, it is that whether matching deposits in first order HashMap (hereinafter referred to as map1) in the root node of fixed condition tree
In the next stage HashMap (hereinafter referred to as map2) with key1 as keyword, execution step 105 if not existing;Otherwise perform
Step 106;
Step 105, with key1 key construction map2, and key-value pair (key1, map2) is stored in into map1;
Perform sentence shape such as:Map2=new HashMap<String,HashMap<String,HashMap<String,
HashMap<String,List<String>>>>>();
Step 106, according to the association attributes of current ad material determining the second level keyword of the ad material
key2;
Key2 equally determines by the association attributes of idea, for example:If idea is N+ advertisements, key2 is entered as n;It is no
Then, it is entered as g;
Step 107, judge whether in map2 next stage HashMap with key2 as keyword (hereinafter referred to as
Map3), execution step 108 if not existing;Otherwise execution step 109;
Step 108, with key2 key construction map3, and key-value pair (key2, map3) is stored in into map2;
Perform sentence shape such as:Map3=new HashMap<String,HashMap<String,HashMap<String,
List<String>>>>();
Step 109, according to the association attributes of current ad material determining the third level keyword of the ad material
key3;
Key3 equally determines by the association attributes of ad material, for example:Its value is the advertisement visitor corresponding to ad material
Family rank, the mark of the levels of clients can be by the letter mark such as V, A, B, C, D, E, S;
Step 110, judge whether in map3 next stage HashMap with key3 as keyword (hereinafter referred to as
Map4), execution step 111 if not existing;Otherwise execution step 112;
Step 111, with key3 key construction map4, and key-value pair (key3, map4) is stored in into map3;
Perform sentence shape such as:Map4=new HashMap<String,HashMap<String,List<String>>>
();
Step 112, according to the association attributes of current ad material determining the fourth stage keyword of the ad material
key4;
Key4 is equally determined that its value depends on the concrete of idea to throw mode surely, for example by the association attributes of ad material:
Av (representing that area+video group is thrown surely), ac (area+crowd throws surely), p (classification is fixed to throw) etc.;
Step 113, judge whether in map4 next stage HashMap with key4 as keyword (hereinafter referred to as
Map5), execution step 114 if not existing;Otherwise execution step 115;
Step 114, with key4 key construction map5, and key-value pair (key4, map5) is stored in into map4;
Perform sentence shape such as:Map5=new HashMap<String,List<String>>();
Step 115, according to the association attributes of current ad material determining the level V keyword of the ad material
key5;
Step 116, the next stage List objects for judging whether in map5 with key5 as keyword, if not existing
Execution step 117;Otherwise execution step 118;
Step 117, newly-built List objects, and key-value pair key5-List is added in map5;
Step 118, the ad material being added to Current ad material id pointed by the corresponding List of key5 in map5 are arranged
In table, if corresponding ad material list is not present, it is newly-built after restore.Then execution step 102 again.
After server is thrown in front end receives ad-request, according to the parameter in ad-request, based on fixed condition tree
Lookup meets the advertisement of fixed condition, and returns ad code to requesting party.It is corresponding steps flow chart to be loaded with above-mentioned advertisement
Advertisement matches comprising the following steps that for flow process:
Step 201, from received ad-request obtain required parameter;
Series of parameters in ad-request can be organized in the form of following ReqParam objects:
public class ReqParam{
private String vid;// video id
private String s;Program id corresponding to // video
private String ct;First-level class belonging to // video, such as:TV play, film, variety, amusement etc.
private String cs;Secondary classification belonging to // video, it has a unique corresponding first-level class, such as:
Continent is acute, Hong Kong and Taiwan are acute, South Korean TV soaps, and it is all secondary classification under first-level class TV play to wait
private String provinceId;The province that // active user is located, can pass through the ip information in user's request
Obtain
private String cityId;The city that // active user is located, can be obtained by the ip information in user's request
Take
private String uid;The account (user id) of the user of // upload current video
private String t;The playing duration of // video
private String keyword;The keyword of // video request institute band
private String partnerid;// partner id
}
Step 202, from the parameter of ad-request obtain first order Keyword List;
According to ad-request parameter reqParam, the corresponding key1 lists of sorted current level map are obtained;
Step 203, from first order Keyword List take out a untreated first order keyword key1, execution step
204;All it is disposed and does not find the advertisement that can be thrown in yet if first order Keyword List is empty or all of keyword, goes to
Step 218;
Step 204, in first order HashMap (hereinafter referred to as map1) matching key1, obtain the corresponding next stage of key1
HashMap (hereinafter referred to as map2);
Step 205;The second level Keyword List with key1 as higher level's keyword is obtained from ad-request parameter;
Step 206, from second level Keyword List take out a untreated second level keyword key2, execution step
207;All it is disposed and does not find the advertisement that can be thrown in yet if second level Keyword List is empty or all of keyword, returns
Execution step 203;
Step 207, key2 is matched in map2, obtain the corresponding next stage HashMap (hereinafter referred to as map3) of key2;
Step 208;The third level Keyword List with key2 as higher level's keyword is obtained from ad-request parameter;
Step 209, from third level Keyword List take out a untreated third level keyword key3, execution step
210;All it is disposed and does not find the advertisement that can be thrown in yet if third level Keyword List is empty or all of keyword, returns
Execution step 206;
Step 210, key3 is matched in map3, obtain the corresponding next stage HashMap (hereinafter referred to as map4) of key3;
Step 211;The fourth stage Keyword List with key3 as higher level's keyword is obtained from ad-request parameter;
Step 212, from fourth stage Keyword List take out a untreated fourth stage keyword key4, execution step
213;All it is disposed and does not find the advertisement that can be thrown in yet if fourth stage Keyword List is empty or all of keyword, returns
Execution step 209;
Step 213, key4 is matched in map4, obtain the corresponding next stage HashMap (hereinafter referred to as map5) of key4;
Step 214;The level V Keyword List with key4 as higher level's keyword is obtained from ad-request parameter;
Step 215, from level V Keyword List take out a untreated level V keyword key5, execution step
216;All it is disposed and does not find the advertisement that can be thrown in yet if level V Keyword List is empty or all of keyword, returns
Execution step 212;
Step 216, in map5 keyword key5 is matched, obtain the corresponding ad material list adList of key5;
Step 217, from the afterbody advertisement that successively Look-ahead can be thrown in of adList, if finding the advertisement that can be thrown in,
Return corresponding ad material mark;If certain advertisement in adList is thrown in finishing, the advertisement is deleted from adList
Ad material mark;If not finding the advertisement that can be thrown in adList, execution step 215 (returns to upper level
map)。
Step 218, return null character string, terminate flow process.
By taking the fixed condition tree shown in accompanying drawing 2 as an example, traveled through according to above-mentioned rule, its process is:
(1) first search downwards from root node, be sequentially followed successively by:k1v、k2n、k3o、k4s、k5s1;
(2) reach after layer 5, obtain first list, then start to access forward from list end, be followed successively by:idm、
id(m-1)、...、id1;
(3) reach first list foremost after, if still not finding the advertisement that can be thrown in, return to last layer
K5s2;
(4) and then from k5s2 second list is found again, then start from list end again to access forward, be followed successively by:
idn、id(n-1)、...、id(m+1)。
By above-mentioned rule, finally can complete to whole fixed condition traversal of tree.
Embodiment one:
Such as certain video website, the requirement to (video ads played i.e. before video playback) input of signposting before it is such as
Under:
(1) video group is thrown surely, crowd throws surely, user throws surely, keyword is thrown surely, the fixed throwing+classification in area to be required to offer
(channel) is thrown calmly, calmly mode is thrown in throwing etc. surely for classification;
(2) it is required to provide the N+ limitation functions to advertisement;
(3) client can be divided into by several grades according to the importance of client, the advertisement of high-grade client should be protected
Card has precedence over the advertisement putting of inferior grade client, but video group throw the advertisement for throwing class surely with crowd surely then need not be according to client etc.
Level is determining release sequence;
(4) to improve Consumer's Experience, in short-sighted frequency (videos within 5 minutes), (duration is less than can only to throw in short front patch
7 seconds), in long video (videos of more than 5 minutes), long front patch (duration is more than 7 seconds) can only be thrown in, but video group is thrown surely
It is then not limited with the advertisement that crowd throws class surely;
According to above-mentioned requirements, ad data can be completed using the data splitting structure of " 5 grades of HashMap+1 levels List "
Caching.The composition of each grade of key is illustrated below.
The key of the wherein first order is set as follows:
v:Throw calmly for video group (videogroup), crowd throws series advertisements surely, due to this kind of mode of throwing surely, length is wide
Announcement is only thrown long video, short advertisement and is only thrown in short-sighted frequency, and determines release sequence not according to levels of clients, so they return
For a class.
l:For only throwing the long advertisement in long video.
s:For only throwing the short advertisement in short-sighted frequency.
Second level key implications:
n:N+ advertisements
f:Non- N+ advertisements
Third level key implications:
a、b、c、d、e:The advertisement of A, B, C, D, E level client is represented respectively, and rank is reduced successively
Fourth stage key implications:
s:The advertisement that video group is thrown surely
c:Crowd throws advertisement surely
u:User throws advertisement surely (advertisement is only thrown in the video of specified user)
k:Keyword throws advertisement surely
p:Advertisement is thrown in classification surely
Level V key implications:
It is made up of fourth stage key title+key values, such as:
c3:Specify the advertisement thrown in white collar women (crowd id is 3) crowd.
a11pd:Specify and throw in Beijing area (province id:11) and in TV play classification (classification id:D) advertisement under.
Such as, certain ad-request, corresponding parameter value is respectively:
Ergodic process is as follows:
(1) first depth first searching is carried out to five layers of Map:Key1=v->Key2=n->Key3=a->Key4=s->
Key5=s13339;
(2) List is obtained according to the corresponding value of key5, then Look-ahead is started from list tail to List, if
An advertisement for meeting fixed condition (injected volume does not exhaust and meet the restriction of advertisement putting frequency N+) is found, is just thrown in;Otherwise
In returning to the map of last layer, it is further continued for depth-first and searches downwards.
Embodiment two:
Such as input of certain website to page ad (advertisement i.e. on webpage in addition to the video ads in video player)
Demand has:
(1) be required to provide area it is fixed throw, user throws surely, advertisement position (certain specified location i.e. on webpage) is thrown calmly,
Keyword throws etc. four kinds and throws mode, and four kinds of multiple modes for being combined with each other input determined in throwing mode surely surely;
(2) advertisement must be thrown on certain advertisement position on webpage, so advertisement position is the essential option in combination.
According to above-mentioned requirements, advertisement number can be completed using the data splitting structure of " 2 grades of HashMap+1 levels List "
According to caching.The composition of each grade of key is illustrated below:
The key of the wherein first order is set as follows:
aupk:Area+user+classification+keyword throws advertisement surely
upk:User+classification+keyword throws advertisement surely
apk:Area+classification+keyword throws advertisement surely
aup:Advertisement is thrown in area+user+classification surely
pk:Classification+keyword throws advertisement surely
up:Advertisement is thrown in user+classification surely
ap:Advertisement is thrown in area+classification surely
p:Advertisement is thrown in classification surely
Second level key is made up of first order key title+key values, such as:
The new the Water Margins of a11p47k:Represent in apk (area+advertisement position+keyword) determines throwing mode, it is intended that throw in Beijing
(advertisement position is for " the first screen-top layout of a page without columns " for (province ID be 11), placement position:47), front-page keyword contains:The page of new the Water Margin
The advertisement in face.
The content deposited in the List of the third level remains ad material ID, identical with example one.
Understood based on the embodiment of the present invention, present invention employs tree data structure to store ad data, compared to it
Its storage mode, greatlys save memory space.Common ad system when advertisement putting is carried out, often respectively with difference
Stereotactic conditions carry out advertisement matching in ad queue successively, every time matching to advertising listing all equivalent to having made once time
Go through, and in the present invention, due to all advertisements to be put being got up to form one according to priority and fixed condition laminated tissue
The structure of tree-shaped, the process of matching is the process of the extreme saturation to setting, and its time complexity is linear time complexity, most
Many need complete whole advertisement matching work by carrying out once the complete extreme saturation to tree, therefore, the matching effect of advertisement
Rate and input are in hgher efficiency, save a large amount of server operation amounts.
The above, only presently preferred embodiments of the present invention is not intended to limit protection scope of the present invention.