From d283891e8e18e30def8a37e9e24e5e11d427fb47 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 21 Jan 2015 14:57:27 +0000
Subject: [PATCH] Removed dead code + code cleanup
---
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/ImportIDSet.java | 127 +++--------------------------------------
1 files changed, 11 insertions(+), 116 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/ImportIDSet.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/ImportIDSet.java
index 79d850e..d333fcd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/ImportIDSet.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/ImportIDSet.java
@@ -50,9 +50,9 @@
/** Key related to an ID set. */
private ByteBuffer key;
/** The entry limit size. */
- private int limit = -1;
+ private final int limit;
/** Set to true if a count of ids above the entry limit should be kept. */
- private boolean doCount;
+ private final boolean doCount;
/**
* Create an import ID set of the specified size, index limit and index
@@ -66,42 +66,28 @@
{
this.array = new long[size + 128];
// A limit of 0 means unlimited.
- if (limit == 0)
- {
- this.limit = Integer.MAX_VALUE;
- }
- else
- {
- this.limit = limit;
- }
+ this.limit = limit == 0 ? Integer.MAX_VALUE : limit;
this.doCount = doCount;
}
/** Create an empty import instance. */
public ImportIDSet()
{
+ this.limit = -1;
+ this.doCount = false;
}
/**
* Clear the set so it can be reused again. The boolean indexParam specifies
* if the index parameters should be cleared also.
- *
- * @param indexParams <CODE>true</CODE> if the index parameters should be
- * cleared.
*/
- public void clear(boolean indexParams)
+ public void clear()
{
undefinedSize = 0;
isDefined = true;
count = 0;
- if(indexParams)
- {
- doCount = false;
- limit = -1;
- }
}
-
/**
* Return if an import ID set is defined or not.
*
@@ -112,84 +98,12 @@
return isDefined;
}
-
- /**
- * Return the undefined size of an import ID set.
- *
- * @return The undefined size of an import ID set.
- */
- long getUndefinedSize()
- {
- return undefinedSize;
- }
-
-
- /**
- * Set an import ID set to undefined.
- */
- void setUndefined() {
+ /** Set an import ID set to undefined. */
+ private void setUndefined() {
array = null;
isDefined = false;
}
-
- /**
- * Merge an instance of an import ID set with the import ID set specified
- * in the parameter. The specified limit and maintain count parameters define
- * if the newly merged set is defined or not.
- *
- * @param importIDSet The import ID set to merge with.
- */
- public void
- merge(ImportIDSet importIDSet)
- {
- if(limit == -1)
- {
- doCount = importIDSet.doCount;
- limit = importIDSet.limit;
- }
- if(!isDefined() && !importIDSet.isDefined()) //both undefined
- {
- if(doCount)
- {
- undefinedSize += importIDSet.getUndefinedSize();
- }
- }
- else if(!isDefined()) //this undefined
- {
- if(doCount)
- {
- undefinedSize += importIDSet.size();
- }
- }
- else if(!importIDSet.isDefined()) //other undefined
- {
- isDefined = false;
- if(doCount)
- {
- undefinedSize = size() + importIDSet.getUndefinedSize();
- } else {
- undefinedSize = Long.MAX_VALUE;
- }
- array = null;
- count = 0;
- }
- else if (count + importIDSet.size() > limit) //add together => undefined
- {
- isDefined = false;
- if(doCount) {
- undefinedSize = size() + importIDSet.size();
- } else {
- undefinedSize = Long.MAX_VALUE;
- }
- array = null;
- count = 0;
- } else {
- addAll(importIDSet);
- }
- }
-
-
/**
* Add the specified entry id to an import ID set.
*
@@ -199,7 +113,6 @@
addEntryID(entryID.longValue());
}
-
/**
* Add the specified long value to an import ID set.
*
@@ -214,8 +127,7 @@
}
if (l < 0 || (isDefined() && count + 1 > limit))
{
- isDefined = false;
- array = null;
+ setUndefined();
if(doCount) {
undefinedSize = count + 1;
} else {
@@ -227,14 +139,13 @@
}
}
-
private boolean mergeCount(byte[] dBbytes, ImportIDSet importIdSet) {
boolean incrementLimitCount=false;
boolean dbUndefined = isDBUndefined(dBbytes);
if (dbUndefined && !importIdSet.isDefined()) {
undefinedSize = JebFormat.entryIDUndefinedSizeFromDatabase(dBbytes) +
- importIdSet.getUndefinedSize();
+ importIdSet.undefinedSize;
isDefined=false;
} else if (dbUndefined && importIdSet.isDefined()) {
undefinedSize = JebFormat.entryIDUndefinedSizeFromDatabase(dBbytes) +
@@ -242,7 +153,7 @@
isDefined=false;
} else if(!importIdSet.isDefined()) {
int dbSize = JebFormat.entryIDListFromDatabase(dBbytes).length;
- undefinedSize = dbSize + importIdSet.getUndefinedSize();
+ undefinedSize = dbSize + importIdSet.undefinedSize;
isDefined = false;
incrementLimitCount = true;
} else {
@@ -259,7 +170,6 @@
return incrementLimitCount;
}
-
/**
* Remove the specified import ID set from the byte array read from the DB.
*
@@ -289,9 +199,6 @@
}
}
-
-
-
/**
* Merge the specified byte array read from a DB, with the specified import
* ID set. The specified limit and maintain count parameters define
@@ -352,8 +259,6 @@
count = c;
}
-
-
private void addAll(ImportIDSet that) {
resize(this.count+that.count);
@@ -434,7 +339,6 @@
count = destPos;
}
-
/**
* Return the number of IDs in an import ID set.
*
@@ -445,7 +349,6 @@
return count;
}
-
private boolean add(long v)
{
resize(count+1);
@@ -473,7 +376,6 @@
return true;
}
-
private static int binarySearch(long[] a, int count, long key)
{
int low = 0;
@@ -500,8 +402,6 @@
return -(low + 1); // key not found.
}
-
-
private void resize(int size)
{
if (array == null)
@@ -521,10 +421,8 @@
System.arraycopy(array, 0, newBytes, 0, count);
array = newBytes;
}
-
}
-
/**
* Create a byte array suitable to write to a JEB DB from an import ID set.
*
@@ -539,7 +437,6 @@
}
}
-
private byte[] encode(byte[] bytes)
{
int encodedSize = count * 8;
@@ -560,7 +457,6 @@
return bytes;
}
-
/**
* Set the DB key related to an import ID set.
*
@@ -571,7 +467,6 @@
this.key = key;
}
-
/**
* Return the DB key related to an import ID set.
*
--
Gitblit v1.10.0