minor fix
This commit is contained in:
parent
9e68cbb283
commit
feaf9b0adc
@ -297,71 +297,66 @@ public class Datahandler {
|
||||
selectUpdate = secondaryIterator;
|
||||
secondaryIterator += iteratorCap;
|
||||
}
|
||||
final ConcurrentMap<Integer, String> getStringCacheMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
for (int i = 0; i < iteratorCap; i++) {
|
||||
getStringCacheMap.put(i, stringCachelocal.get(selectUpdate));
|
||||
selectUpdate++;
|
||||
}
|
||||
String getStringCacheStr = stringCachelocal.get(selectUpdate);
|
||||
ConcurrentMap<Integer, SimilarityMatrix> matrixUpdateMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
ConcurrentMap<Integer, Future<SimilarityMatrix>> futures = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
getStringCacheMap.values().forEach((getStringCacheStr) -> {
|
||||
stringCachelocal.values().forEach((str1) -> {
|
||||
if (!getStringCacheStr.equals(str1)) {
|
||||
boolean present = false;
|
||||
LinkedHashMap<String, Double> orDefault = lHMSMX.getOrDefault(getStringCacheStr, null);
|
||||
stringCachelocal.values().forEach((str1) -> {
|
||||
if (!getStringCacheStr.equals(str1)) {
|
||||
boolean present = false;
|
||||
LinkedHashMap<String, Double> orDefault = lHMSMX.getOrDefault(getStringCacheStr, null);
|
||||
if (orDefault != null) {
|
||||
Collection<String> strkeys = orDefault.keySet();
|
||||
for (String strkey : strkeys) {
|
||||
if (strkey.equals(str1)) {
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!present) {
|
||||
orDefault = lHMSMX.getOrDefault(str1, null);
|
||||
if (orDefault != null) {
|
||||
Collection<String> strkeys = orDefault.keySet();
|
||||
for (String strkey : strkeys) {
|
||||
if (strkey.equals(str1)) {
|
||||
if (strkey.equals(getStringCacheStr)) {
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!present) {
|
||||
orDefault = lHMSMX.getOrDefault(str1, null);
|
||||
if (orDefault != null) {
|
||||
Collection<String> strkeys = orDefault.keySet();
|
||||
for (String strkey : strkeys) {
|
||||
if (strkey.equals(getStringCacheStr)) {
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!present) {
|
||||
LinkedHashMap<String, Double> orDefault1 = lHMSMX.getOrDefault(getStringCacheStr, null);
|
||||
if (orDefault1 == null) {
|
||||
orDefault1 = new LinkedHashMap<String, Double>();
|
||||
}
|
||||
orDefault1.put(str1, 0.0);
|
||||
lHMSMX.put(getStringCacheStr, orDefault1);
|
||||
SimilarityMatrix SMX = new SimilarityMatrix(getStringCacheStr, str1);
|
||||
Callable<SimilarityMatrix> worker = new SentimentAnalyzerTest(getStringCacheStr, str1, SMX, jmweAnnotationCache.get(getStringCacheStr),
|
||||
jmweAnnotationCache.get(str1), pipelineAnnotationCache.get(getStringCacheStr), pipelineAnnotationCache.get(str1),
|
||||
pipelineSentimentAnnotationCache.get(getStringCacheStr), pipelineSentimentAnnotationCache.get(str1));
|
||||
futures.put(futures.size() + 1, executor.submit(worker));
|
||||
}
|
||||
if (!present) {
|
||||
LinkedHashMap<String, Double> orDefault1 = lHMSMX.getOrDefault(getStringCacheStr, null);
|
||||
if (orDefault1 == null) {
|
||||
orDefault1 = new LinkedHashMap<String, Double>();
|
||||
}
|
||||
orDefault1.put(str1, 0.0);
|
||||
lHMSMX.put(getStringCacheStr, orDefault1);
|
||||
SimilarityMatrix SMX = new SimilarityMatrix(getStringCacheStr, str1);
|
||||
Callable<SimilarityMatrix> worker = new SentimentAnalyzerTest(getStringCacheStr, str1, SMX, jmweAnnotationCache.get(getStringCacheStr),
|
||||
jmweAnnotationCache.get(str1), pipelineAnnotationCache.get(getStringCacheStr), pipelineAnnotationCache.get(str1),
|
||||
pipelineSentimentAnnotationCache.get(getStringCacheStr), pipelineSentimentAnnotationCache.get(str1));
|
||||
futures.put(futures.size() + 1, executor.submit(worker));
|
||||
}
|
||||
});
|
||||
System.out.println("finished worker assignment, futures size: " + futures.size() + "\n");
|
||||
futures.values().parallelStream().forEach((future) -> {
|
||||
SimilarityMatrix SMX = new SimilarityMatrix("", "");
|
||||
try {
|
||||
SMX = future.get(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
SMX = null;
|
||||
}
|
||||
if (SMX != null) {
|
||||
LinkedHashMap<String, Double> getFuture = lHMSMX.getOrDefault(SMX.getPrimaryString(), null);
|
||||
getFuture.put(SMX.getSecondaryString(), SMX.getDistance());
|
||||
lHMSMX.put(SMX.getPrimaryString(), getFuture);
|
||||
matrixUpdateMap.put(matrixUpdateMap.size() + 1, SMX);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
System.out.println("finished worker assignment, futures size: " + futures.size() + "\n");
|
||||
futures.values().parallelStream().forEach((future) -> {
|
||||
SimilarityMatrix SMX = new SimilarityMatrix("", "");
|
||||
try {
|
||||
SMX = future.get(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
SMX = null;
|
||||
}
|
||||
if (SMX != null) {
|
||||
LinkedHashMap<String, Double> getFuture = lHMSMX.getOrDefault(SMX.getPrimaryString(), null);
|
||||
getFuture.put(SMX.getSecondaryString(), SMX.getDistance());
|
||||
lHMSMX.put(SMX.getPrimaryString(), getFuture);
|
||||
matrixUpdateMap.put(matrixUpdateMap.size() + 1, SMX);
|
||||
}
|
||||
});
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (!matrixUpdateMap.isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user