mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
17.44.2012 f427a7e4ab4db809971c1b53922e0bc4788fcec9
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.
1 files modified
33 ■■■■ changed files
opends/src/server/org/opends/server/util/LDIFReader.java 33 ●●●● patch | view | raw | blame | history
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;
        }
      }