Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
a15ce323
Commit
a15ce323
authored
Nov 27, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Styling fixes
parent
9e4ae9e3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
25 deletions
+46
-25
library/Solarium/Client/Adapter/Curl.php
library/Solarium/Client/Adapter/Curl.php
+3
-3
library/Solarium/Client/ResponseParser/Select/Component/Grouping.php
...arium/Client/ResponseParser/Select/Component/Grouping.php
+20
-7
library/Solarium/Client/ResponseParser/Select/Component/Stats.php
...Solarium/Client/ResponseParser/Select/Component/Stats.php
+1
-1
library/Solarium/Plugin/CustomizeRequest.php
library/Solarium/Plugin/CustomizeRequest.php
+1
-1
library/Solarium/Plugin/Loadbalancer.php
library/Solarium/Plugin/Loadbalancer.php
+18
-10
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
...ary/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
+3
-3
No files found.
library/Solarium/Client/Adapter/Curl.php
View file @
a15ce323
...
...
@@ -91,7 +91,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$uri
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_FOLLOWLOCATION
,
true
);
curl_setopt
(
$ch
,
CURLOPT_FOLLOWLOCATION
,
true
);
curl_setopt
(
$ch
,
CURLOPT_TIMEOUT
,
$options
[
'timeout'
]);
if
(
!
isset
(
$options
[
'headers'
][
'Content-Type'
]))
{
...
...
@@ -101,7 +101,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$options
[
'headers'
][
'Content-Type'
]
=
'text/xml; charset=utf-8'
;
}
if
(
count
(
$options
[
'headers'
]))
{
if
(
count
(
$options
[
'headers'
]))
{
$arr
=
array
();
foreach
(
$options
[
'headers'
]
as
$k
=>
$v
)
{
$arr
[]
=
$k
.
": "
.
$v
;
...
...
@@ -125,7 +125,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$headers
=
array
();
$data
=
''
;
if
(
$httpResponse
!==
false
)
{
if
(
$httpResponse
!==
false
)
{
$data
=
$httpResponse
;
$info
=
curl_getinfo
(
$ch
);
$headers
=
array
();
...
...
library/Solarium/Client/ResponseParser/Select/Component/Grouping.php
View file @
a15ce323
...
...
@@ -69,23 +69,34 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping
$valueGroups
=
array
();
foreach
(
$result
[
'groups'
]
as
$valueGroupResult
)
{
$value
=
(
isset
(
$valueGroupResult
[
'groupValue'
]))
?
$valueGroupResult
[
'groupValue'
]
:
null
;
$numFound
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'numFound'
]))
?
$valueGroupResult
[
'doclist'
][
'numFound'
]
:
null
;
$start
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'start'
]))
?
$valueGroupResult
[
'doclist'
][
'start'
]
:
null
;
$value
=
(
isset
(
$valueGroupResult
[
'groupValue'
]))
?
$valueGroupResult
[
'groupValue'
]
:
null
;
$numFound
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'numFound'
]))
?
$valueGroupResult
[
'doclist'
][
'numFound'
]
:
null
;
$start
=
(
isset
(
$valueGroupResult
[
'doclist'
][
'start'
]))
?
$valueGroupResult
[
'doclist'
][
'start'
]
:
null
;
// create document instances
$documentClass
=
$query
->
getOption
(
'documentclass'
);
$documents
=
array
();
if
(
isset
(
$valueGroupResult
[
'doclist'
][
'docs'
])
&&
is_array
(
$valueGroupResult
[
'doclist'
][
'docs'
]))
{
if
(
isset
(
$valueGroupResult
[
'doclist'
][
'docs'
])
&&
is_array
(
$valueGroupResult
[
'doclist'
][
'docs'
]))
{
foreach
(
$valueGroupResult
[
'doclist'
][
'docs'
]
as
$doc
)
{
$documents
[]
=
new
$documentClass
(
$doc
);
}
}
$valueGroups
[]
=
new
Solarium_Result_Select_Grouping_ValueGroup
(
$value
,
$numFound
,
$start
,
$documents
);
$valueGroups
[]
=
new
Solarium_Result_Select_Grouping_ValueGroup
(
$value
,
$numFound
,
$start
,
$documents
);
}
$groups
[
$field
]
=
new
Solarium_Result_Select_Grouping_FieldGroup
(
$matches
,
$groupCount
,
$valueGroups
);
$groups
[
$field
]
=
new
Solarium_Result_Select_Grouping_FieldGroup
(
$matches
,
$groupCount
,
$valueGroups
);
}
}
...
...
@@ -110,7 +121,9 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping
}
// create a group result object
$group
=
new
Solarium_Result_Select_Grouping_QueryGroup
(
$matches
,
$numFound
,
$start
,
$maxScore
,
$documents
);
$group
=
new
Solarium_Result_Select_Grouping_QueryGroup
(
$matches
,
$numFound
,
$start
,
$maxScore
,
$documents
);
$groups
[
$groupQuery
]
=
$group
;
}
}
...
...
library/Solarium/Client/ResponseParser/Select/Component/Stats.php
View file @
a15ce323
...
...
@@ -61,7 +61,7 @@ class Solarium_Client_ResponseParser_Select_Component_Stats
$statResults
=
$data
[
'stats'
][
'stats_fields'
];
foreach
(
$statResults
AS
$field
=>
$stats
)
{
if
(
isset
(
$stats
[
'facets'
]))
{
foreach
(
$stats
[
'facets'
]
as
$facetField
=>
$values
)
{
foreach
(
$stats
[
'facets'
]
as
$facetField
=>
$values
)
{
foreach
(
$values
as
$value
=>
$valueStats
)
{
$stats
[
'facets'
][
$facetField
][
$value
]
=
new
Solarium_Result_Select_Stats_FacetValue
(
$value
,
$valueStats
);
}
...
...
library/Solarium/Plugin/CustomizeRequest.php
View file @
a15ce323
...
...
@@ -238,7 +238,7 @@ class Solarium_Plugin_CustomizeRequest extends Solarium_Plugin_Abstract
// first validate
if
(
!
$customization
->
isValid
())
{
throw
new
Solarium_Exception
(
'Request customization with key "'
.
$key
.
'" is invalid'
);
throw
new
Solarium_Exception
(
'Request customization with key "'
.
$key
.
'" is invalid'
);
}
// apply to request, depending on type
...
...
library/Solarium/Plugin/Loadbalancer.php
View file @
a15ce323
...
...
@@ -199,7 +199,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param int $weight Must be a positive number
* @return self Provides fluent interface
*/
public
function
addServer
(
$key
,
$options
,
$weight
=
1
)
{
public
function
addServer
(
$key
,
$options
,
$weight
=
1
)
{
if
(
array_key_exists
(
$key
,
$this
->
_servers
))
{
throw
new
Solarium_Exception
(
'A server for the loadbalancer plugin must have a unique key'
);
}
else
{
...
...
@@ -330,7 +331,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
*
* @return array
*/
public
function
getBlockedQueryTypes
()
{
public
function
getBlockedQueryTypes
()
{
return
array_keys
(
$this
->
_blockedQueryTypes
);
}
...
...
@@ -342,7 +344,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param array $types Use an array with the constants defined in Solarium_Client as values
* @return self Provides fluent interface
*/
public
function
setBlockedQueryTypes
(
$types
)
{
public
function
setBlockedQueryTypes
(
$types
)
{
$this
->
clearBlockedQueryTypes
();
$this
->
addBlockedQueryTypes
(
$types
);
return
$this
;
...
...
@@ -354,7 +357,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param string $type Use one of the constants defined in Solarium_Client
* @return self Provides fluent interface
*/
public
function
addBlockedQueryType
(
$type
)
{
public
function
addBlockedQueryType
(
$type
)
{
if
(
!
array_key_exists
(
$type
,
$this
->
_blockedQueryTypes
))
{
$this
->
_blockedQueryTypes
[
$type
]
=
true
;
}
...
...
@@ -370,7 +374,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param array $types Use an array with the constants defined in Solarium_Client as values
* @return self Provides fluent interface
*/
public
function
addBlockedQueryTypes
(
$types
)
{
public
function
addBlockedQueryTypes
(
$types
)
{
foreach
(
$types
AS
$type
)
{
$this
->
addBlockedQueryType
(
$type
);
}
...
...
@@ -382,7 +387,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param string $type
* @return void
*/
public
function
removeBlockedQueryType
(
$type
)
{
public
function
removeBlockedQueryType
(
$type
)
{
if
(
array_key_exists
(
$type
,
$this
->
_blockedQueryTypes
))
{
unset
(
$this
->
_blockedQueryTypes
[
$type
]);
}
...
...
@@ -393,7 +399,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
*
* @return self Provides fluent interface
*/
public
function
clearBlockedQueryTypes
()
{
public
function
clearBlockedQueryTypes
()
{
$this
->
_blockedQueryTypes
=
array
();
}
...
...
@@ -462,7 +469,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param Solarium_Client_Request $request
* @return Solarium_Client_Response $response
*/
protected
function
_getLoadbalancedResponse
(
$request
)
{
protected
function
_getLoadbalancedResponse
(
$request
)
{
$this
->
_serverExcludes
=
array
();
// reset for each query
$adapter
=
$this
->
_client
->
getAdapter
();
...
...
@@ -471,7 +479,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
$e
=
new
Solarium_Exception
(
'Maximum number of loadbalancer retries reached'
);
for
(
$i
=
0
;
$i
<=
$this
->
getFailoverMaxRetries
();
$i
++
)
{
for
(
$i
=
0
;
$i
<=
$this
->
getFailoverMaxRetries
();
$i
++
)
{
$options
=
$this
->
_getRandomServerOptions
();
$adapter
->
setOptions
(
$options
);
try
{
...
...
@@ -524,7 +532,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
{
if
(
$this
->
_randomizer
===
null
)
{
$choices
=
array
();
foreach
(
$this
->
_servers
AS
$key
=>
$settings
)
{
foreach
(
$this
->
_servers
AS
$key
=>
$settings
)
{
$choices
[
$key
]
=
$settings
[
'weight'
];
}
$this
->
_randomizer
=
new
Solarium_Plugin_Loadbalancer_WeightedRandomChoice
(
$choices
);
...
...
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
View file @
a15ce323
...
...
@@ -75,7 +75,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice
public
function
__construct
(
$choices
)
{
$i
=
0
;
foreach
(
$choices
AS
$key
=>
$weight
)
{
foreach
(
$choices
AS
$key
=>
$weight
)
{
if
(
$weight
<=
0
)
throw
new
Solarium_Exception
(
'Weight must be greater than zero'
);
$this
->
_totalWeight
+=
$weight
;
...
...
@@ -100,7 +100,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice
// continue until a non-excluded value is found
// @todo optimize?
while
(
1
)
{
while
(
1
)
{
$result
=
$this
->
_values
[
$this
->
_getKey
()];
if
(
!
in_array
(
$result
,
$excludes
))
return
$result
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment