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
404be18c
Commit
404be18c
authored
Mar 24, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various code standard fixes
parent
e28de900
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
115 additions
and
43 deletions
+115
-43
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+25
-9
library/Solarium/Core/Client/Endpoint.php
library/Solarium/Core/Client/Endpoint.php
+3
-1
library/Solarium/Core/Client/Request.php
library/Solarium/Core/Client/Request.php
+5
-2
library/Solarium/Core/Query/Helper.php
library/Solarium/Core/Query/Helper.php
+3
-1
library/Solarium/Core/Query/RequestBuilder.php
library/Solarium/Core/Query/RequestBuilder.php
+3
-1
library/Solarium/Plugin/CustomizeRequest/Customization.php
library/Solarium/Plugin/CustomizeRequest/Customization.php
+6
-2
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
...ary/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
+7
-3
library/Solarium/Plugin/ParallelExecution.php
library/Solarium/Plugin/ParallelExecution.php
+6
-2
library/Solarium/Plugin/PrefetchIterator.php
library/Solarium/Plugin/PrefetchIterator.php
+7
-5
library/Solarium/Query/MoreLikeThis/ResponseParser.php
library/Solarium/Query/MoreLikeThis/ResponseParser.php
+1
-1
library/Solarium/Query/Select/Query/Component/Facet/Facet.php
...ary/Solarium/Query/Select/Query/Component/Facet/Facet.php
+3
-1
library/Solarium/Query/Select/Query/Component/Facet/MultiQuery.php
...olarium/Query/Select/Query/Component/Facet/MultiQuery.php
+3
-1
library/Solarium/Query/Select/Query/Component/Grouping.php
library/Solarium/Query/Select/Query/Component/Grouping.php
+3
-1
library/Solarium/Query/Select/Query/FilterQuery.php
library/Solarium/Query/Select/Query/FilterQuery.php
+3
-1
library/Solarium/Query/Select/Query/Query.php
library/Solarium/Query/Select/Query/Query.php
+2
-2
library/Solarium/Query/Select/ResponseParser/Component/FacetSet.php
...larium/Query/Select/ResponseParser/Component/FacetSet.php
+3
-1
library/Solarium/Query/Select/ResponseParser/ResponseParser.php
...y/Solarium/Query/Select/ResponseParser/ResponseParser.php
+1
-1
library/Solarium/Query/Update/Query/Query.php
library/Solarium/Query/Update/Query/Query.php
+31
-8
No files found.
library/Solarium/Core/Client/Client.php
View file @
404be18c
...
...
@@ -265,7 +265,9 @@ class Client extends Configurable
$this
->
endpoints
[
$key
]
=
$endpoint
;
// if no default endpoint is set do so now
if
(
null
==
$this
->
defaultEndpoint
)
$this
->
defaultEndpoint
=
$key
;
if
(
null
==
$this
->
defaultEndpoint
)
{
$this
->
defaultEndpoint
=
$key
;
}
}
return
$this
;
...
...
@@ -300,9 +302,11 @@ class Client extends Configurable
*/
public
function
getEndpoint
(
$key
=
null
)
{
if
(
null
==
$key
)
$key
=
$this
->
defaultEndpoint
;
if
(
null
==
$key
)
{
$key
=
$this
->
defaultEndpoint
;
}
if
(
!
isset
(
$this
->
endpoints
[
$key
])){
if
(
!
isset
(
$this
->
endpoints
[
$key
]))
{
throw
new
Exception
(
'Endpoint '
.
$key
.
' not available'
);
}
...
...
@@ -497,7 +501,9 @@ class Client extends Configurable
// support both "key=>value" and "(no-key) => array(key=>x,query=>y)" formats
if
(
is_array
(
$class
))
{
if
(
isset
(
$class
[
'type'
]))
$type
=
$class
[
'type'
];
if
(
isset
(
$class
[
'type'
]))
{
$type
=
$class
[
'type'
];
}
$class
=
$class
[
'query'
];
}
...
...
@@ -555,7 +561,9 @@ class Client extends Configurable
{
foreach
(
$plugins
as
$key
=>
$plugin
)
{
if
(
!
isset
(
$plugin
[
'key'
]))
$plugin
[
'key'
]
=
$key
;
if
(
!
isset
(
$plugin
[
'key'
]))
{
$plugin
[
'key'
]
=
$key
;
}
$this
->
registerPlugin
(
$plugin
[
'key'
],
...
...
@@ -678,7 +686,9 @@ class Client extends Configurable
public
function
createRequest
(
QueryInterface
$query
)
{
$pluginResult
=
$this
->
callPlugins
(
'preCreateRequest'
,
array
(
$query
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
if
(
$pluginResult
!==
null
)
{
return
$pluginResult
;
}
$requestBuilder
=
$query
->
getRequestBuilder
();
if
(
!
$requestBuilder
||
!
(
$requestBuilder
instanceof
RequestBuilderInterface
))
{
...
...
@@ -702,7 +712,9 @@ class Client extends Configurable
public
function
createResult
(
QueryInterface
$query
,
$response
)
{
$pluginResult
=
$this
->
callPlugins
(
'preCreateResult'
,
array
(
$query
,
$response
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
if
(
$pluginResult
!==
null
)
{
return
$pluginResult
;
}
$resultClass
=
$query
->
getResultClass
();
$result
=
new
$resultClass
(
$this
,
$query
,
$response
);
...
...
@@ -726,7 +738,9 @@ class Client extends Configurable
public
function
execute
(
QueryInterface
$query
,
$endpoint
=
null
)
{
$pluginResult
=
$this
->
callPlugins
(
'preExecute'
,
array
(
$query
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
if
(
$pluginResult
!==
null
)
{
return
$pluginResult
;
}
$request
=
$this
->
createRequest
(
$query
);
$response
=
$this
->
executeRequest
(
$request
,
$endpoint
);
...
...
@@ -920,7 +934,9 @@ class Client extends Configurable
$type
=
strtolower
(
$type
);
$pluginResult
=
$this
->
callPlugins
(
'preCreateQuery'
,
array
(
$type
,
$options
),
true
);
if
(
$pluginResult
!==
null
)
return
$pluginResult
;
if
(
$pluginResult
!==
null
)
{
return
$pluginResult
;
}
if
(
!
isset
(
$this
->
queryTypes
[
$type
]))
{
throw
new
Exception
(
'Unknown querytype: '
.
$type
);
...
...
library/Solarium/Core/Client/Endpoint.php
View file @
404be18c
...
...
@@ -151,7 +151,9 @@ class Endpoint extends Configurable
*/
public
function
setPath
(
$path
)
{
if
(
substr
(
$path
,
-
1
)
==
'/'
)
$path
=
substr
(
$path
,
0
,
-
1
);
if
(
substr
(
$path
,
-
1
)
==
'/'
)
{
$path
=
substr
(
$path
,
0
,
-
1
);
}
return
$this
->
setOption
(
'path'
,
$path
);
}
...
...
library/Solarium/Core/Client/Request.php
View file @
404be18c
...
...
@@ -219,8 +219,11 @@ class Request extends Configurable
$this
->
params
[
$key
][]
=
$value
;
}
else
{
// not all solr handlers support 0/1 as boolean values...
if
(
$value
===
true
)
$value
=
'true'
;
if
(
$value
===
false
)
$value
=
'false'
;
if
(
$value
===
true
)
{
$value
=
'true'
;
}
elseif
(
$value
===
false
)
{
$value
=
'false'
;
}
$this
->
params
[
$key
]
=
$value
;
}
...
...
library/Solarium/Core/Query/Helper.php
View file @
404be18c
...
...
@@ -154,7 +154,9 @@ class Helper
case
is_string
(
$input
)
||
is_numeric
(
$input
)
:
// if date/time string: convert to timestamp first
if
(
is_string
(
$input
))
$input
=
strtotime
(
$input
);
if
(
is_string
(
$input
))
{
$input
=
strtotime
(
$input
);
}
// now try converting the timestamp to a datetime instance, on failure return false
try
{
...
...
library/Solarium/Core/Query/RequestBuilder.php
View file @
404be18c
...
...
@@ -77,7 +77,9 @@ abstract class RequestBuilder implements RequestBuilderInterface
{
$params
=
''
;
foreach
(
$localParams
AS
$paramName
=>
$paramValue
)
{
if
(
empty
(
$paramValue
))
continue
;
if
(
empty
(
$paramValue
))
{
continue
;
}
if
(
is_array
(
$paramValue
))
{
$paramValue
=
implode
(
$paramValue
,
','
);
...
...
library/Solarium/Plugin/CustomizeRequest/Customization.php
View file @
404be18c
...
...
@@ -209,9 +209,13 @@ class Customization extends Configurable
public
function
isValid
()
{
$type
=
$this
->
getType
();
if
(
$type
!==
self
::
TYPE_PARAM
&&
$type
!==
self
::
TYPE_HEADER
)
return
false
;
if
(
$type
!==
self
::
TYPE_PARAM
&&
$type
!==
self
::
TYPE_HEADER
)
{
return
false
;
}
if
(
null
==
$this
->
getKey
()
||
null
==
$this
->
getName
()
||
null
==
$this
->
getValue
())
return
false
;
if
(
null
==
$this
->
getKey
()
||
null
==
$this
->
getName
()
||
null
==
$this
->
getValue
())
{
return
false
;
}
return
true
;
}
...
...
library/Solarium/Plugin/Loadbalancer/WeightedRandomChoice.php
View file @
404be18c
...
...
@@ -77,7 +77,9 @@ class WeightedRandomChoice
{
$i
=
0
;
foreach
(
$choices
AS
$key
=>
$weight
)
{
if
(
$weight
<=
0
)
throw
new
Exception
(
'Weight must be greater than zero'
);
if
(
$weight
<=
0
)
{
throw
new
Exception
(
'Weight must be greater than zero'
);
}
$this
->
totalWeight
+=
$weight
;
$this
->
lookup
[
$i
]
=
$this
->
totalWeight
;
...
...
@@ -104,7 +106,9 @@ class WeightedRandomChoice
$result
=
null
;
while
(
1
)
{
$result
=
$this
->
values
[
$this
->
getKey
()];
if
(
!
in_array
(
$result
,
$excludes
))
break
;
if
(
!
in_array
(
$result
,
$excludes
))
{
break
;
}
}
return
$result
;
...
...
@@ -122,7 +126,7 @@ class WeightedRandomChoice
$low
=
0
;
while
(
$low
<
$high
)
{
$probe
=
(
int
)((
$high
+
$low
)
/
2
);
$probe
=
(
int
)
((
$high
+
$low
)
/
2
);
if
(
$this
->
lookup
[
$probe
]
<
$random
)
{
$low
=
$probe
+
1
;
}
else
if
(
$this
->
lookup
[
$probe
]
>
$random
)
{
...
...
library/Solarium/Plugin/ParallelExecution.php
View file @
404be18c
...
...
@@ -90,9 +90,13 @@ class ParallelExecution extends Plugin
*/
public
function
addQuery
(
$key
,
$query
,
$endpoint
=
null
)
{
if
(
is_object
(
$endpoint
))
$endpoint
=
$endpoint
->
getKey
();
if
(
is_object
(
$endpoint
))
{
$endpoint
=
$endpoint
->
getKey
();
}
if
(
$endpoint
==
null
)
$endpoint
=
$this
->
client
->
getEndpoint
()
->
getKey
();
if
(
$endpoint
==
null
)
{
$endpoint
=
$this
->
client
->
getEndpoint
()
->
getKey
();
}
$this
->
queries
[
$key
]
=
array
(
'query'
=>
$query
,
...
...
library/Solarium/Plugin/PrefetchIterator.php
View file @
404be18c
...
...
@@ -146,7 +146,9 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
public
function
count
()
{
// if no results are available yet, get them now
if
(
null
==
$this
->
result
)
$this
->
fetchNext
();
if
(
null
==
$this
->
result
)
{
$this
->
fetchNext
();
}
return
$this
->
result
->
getNumFound
();
}
...
...
@@ -154,7 +156,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
/**
* Iterator implementation
*/
function
rewind
()
public
function
rewind
()
{
$this
->
position
=
0
;
...
...
@@ -167,7 +169,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
/**
* Iterator implementation
*/
function
current
()
public
function
current
()
{
$adjustedIndex
=
$this
->
position
%
$this
->
options
[
'prefetch'
];
return
$this
->
documents
[
$adjustedIndex
];
...
...
@@ -186,7 +188,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
/**
* Iterator implementation
*/
function
next
()
public
function
next
()
{
++
$this
->
position
;
}
...
...
@@ -196,7 +198,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
*
* @return boolean
*/
function
valid
()
public
function
valid
()
{
$adjustedIndex
=
$this
->
position
%
$this
->
options
[
'prefetch'
];
...
...
library/Solarium/Query/MoreLikeThis/ResponseParser.php
View file @
404be18c
...
...
@@ -74,7 +74,7 @@ class ResponseParser extends SelectResponseParser
$matchData
=
$data
[
'match'
][
'docs'
][
0
];
$documentClass
=
$query
->
getOption
(
'documentclass'
);
$fields
=
(
array
)
$matchData
;
$fields
=
(
array
)
$matchData
;
$parseResult
[
'match'
]
=
new
$documentClass
(
$fields
);
}
...
...
library/Solarium/Query/Select/Query/Component/Facet/Facet.php
View file @
404be18c
...
...
@@ -75,7 +75,9 @@ abstract class Facet extends Configurable
$this
->
setKey
(
$value
);
break
;
case
'exclude'
:
if
(
!
is_array
(
$value
))
$value
=
array
(
$value
);
if
(
!
is_array
(
$value
))
{
$value
=
array
(
$value
);
}
$this
->
setExcludes
(
$value
);
unset
(
$this
->
options
[
'exclude'
]);
break
;
...
...
library/Solarium/Query/Select/Query/Component/Facet/MultiQuery.php
View file @
404be18c
...
...
@@ -71,7 +71,9 @@ class MultiQuery extends Facet
foreach
(
$this
->
options
AS
$name
=>
$value
)
{
switch
(
$name
)
{
case
'query'
:
if
(
!
is_array
(
$value
))
$value
=
array
(
$value
);
if
(
!
is_array
(
$value
))
{
$value
=
array
(
$value
);
}
$this
->
addQueries
(
$value
);
break
;
}
...
...
library/Solarium/Query/Select/Query/Component/Grouping.php
View file @
404be18c
...
...
@@ -229,7 +229,9 @@ class Grouping extends Component
*/
public
function
addQueries
(
$queries
)
{
if
(
!
is_array
(
$queries
))
$queries
=
array
(
$queries
);
if
(
!
is_array
(
$queries
))
{
$queries
=
array
(
$queries
);
}
$this
->
queries
=
array_merge
(
$this
->
queries
,
$queries
);
...
...
library/Solarium/Query/Select/Query/FilterQuery.php
View file @
404be18c
...
...
@@ -72,7 +72,9 @@ class FilterQuery extends Configurable
foreach
(
$this
->
options
AS
$name
=>
$value
)
{
switch
(
$name
)
{
case
'tag'
:
if
(
!
is_array
(
$value
))
$value
=
array
(
$value
);
if
(
!
is_array
(
$value
))
{
$value
=
array
(
$value
);
}
$this
->
addTags
(
$value
);
break
;
case
'key'
:
...
...
library/Solarium/Query/Select/Query/Query.php
View file @
404be18c
...
...
@@ -233,10 +233,10 @@ class Query extends BaseQuery
$this
->
addFields
(
$value
);
break
;
case
'rows'
:
$this
->
setRows
((
int
)
$value
);
$this
->
setRows
((
int
)
$value
);
break
;
case
'start'
:
$this
->
setStart
((
int
)
$value
);
$this
->
setStart
((
int
)
$value
);
break
;
case
'component'
:
$this
->
createComponents
(
$value
);
...
...
library/Solarium/Query/Select/ResponseParser/Component/FacetSet.php
View file @
404be18c
...
...
@@ -79,7 +79,9 @@ class FacetSet
throw
new
Exception
(
'Unknown facet type'
);
}
if
(
$result
!==
null
)
$facets
[
$key
]
=
$result
;
if
(
$result
!==
null
)
{
$facets
[
$key
]
=
$result
;
}
}
return
$this
->
createFacetSet
(
$facets
);
...
...
library/Solarium/Query/Select/ResponseParser/ResponseParser.php
View file @
404be18c
...
...
@@ -62,7 +62,7 @@ class ResponseParser implements ResponseParserInterface
$documents
=
array
();
if
(
isset
(
$data
[
'response'
][
'docs'
]))
{
foreach
(
$data
[
'response'
][
'docs'
]
AS
$doc
)
{
$fields
=
(
array
)
$doc
;
$fields
=
(
array
)
$doc
;
$documents
[]
=
new
$documentClass
(
$fields
);
}
}
...
...
library/Solarium/Query/Update/Query/Query.php
View file @
404be18c
...
...
@@ -359,8 +359,14 @@ class Query extends BaseQuery
$commitWithin
=
null
)
{
$add
=
new
Command\Add
;
if
(
null
!==
$overwrite
)
$add
->
setOverwrite
(
$overwrite
);
if
(
null
!==
$commitWithin
)
$add
->
setCommitWithin
(
$commitWithin
);
if
(
null
!==
$overwrite
)
{
$add
->
setOverwrite
(
$overwrite
);
}
if
(
null
!==
$commitWithin
)
{
$add
->
setCommitWithin
(
$commitWithin
);
}
$add
->
addDocuments
(
$documents
);
return
$this
->
add
(
null
,
$add
);
...
...
@@ -381,10 +387,18 @@ class Query extends BaseQuery
$expungeDeletes
=
null
)
{
$commit
=
new
Command\Commit
();
if
(
null
!==
$waitFlush
)
$commit
->
setWaitFlush
(
$waitFlush
);
if
(
null
!==
$waitSearcher
)
$commit
->
setWaitSearcher
(
$waitSearcher
);
if
(
null
!==
$expungeDeletes
)
if
(
null
!==
$waitFlush
)
{
$commit
->
setWaitFlush
(
$waitFlush
);
}
if
(
null
!==
$waitSearcher
)
{
$commit
->
setWaitSearcher
(
$waitSearcher
);
}
if
(
null
!==
$expungeDeletes
)
{
$commit
->
setExpungeDeletes
(
$expungeDeletes
);
}
return
$this
->
add
(
null
,
$commit
);
}
...
...
@@ -404,9 +418,18 @@ class Query extends BaseQuery
$maxSegments
=
null
)
{
$optimize
=
new
Command\Optimize
();
if
(
null
!==
$waitFlush
)
$optimize
->
setWaitFlush
(
$waitFlush
);
if
(
null
!==
$waitSearcher
)
$optimize
->
setWaitSearcher
(
$waitSearcher
);
if
(
null
!==
$maxSegments
)
$optimize
->
setMaxSegments
(
$maxSegments
);
if
(
null
!==
$waitFlush
)
{
$optimize
->
setWaitFlush
(
$waitFlush
);
}
if
(
null
!==
$waitSearcher
)
{
$optimize
->
setWaitSearcher
(
$waitSearcher
);
}
if
(
null
!==
$maxSegments
)
{
$optimize
->
setMaxSegments
(
$maxSegments
);
}
return
$this
->
add
(
null
,
$optimize
);
}
...
...
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