From aae8bc83dc164b20a0b9b2d5ec6d0a43295272a5 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 05 Dec 2014 14:06:12 +0000
Subject: [PATCH] Importer.java: Extracted method processAttribute(). Code cleanup
---
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java | 80 ++++++++++++++++-----------------------
1 files changed, 33 insertions(+), 47 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index 733ee85..f63a4cd 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -223,7 +223,8 @@
static
{
- if ((dnType = DirectoryServer.getAttributeType("dn")) == null)
+ dnType = DirectoryServer.getAttributeType("dn");
+ if (dnType == null)
{
dnType = DirectoryServer.getDefaultAttributeType("dn");
}
@@ -592,7 +593,7 @@
importMemPct -= 15;
}
- availableMemory = (totalAvailableMemory * importMemPct / 100);
+ availableMemory = totalAvailableMemory * importMemPct / 100;
}
private void initializeIndexBuffers()
@@ -896,7 +897,7 @@
switchContainers();
recursiveDelete(tempDir);
long finishTime = System.currentTimeMillis();
- long importTime = (finishTime - startTime);
+ long importTime = finishTime - startTime;
float rate = 0;
logger.info(NOTE_JEB_IMPORT_PHASE_STATS, importTime / 1000,
(phaseOneFinishTime - startTime) / 1000,
@@ -1556,60 +1557,46 @@
}
}
- void fillIndexKey(Suffix suffix,
- Map.Entry<AttributeType, AttributeIndex> mapEntry, Entry entry,
- AttributeType attributeType, EntryID entryID) throws DatabaseException,
- InterruptedException, DirectoryException, JebException
+ void fillIndexKey(Suffix suffix, Map.Entry<AttributeType, AttributeIndex> mapEntry, Entry entry,
+ AttributeType attrType, EntryID entryID)
+ throws DatabaseException, InterruptedException, DirectoryException, JebException
{
- AttributeIndex attributeIndex = mapEntry.getValue();
- IndexingOptions options = attributeIndex.getIndexingOptions();
- Index index = attributeIndex.getEqualityIndex();
- if (index != null)
- {
- processAttribute(index, entry, entryID, options, new IndexKey(attributeType,
- ImportIndexType.EQUALITY, index.getIndexEntryLimit()));
- }
- index = attributeIndex.getPresenceIndex();
- if (index != null)
- {
- processAttribute(index, entry, entryID, options, new IndexKey(attributeType,
- ImportIndexType.PRESENCE, index.getIndexEntryLimit()));
- }
- index = attributeIndex.getSubstringIndex();
- if (index != null)
- {
- processAttribute(index, entry, entryID, options, new IndexKey(attributeType,
- ImportIndexType.SUBSTRING, index.getIndexEntryLimit()));
- }
- index = attributeIndex.getOrderingIndex();
- if (index != null)
- {
- processAttribute(index, entry, entryID, options, new IndexKey(attributeType,
- ImportIndexType.ORDERING, index.getIndexEntryLimit()));
- }
- index = attributeIndex.getApproximateIndex();
- if (index != null)
- {
- processAttribute(index, entry, entryID, options, new IndexKey(attributeType,
- ImportIndexType.APPROXIMATE, index.getIndexEntryLimit()));
- }
+ final AttributeIndex attrIndex = mapEntry.getValue();
+ final IndexingOptions options = attrIndex.getIndexingOptions();
+
+ processAttribute(attrIndex.getEqualityIndex(), ImportIndexType.EQUALITY, entry, attrType, entryID, options);
+ processAttribute(attrIndex.getPresenceIndex(), ImportIndexType.PRESENCE, entry, attrType, entryID, options);
+ processAttribute(attrIndex.getSubstringIndex(), ImportIndexType.SUBSTRING, entry, attrType, entryID, options);
+ processAttribute(attrIndex.getOrderingIndex(), ImportIndexType.ORDERING, entry, attrType, entryID, options);
+ processAttribute(attrIndex.getApproximateIndex(), ImportIndexType.APPROXIMATE, entry, attrType, entryID, options);
+
for (VLVIndex vlvIdx : suffix.getEntryContainer().getVLVIndexes())
{
Transaction transaction = null;
vlvIdx.addEntry(transaction, entryID, entry);
}
- Map<String, Collection<Index>> extensibleMap = attributeIndex.getExtensibleIndexes();
+ Map<String, Collection<Index>> extensibleMap = attrIndex.getExtensibleIndexes();
if (!extensibleMap.isEmpty())
{
Collection<Index> subIndexes = extensibleMap.get(EXTENSIBLE_INDEXER_ID_SUBSTRING);
- processAttributes(entry, attributeType, entryID, options, subIndexes, ImportIndexType.EX_SUBSTRING);
+ processAttributes(subIndexes, ImportIndexType.EX_SUBSTRING, entry, attrType, entryID, options);
Collection<Index> sharedIndexes = extensibleMap.get(EXTENSIBLE_INDEXER_ID_SHARED);
- processAttributes(entry, attributeType, entryID, options, sharedIndexes, ImportIndexType.EX_SHARED);
+ processAttributes(sharedIndexes, ImportIndexType.EX_SHARED, entry, attrType, entryID, options);
}
}
- private void processAttributes(Entry entry, AttributeType attributeType, EntryID entryID, IndexingOptions options,
- Collection<Index> indexes, ImportIndexType indexType) throws InterruptedException
+ private void processAttribute(Index index, ImportIndexType presence, Entry entry, AttributeType attributeType, EntryID entryID,
+ IndexingOptions options) throws InterruptedException
+ {
+ if (index != null)
+ {
+ IndexKey indexKey = new IndexKey(attributeType, presence, index.getIndexEntryLimit());
+ processAttribute(index, entry, entryID, options, indexKey);
+ }
+ }
+
+ private void processAttributes(Collection<Index> indexes, ImportIndexType indexType, Entry entry, AttributeType attributeType,
+ EntryID entryID, IndexingOptions options) throws InterruptedException
{
if (indexes != null)
{
@@ -1734,8 +1721,7 @@
private final IndexManager indexMgr;
private final DatabaseEntry dbKey, dbValue;
private final int cacheSize;
- private final Map<Integer, DNState> dnStateMap =
- new HashMap<Integer, DNState>();
+ private final Map<Integer, DNState> dnStateMap = new HashMap<Integer, DNState>();
private final Map<Integer, Index> indexMap = new HashMap<Integer, Index>();
private final Semaphore permits;
private final int maxPermits;
@@ -2729,7 +2715,7 @@
{
return;
}
- boolean isDN = indexKey.getIndexType().equals(ImportIndexType.DN);
+ boolean isDN = ImportIndexType.DN.equals(indexKey.getIndexType());
IndexManager indexMgr = new IndexManager(
indexKey.getName(), isDN, indexKey.getEntryLimit());
if (isDN)
--
Gitblit v1.10.0