1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
reindexprocess.php
См. документацию.
1
<?
8
9
namespace
Bitrix\Sale\Location\Search;
10
11
use Bitrix\Main;
12
13
use Bitrix\Sale\Location;
14
15
final
class
ReindexProcess
extends
Location\Util\Process
16
{
17
const
DEBUG_MODE
=
true
;
18
19
protected
$sessionKey
=
'location_reindex'
;
20
21
protected
$wordInstance
=
null
;
22
protected
$chainInstance
=
null
;
23
24
public
function
__construct
(
$options
)
25
{
26
$this->
addStage
(
array
(
27
'PERCENT'
=> 5,
28
'CODE'
=>
'CLEANUP'
,
29
'CALLBACK'
=>
'stageCleanup'
30
));
31
32
$this->
addStage
(
array
(
33
'PERCENT'
=> 10,
34
'CODE'
=>
'CREATE_DICTIONARY'
,
35
'CALLBACK'
=>
'stageCreateDictionary'
,
36
'SUBPERCENT_CALLBACK'
=>
'getSubpercentForStageCreateDictionary'
,
37
'ON_BEFORE_CALLBACK'
=>
'stageCreateDictionaryBefore'
,
38
'ON_AFTER_CALLBACK'
=>
'stageCreateDictionaryAfter'
,
39
'TYPE'
=> static::CALLBACK_TYPE_QUOTA
40
));
41
42
$this->
addStage
(
array
(
43
'PERCENT'
=> 20,
44
'CODE'
=>
'RESORT_DICTIONARY'
,
45
'CALLBACK'
=>
'stageResortDictionary'
,
46
'SUBPERCENT_CALLBACK'
=>
'getSubpercentForStageResortDictionary'
,
47
'ON_BEFORE_CALLBACK'
=>
'stageResortDictionaryBefore'
,
48
'ON_AFTER_CALLBACK'
=>
'stageResortDictionaryAfter'
,
49
'TYPE'
=> static::CALLBACK_TYPE_QUOTA
50
));
51
52
$this->
addStage
(
array
(
53
'PERCENT'
=> 80,
54
'CODE'
=>
'CREATE_SEARCH_INDEX'
,
55
'CALLBACK'
=>
'stageCreateSearchIndex'
,
56
'SUBPERCENT_CALLBACK'
=>
'getSubpercentForStageCreateSearchIndex'
,
57
'ON_BEFORE_CALLBACK'
=>
'stageCreateSearchIndexBefore'
,
58
'ON_AFTER_CALLBACK'
=>
'stageCreateSearchIndexAfter'
,
59
'TYPE'
=> static::CALLBACK_TYPE_QUOTA
60
));
61
62
$this->
addStage
(
array
(
63
'PERCENT'
=> 90,
64
'CODE'
=>
'CREATE_SITE2LOCATION_INDEX'
,
65
'CALLBACK'
=>
'stageCreateSite2LocationIndex'
,
66
'SUBPERCENT_CALLBACK'
=>
'getSubpercentForCreateSite2LocationIndex'
67
));
68
69
$this->
addStage
(
array
(
70
'PERCENT'
=> 100,
71
'CODE'
=>
'RESTORE_DB_INDEXES'
,
72
'CALLBACK'
=>
'stageRestoreDBIndexes'
,
73
'SUBPERCENT_CALLBACK'
=>
'getSubpercentForRestoreDBIndexes'
74
));
75
76
parent::__construct(
$options
);
77
}
78
79
public
function
onAfterPerformIteration
()
80
{
81
if
($this->
getPercent
() == 100)
82
Finder::setIndexValid
();
83
}
84
86
// STAGES
87
88
protected
function
stageCleanup
()
89
{
90
Finder::setIndexInvalid
();
91
92
WordTable::cleanUpData
();
93
ChainTable::cleanUpData
();
94
SiteLinkTable::cleanUpData
();
95
96
$this->
nextStage
();
97
}
98
100
101
protected
function
stageCreateDictionaryBefore
()
102
{
103
if
(!isset($this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
]))
104
{
105
$instance
=
new
WordTable
(
array
(
106
'TYPES'
=>
Finder::getIndexedTypes
(),
107
'LANGS'
=>
Finder::getIndexedLanguages
()
108
));
109
}
110
else
111
{
112
$instance
= unserialize(
113
$this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
],
114
[
'allowed_classes'
=> [WordTable::class]]
115
);
116
}
117
118
$this->wordInstance =
$instance
;
119
}
120
121
protected
function
stageCreateDictionary
()
122
{
123
if
($this->
getStep
() == 0)
124
{
125
$this->wordInstance->setOffset(0);
126
$this->wordInstance->setPosition(0);
127
}
128
129
return
$this->wordInstance->initializeData();
130
}
131
132
protected
function
stageCreateDictionaryAfter
()
133
{
134
$this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
] = serialize($this->wordInstance);
135
$this->data[
'OFFSET'
] = $this->wordInstance->getOffset();
136
}
137
138
protected
function
getSubpercentForStageCreateDictionary
()
139
{
140
if
(!isset($this->data[
'LOC_NAMES_2_INDEX_COUNT'
]))
141
{
142
$item = Location\Name\LocationTable::getList(
array
(
143
'select'
=>
array
(
'CNT'
),
144
'filter'
=>
WordTable::getFilterForInitData
(
array
(
145
'TYPES'
=>
Finder::getIndexedTypes
(),
146
'LANGS'
=>
Finder::getIndexedLanguages
()
147
))
148
))->fetch();
149
150
$this->data[
'LOC_NAMES_2_INDEX_COUNT'
] = intval($item[
'CNT'
]);
151
}
152
153
return
$this->
getSubPercentByTotalAndDone
($this->data[
'LOC_NAMES_2_INDEX_COUNT'
], $this->data[
'OFFSET'
] ?? 0);
154
}
155
157
158
protected
function
stageResortDictionaryBefore
()
159
{
160
if
(!isset($this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
]))
161
{
162
$instance
=
new
WordTable
(
array
(
163
'TYPES'
=>
Finder::getIndexedTypes
(),
164
'LANGS'
=>
Finder::getIndexedLanguages
()
165
));
166
}
167
else
168
$instance
= unserialize(
169
$this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
],
170
[
'allowed_classes'
=> [WordTable::class]]
171
);
172
173
$this->wordInstance =
$instance
;
174
}
175
176
protected
function
stageResortDictionary
()
177
{
178
if
($this->
getStep
() == 0)
179
{
180
$this->wordInstance->setOffset(0);
181
$this->wordInstance->setPosition(0);
182
}
183
184
$allDone = $this->wordInstance->resort();
185
186
if
($allDone)
187
$this->wordInstance->mergeResort();
188
189
return
$allDone;
190
}
191
192
protected
function
stageResortDictionaryAfter
()
193
{
194
$this->data[
'WORD_TABLE_INSTANCE_SERIALIZED'
] = serialize($this->wordInstance);
195
$this->data[
'OFFSET'
] = $this->wordInstance->getOffset();
196
}
197
198
protected
function
getSubpercentForStageResortDictionary
()
199
{
200
if
($this->
getStep
() == 0)
201
$this->data[
'OFFSET'
] = 0;
202
203
if
(!isset($this->data[
'DICTIONARY_SIZE'
]))
204
{
205
$item = WordTable::getList(
array
(
206
'select'
=>
array
(
'CNT'
)
207
))->fetch();
208
209
$this->data[
'DICTIONARY_SIZE'
] = intval($item[
'CNT'
]);
210
}
211
212
return
$this->
getSubPercentByTotalAndDone
($this->data[
'DICTIONARY_SIZE'
], $this->data[
'OFFSET'
]);
213
}
214
216
217
protected
function
stageCreateSearchIndexBefore
()
218
{
219
if
(!isset($this->data[
'CHAIN_TABLE_INSTANCE_SERIALIZED'
]))
220
{
221
$instance
=
new
ChainTable
(
array
(
222
'TYPES'
=>
Finder::getIndexedTypes
()
223
));
224
}
225
else
226
$instance
= unserialize(
227
$this->data[
'CHAIN_TABLE_INSTANCE_SERIALIZED'
],
228
[
'allowed_classes'
=> [ChainTable::class]]
229
);
230
231
$this->chainInstance =
$instance
;
232
}
233
234
protected
function
stageCreateSearchIndex
()
235
{
236
return
$this->chainInstance->initializeData();
237
}
238
239
protected
function
stageCreateSearchIndexAfter
()
240
{
241
$this->data[
'CHAIN_TABLE_INSTANCE_SERIALIZED'
] = serialize($this->chainInstance);
242
$this->data[
'OFFSET'
] = $this->chainInstance->getOffset();
243
}
244
245
protected
function
getSubpercentForStageCreateSearchIndex
()
246
{
247
if
($this->
getStep
() == 0)
248
$this->data[
'OFFSET'
] = 0;
249
250
if
(!isset($this->data[
'INDEX_LOCATION_COUNT'
]))
251
{
252
$item = Location\LocationTable::getList(
array
(
253
'select'
=>
array
(
254
'CNT'
255
),
256
'filter'
=>
ChainTable::getFilterForInitData
(
array
(
'TYPES'
=>
Finder::getIndexedTypes
()))
257
))->fetch();
258
259
$this->data[
'INDEX_LOCATION_COUNT'
] = intval($item[
'CNT'
]);
260
}
261
262
return
$this->
getSubPercentByTotalAndDone
($this->data[
'INDEX_LOCATION_COUNT'
], $this->data[
'OFFSET'
]);
263
}
264
266
267
protected
function
stageCreateSite2LocationIndex
()
268
{
269
SiteLinkTable::initializeData
();
270
271
$this->
nextStage
();
272
}
273
protected
function
getSubpercentForCreateSite2LocationIndex
()
274
{
275
return
0;
276
}
277
278
protected
function
stageRestoreDBIndexes
()
279
{
280
$step
= $this->
getStep
();
281
282
if
(
$step
== 0)
283
WordTable::createIndex
();
284
elseif
(
$step
== 1)
285
ChainTable::createIndex
();
286
elseif
(
$step
== 2)
287
SiteLinkTable::createIndex
();
288
289
if
(
$step
>= 2)
290
$this->
nextStage
();
291
else
292
$this->
nextStep
();
293
}
294
protected
function
getSubpercentForRestoreDBIndexes
()
295
{
296
$pRange = $this->
getCurrentPercentRange
();
297
$step
= $this->
getStep
();
298
299
$indexCount = 3;
300
301
if
(
$step
>= $indexCount)
302
return
$pRange;
303
else
304
{
305
return
round($pRange * (
$step
/ $indexCount));
306
}
307
}
308
}
Bitrix\Sale\Location\Search\ChainTable
Определения
chain.php:38
Bitrix\Sale\Location\Search\ChainTable\getFilterForInitData
static getFilterForInitData($parameters=array())
Определения
chain.php:150
Bitrix\Sale\Location\Search\ChainTable\createIndex
static createIndex()
Определения
chain.php:313
Bitrix\Sale\Location\Search\ChainTable\cleanUpData
static cleanUpData()
Определения
chain.php:135
Bitrix\Sale\Location\Search\Finder\getIndexedLanguages
static getIndexedLanguages()
Определения
finder.php:89
Bitrix\Sale\Location\Search\Finder\setIndexValid
static setIndexValid()
Определения
finder.php:35
Bitrix\Sale\Location\Search\Finder\setIndexInvalid
static setIndexInvalid()
Определения
finder.php:40
Bitrix\Sale\Location\Search\Finder\getIndexedTypes
static getIndexedTypes()
Определения
finder.php:45
Bitrix\Sale\Location\Search\ReindexProcess
Определения
reindexprocess.php:16
Bitrix\Sale\Location\Search\ReindexProcess\stageResortDictionaryAfter
stageResortDictionaryAfter()
Определения
reindexprocess.php:192
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateSearchIndexAfter
stageCreateSearchIndexAfter()
Определения
reindexprocess.php:239
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateSearchIndexBefore
stageCreateSearchIndexBefore()
Определения
reindexprocess.php:217
Bitrix\Sale\Location\Search\ReindexProcess\$wordInstance
$wordInstance
Определения
reindexprocess.php:21
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateDictionary
stageCreateDictionary()
Определения
reindexprocess.php:121
Bitrix\Sale\Location\Search\ReindexProcess\getSubpercentForCreateSite2LocationIndex
getSubpercentForCreateSite2LocationIndex()
Определения
reindexprocess.php:273
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateSite2LocationIndex
stageCreateSite2LocationIndex()
Определения
reindexprocess.php:267
Bitrix\Sale\Location\Search\ReindexProcess\getSubpercentForStageCreateDictionary
getSubpercentForStageCreateDictionary()
Определения
reindexprocess.php:138
Bitrix\Sale\Location\Search\ReindexProcess\getSubpercentForStageResortDictionary
getSubpercentForStageResortDictionary()
Определения
reindexprocess.php:198
Bitrix\Sale\Location\Search\ReindexProcess\$sessionKey
$sessionKey
Определения
reindexprocess.php:19
Bitrix\Sale\Location\Search\ReindexProcess\stageCleanup
stageCleanup()
Определения
reindexprocess.php:88
Bitrix\Sale\Location\Search\ReindexProcess\stageResortDictionaryBefore
stageResortDictionaryBefore()
Определения
reindexprocess.php:158
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateDictionaryAfter
stageCreateDictionaryAfter()
Определения
reindexprocess.php:132
Bitrix\Sale\Location\Search\ReindexProcess\$chainInstance
$chainInstance
Определения
reindexprocess.php:22
Bitrix\Sale\Location\Search\ReindexProcess\stageResortDictionary
stageResortDictionary()
Определения
reindexprocess.php:176
Bitrix\Sale\Location\Search\ReindexProcess\getSubpercentForRestoreDBIndexes
getSubpercentForRestoreDBIndexes()
Определения
reindexprocess.php:294
Bitrix\Sale\Location\Search\ReindexProcess\stageRestoreDBIndexes
stageRestoreDBIndexes()
Определения
reindexprocess.php:278
Bitrix\Sale\Location\Search\ReindexProcess\DEBUG_MODE
const DEBUG_MODE
Определения
reindexprocess.php:17
Bitrix\Sale\Location\Search\ReindexProcess\onAfterPerformIteration
onAfterPerformIteration()
Определения
reindexprocess.php:79
Bitrix\Sale\Location\Search\ReindexProcess\getSubpercentForStageCreateSearchIndex
getSubpercentForStageCreateSearchIndex()
Определения
reindexprocess.php:245
Bitrix\Sale\Location\Search\ReindexProcess\__construct
__construct($options)
Определения
reindexprocess.php:24
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateSearchIndex
stageCreateSearchIndex()
Определения
reindexprocess.php:234
Bitrix\Sale\Location\Search\ReindexProcess\stageCreateDictionaryBefore
stageCreateDictionaryBefore()
Определения
reindexprocess.php:101
Bitrix\Sale\Location\Search\SiteLinkTable\createIndex
static createIndex()
Определения
sitelink.php:99
Bitrix\Sale\Location\Search\SiteLinkTable\cleanUpData
static cleanUpData()
Определения
sitelink.php:58
Bitrix\Sale\Location\Search\SiteLinkTable\initializeData
static initializeData()
Определения
sitelink.php:74
Bitrix\Sale\Location\Search\WordTable
Определения
word.php:38
Bitrix\Sale\Location\Search\WordTable\getFilterForInitData
static getFilterForInitData($parameters=array())
Определения
word.php:263
Bitrix\Sale\Location\Search\WordTable\createIndex
static createIndex()
Определения
word.php:201
Bitrix\Sale\Location\Search\WordTable\cleanUpData
static cleanUpData()
Определения
word.php:164
Bitrix\Sale\Location\Util\Process
Определения
process.php:14
Bitrix\Sale\Location\Util\Process\$options
$options
Определения
process.php:35
Bitrix\Sale\Location\Util\Process\addStage
addStage($params)
Определения
process.php:67
Bitrix\Sale\Location\Util\Process\getSubPercentByTotalAndDone
getSubPercentByTotalAndDone($total, $done=0)
Определения
process.php:383
Bitrix\Sale\Location\Util\Process\getPercent
getPercent()
Определения
process.php:362
Bitrix\Sale\Location\Util\Process\nextStage
nextStage()
Определения
process.php:221
Bitrix\Sale\Location\Util\Process\$step
$step
Определения
process.php:28
Bitrix\Sale\Location\Util\Process\getCurrentPercentRange
getCurrentPercentRange()
Определения
process.php:357
Bitrix\Sale\Location\Util\Process\getStep
getStep()
Определения
process.php:308
Bitrix\Sale\Location\Util\Process\nextStep
nextStep()
Определения
process.php:243
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$instance
$instance
Определения
ps_b24_final.php:14
bitrix
modules
sale
lib
location
search
reindexprocess.php
Создано системой
1.14.0