From f427a7e4ab4db809971c1b53922e0bc4788fcec9 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 17 Apr 2012 09:44:31 +0000
Subject: [PATCH] Fix OPENDJ-469 - LDIFReader has code duplication and suffer from poor performance with highly multi-valued attributes. Another optimization to avoid double checking of the presence of an entry.
---
opends/src/server/org/opends/server/util/LDIFReader.java | 33 ++++++++-------------------------
1 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/LDIFReader.java b/opends/src/server/org/opends/server/util/LDIFReader.java
index a9d85a6..eb6fc0b 100644
--- a/opends/src/server/org/opends/server/util/LDIFReader.java
+++ b/opends/src/server/org/opends/server/util/LDIFReader.java
@@ -1312,27 +1312,12 @@
// Check to see if any of the attributes in the list have the same set of
// options. If so, then try to add a value to that attribute.
- for (AttributeBuilder a : attrList) {
- if (a.optionsEqual(attribute.getOptions())) {
- if (a.contains(attributeValue)) {
- if (!checkSchema) {
- // If we're not doing schema checking, then it is possible that
- // the attribute type should use case-sensitive matching and the
- // values differ in capitalization. Only reject the proposed
- // value if we find another value that is exactly the same as the
- // one that was provided.
- for (AttributeValue v : a) {
- if (v.getValue().equals(attributeValue.getValue())) {
- Message message = WARN_LDIF_DUPLICATE_ATTR.get(
- String.valueOf(entryDN),
- lastEntryLineNumber, attrName,
- value.toString());
- logToRejectWriter(lines, message);
- throw new LDIFException(message, lastEntryLineNumber,
- true);
- }
- }
- } else {
+ for (AttributeBuilder a : attrList)
+ {
+ if (a.optionsEqual(attribute.getOptions()))
+ {
+ if (!a.add(attributeValue) && checkSchema)
+ {
Message message = WARN_LDIF_DUPLICATE_ATTR.get(
String.valueOf(entryDN),
lastEntryLineNumber, attrName,
@@ -1340,10 +1325,9 @@
logToRejectWriter(lines, message);
throw new LDIFException(message, lastEntryLineNumber,
true);
- }
}
-
- if (attrType.isSingleValue() && !a.isEmpty() && checkSchema) {
+ if (attrType.isSingleValue() && (a.size() > 1) && checkSchema)
+ {
Message message = ERR_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR
.get(String.valueOf(entryDN),
lastEntryLineNumber, attrName);
@@ -1351,7 +1335,6 @@
throw new LDIFException(message, lastEntryLineNumber, true);
}
- a.add(attributeValue);
return;
}
}
--
Gitblit v1.10.0