speedup at inserting to DB

This commit is contained in:
MrBesen 2018-11-13 14:49:04 +01:00
parent 5519ab072d
commit bb46e9a5e6
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 7 additions and 9 deletions

View File

@ -70,7 +70,7 @@ public class Crawler implements Runnable {
//if(! (toCrawl.contains(videoid) || toknown.contains(videoid)))
//toknown.add(videoid);
if(toCrawl.contains(videoid)) {
LinkedList<String> str = new LinkedList<String>();
ArrayList<String> str = new ArrayList<String>(1);
str.add(videoid);
db.storeTemp(str);
}
@ -255,18 +255,16 @@ public class Crawler implements Runnable {
int count = 0;
while(report[1].size() > 1) {//2 videos werden ggf. gelöscht ohne gesehen zu werden.
LinkedList<String> store = null;
ArrayList<String> store = null;
try {
if(report[1].size() <= 50) {
store = report[1];
store = new ArrayList<>(report[1]);
count += report[1].size();
report[1].clear();
} else {
store = new LinkedList<>();
while(!report[1].isEmpty() && store.size() < 50) {
store.add(report[1].removeFirst());
count++;
}
store = new ArrayList<>(report[1].subList(0, 50));
report[1].removeAll(store);
count+=50;
}
} catch(NoSuchElementException ignored) {//concurrentmodification fuckery
log.info("no suchelement bla");

View File

@ -271,7 +271,7 @@ public class DB implements Runnable {
log.info("Delete Double done in " + ((System.currentTimeMillis() - start)/60000) + " min");
}
public void storeTemp(LinkedList<String> strings) {
public void storeTemp(ArrayList<String> strings) {
if(strings == null)
return;
if(!strings.isEmpty()) {