mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 06:23:10 +00:00
[DS-739] Convert list to map to deduplicate tasks for the same handle
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5728 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -50,7 +50,9 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@@ -774,14 +776,14 @@ public class DSIndexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<IndexingTask> actionQueue = new ArrayList<IndexingTask>();
|
private static Map<String, IndexingTask> queuedTaskMap = new HashMap<String, IndexingTask>();
|
||||||
|
|
||||||
static synchronized void addToIndexingTaskQueue(IndexingTask action)
|
static synchronized void addToIndexingTaskQueue(IndexingTask action)
|
||||||
{
|
{
|
||||||
if (action != null)
|
if (action != null)
|
||||||
{
|
{
|
||||||
actionQueue.add(action);
|
queuedTaskMap.put(action.getTerm().text(), action);
|
||||||
if (actionQueue.size() >= batchFlushAfterDocuments)
|
if (queuedTaskMap.size() >= batchFlushAfterDocuments)
|
||||||
{
|
{
|
||||||
flushIndexingTaskQueue();
|
flushIndexingTaskQueue();
|
||||||
}
|
}
|
||||||
@@ -790,7 +792,7 @@ public class DSIndexer
|
|||||||
|
|
||||||
static void flushIndexingTaskQueue()
|
static void flushIndexingTaskQueue()
|
||||||
{
|
{
|
||||||
if (actionQueue.size() > 0)
|
if (queuedTaskMap.size() > 0)
|
||||||
{
|
{
|
||||||
IndexWriter writer = null;
|
IndexWriter writer = null;
|
||||||
|
|
||||||
@@ -822,7 +824,7 @@ public class DSIndexer
|
|||||||
|
|
||||||
private static synchronized void flushIndexingTaskQueue(IndexWriter writer)
|
private static synchronized void flushIndexingTaskQueue(IndexWriter writer)
|
||||||
{
|
{
|
||||||
for (IndexingTask action : actionQueue)
|
for (IndexingTask action : queuedTaskMap.values())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -841,7 +843,7 @@ public class DSIndexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actionQueue.clear();
|
queuedTaskMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user