所以我想说我有一个清单
@Override
public void write(List<? extends IndexerInputVO> inputItems) throws Exception {
int docsPerThread = Constants.NUMBER_OF_DOCS_PER_INDEX_WRITER_THREADS;
int docSize = inputItems.size();
int remainder = docSize%docsPerThread;
int poolSize = docSize/docsPerThread;
ExecutorService executor = Executors.newFixedThreadPool(poolSize+1);
int fromIndex=0;
int toIndex = docsPerThread;
if(docSize < docsPerThread){
executor.submit(new IndexWriterRunnable(this.luceneObjects,service,inputItems));
}else{
for(int i=1;i<=poolSize;i++){
executor.submit(new IndexWriterRunnable(this.luceneObjects,service,inputItems.subList(fromIndex, toIndex)));
fromIndex+=docsPerThread;
toIndex+=docsPerThread;
}
if(remainder != 0){
toIndex=docSize;
executor.submit(new IndexWriterRunnable(this.luceneObjects,service,inputItems.subList(fromIndex, toIndex)));
}
}
executor.shutdown();
while(executor.isTerminated()){
;
}
我想做的是这样的事情
answer_list = aaAbaBabBaBBaAbBAb
所以我试图检查每7个字符,如果字符是小写或大写B,我增加dimension_1_index = 0
dimension_1_b_answers = 0
while dimension_1_index <= len(answer_list):
if answer_list[dimension_1_index] == "b" or "B":
dimension_1_b_answers += 1
dimension_1_index += 7
else:
continue
print(dimension_1_b_answers)
。但是当我运行程序时,我没有得到任何结果。