fix sequence bug

This commit is contained in:
yxsh 2014-03-20 09:22:35 +08:00
parent 0f116bb29b
commit 607707e3ec
1 changed files with 24 additions and 16 deletions

View File

@ -10,11 +10,13 @@ import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
public class Para_Table {
public final int cacheCap = 5000;// 1 sequence 2 random
public final int cacheSize = 1000;// 1 sequence 2 random
public final int readCharSize = 10000;
public ConcurrentHashMap<String, Reader> readerMap = new ConcurrentHashMap<String, Para_Table.Reader>();
public abstract class Reader {
public final Table t;
@ -235,23 +237,29 @@ public class Para_Table {
resultRow = (TableRow) objCache.get(sourceValue);
return resultRow.cells.get(col);
}
if (source.equals("file")) {
table = new FileTable(sourceValue, fRow, sChar, lChar);
} else if (source.equals("input")) {
table = new StringTable(sourceValue, fRow, sChar, lChar);
if (this.readerMap.containsKey(sourceValue)) {
reader = readerMap.get(sourceValue);
} else {
if (source.equals("file")) {
table = new FileTable(sourceValue, fRow, sChar, lChar);
} else if (source.equals("input")) {
table = new StringTable(sourceValue, fRow, sChar, lChar);
}
if (nextRow.equals("random")) {
ArrayBlockingQueue<TableRow> queue = new ArrayBlockingQueue<Para_Table.TableRow>(
cacheCap);
reader = new RandomReader(queue, table);
} else if (nextRow.equals("sequence")) {
ArrayBlockingQueue<TableRow> queue = new ArrayBlockingQueue<Para_Table.TableRow>(
cacheCap);
reader = new SequenceReader(queue, table);
}
readerMap.put(sourceValue, reader);
}
if (nextRow.equals("random")) {
ArrayBlockingQueue<TableRow> queue = new ArrayBlockingQueue<Para_Table.TableRow>(
cacheCap);
reader = new RandomReader(queue, table);
} else if (nextRow.equals("sequence")) {
ArrayBlockingQueue<TableRow> queue = new ArrayBlockingQueue<Para_Table.TableRow>(
cacheCap);
reader = new SequenceReader(queue, table);
}
resultRow = reader.nextRow();
objCache.put(sourceValue, resultRow);
return resultRow.cells.get(col);