From d0fa149bb033b08cd0e14c28beb5c1a4d2a7ed06 Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Thu, 09 Apr 2009 22:43:42 +0000
Subject: [PATCH] - add numSubordinates support.

---
 opends/src/server/org/opends/server/backends/ndb/EntryContainer.java |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java b/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java
index 196afa7..fe9daaf 100644
--- a/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java
+++ b/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java
@@ -219,6 +219,38 @@
   }
 
   /**
+   * Determine the number of subordinate entries for a given entry.
+   *
+   * @param  entryDN The distinguished name of the entry.
+   * @param  subtree <code>true</code> will include all the entries
+   *         under the given entries. <code>false</code> will only
+   *         return the number of entries immediately under the
+   *         given entry.
+   * @return The number of subordinate entries for the given entry
+   *         or -1 if the entry does not exist.
+   * @throws com.mysql.cluster.ndbj.NdbApiException If an error
+   *         occurs in the database.
+   */
+  public long getNumSubordinates(DN entryDN, boolean subtree)
+      throws NdbApiException
+  {
+    if (baseDN.equals(entryDN)) {
+      // Shortcut to avoid scan.
+      return getEntryCount() - 1;
+    }
+
+    AbstractTransaction txn = new AbstractTransaction(rootContainer);
+
+    try {
+      return dn2id.numSubordinates(txn, entryDN, subtree);
+    } finally {
+      if (txn != null) {
+        txn.close();
+      }
+    }
+  }
+
+  /**
    * Processes the specified search in this entryContainer.
    * Matching entries should be provided back to the core server using the
    * <CODE>SearchOperation.returnEntry</CODE> method.

--
Gitblit v1.10.0