Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
search
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
search
Commits
8be62785
Commit
8be62785
authored
Dec 06, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
a1a520a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
ListUtil.java
src/main/java/com/egolm/search/common/ListUtil.java
+26
-0
AbstractSolrApi.java
...main/java/com/egolm/search/schedules/AbstractSolrApi.java
+2
-2
No files found.
src/main/java/com/egolm/search/common/ListUtil.java
0 → 100644
View file @
8be62785
package
com
.
egolm
.
search
.
common
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.egolm.search.config.XException
;
public
class
ListUtil
{
public
static
<
T
>
List
<
List
<
T
>>
split
(
List
<
T
>
list
,
int
length
)
{
if
(
length
<=
0
)
{
throw
new
XException
(
"List split error, length must greater then 0"
);
}
List
<
List
<
T
>>
result
=
new
ArrayList
<
List
<
T
>>();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
int
size
=
list
.
size
();
int
count
=
(
size
+
length
-
1
)
/
length
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
List
<
T
>
subList
=
list
.
subList
(
i
*
length
,
((
i
+
1
)
*
length
>
size
?
size
:
length
*
(
i
+
1
)));
result
.
add
(
subList
);
}
}
return
result
;
}
}
src/main/java/com/egolm/search/schedules/AbstractSolrApi.java
View file @
8be62785
...
@@ -8,8 +8,8 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
...
@@ -8,8 +8,8 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
import
org.apache.solr.common.SolrInputDocument
;
import
org.apache.solr.common.SolrInputDocument
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.search.common.ListUtil
;
import
com.egolm.search.config.XRException
;
import
com.egolm.search.config.XRException
;
import
com.google.common.collect.Lists
;
public
abstract
class
AbstractSolrApi
implements
SolrApi
{
public
abstract
class
AbstractSolrApi
implements
SolrApi
{
...
@@ -29,7 +29,7 @@ public abstract class AbstractSolrApi implements SolrApi {
...
@@ -29,7 +29,7 @@ public abstract class AbstractSolrApi implements SolrApi {
docs
.
add
(
solrInputDocument
);
docs
.
add
(
solrInputDocument
);
}
}
List
<
List
<
SolrInputDocument
>>
doclist
=
List
s
.
partition
(
docs
,
1000
);
List
<
List
<
SolrInputDocument
>>
doclist
=
List
Util
.
split
(
docs
,
1000
);
for
(
List
<
SolrInputDocument
>
tmp
:
doclist
)
{
for
(
List
<
SolrInputDocument
>
tmp
:
doclist
)
{
solrClient
.
add
(
tmp
);
solrClient
.
add
(
tmp
);
}
}
...
...
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