Examples of NdbResultSet


Examples of com.mysql.cluster.ndbj.NdbResultSet

    tagScanOp.setBoundLong(BackendImpl.EID,
      NdbIndexScanOperation.BoundType.BoundEQ, eid);
    tagScanOp.getValue(BackendImpl.TAG_ATTR);
    tagScanOp.getValue(BackendImpl.MID);
    tagScanOp.getValue(BackendImpl.TAG_TAGS);
    NdbResultSet tagRs = tagScanOp.resultData();

    ndbDATxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    return decodeNDBEntry(dn, ocRsList, tagRs, objectClasses,
      xObjectClasses, blobMap, extensibleObject);
View Full Code Here

Examples of com.mysql.cluster.ndbj.NdbResultSet

      }
    }

    // Object classes and user atributes.
    Iterator<NdbResultSet> ocRsIterator = ocRsList.iterator();
    NdbResultSet ocRs = ocRsIterator.next();
    AttributeBuilder attrBuilder = new AttributeBuilder();
    for (ObjectClass oc : objectClasses.keySet()) {
      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }
      while (ocRs.next()) {
        int mid = ocRs.getInt(BackendImpl.MID);
        for (AttributeType reqAttr : oc.getRequiredAttributes()) {
          String attrName = reqAttr.getNameOrOID();
          byte[] attrValBytes = null;
          NdbBlob blob = null;
          if (BackendImpl.blobAttributes.contains(attrName)) {
            Map<String, NdbBlob> attr2Blob =
              blobMap.get(objectClasses.get(oc));
            blob = attr2Blob.get(attrName);
          } else {
            attrValBytes = ocRs.getStringBytes(attrName);
            if (ocRs.wasNull()) {
              continue;
            }
          }
          AttributeType attributeType =
            DirectoryServer.getAttributeType(
            BackendImpl.attrName2LC.get(attrName), true);
          List<Attribute> attrList = userAttributes.get(attributeType);
          if (attrList == null) {
            attrList = new ArrayList<Attribute>();
          }
          Attribute attr = null;
          LinkedHashSet<String> options = null;
          Map<Integer, LinkedHashSet<String>> mid2tagMap =
            attr2tagMap.get(attrName);
          if (mid2tagMap != null) {
            options = mid2tagMap.get(mid);
          }
          if ((options == null) && !attrList.isEmpty()) {
            attr = attrList.get(attrList.size() - 1);
          }
          if (attr == null) {
            attrBuilder.setAttributeType(attributeType, attrName);
          } else {
            attrBuilder = new AttributeBuilder(attr);
          }
          if (blob != null) {
            if (blob.getNull()) {
              continue;
            }
            int len = blob.getLength().intValue();
            byte[] buf = new byte[len];
            blob.readData(buf, len);
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(buf)));
          } else {
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(attrValBytes)));
          }

          // Create or update an attribute.
          if (options != null) {
            attrBuilder.setOptions(options);
          }
          attr = attrBuilder.toAttribute();
          if (attrList.isEmpty()) {
            attrList.add(attr);
          } else {
            attrList.set(attrList.size() - 1, attr);
          }

          userAttributes.put(attributeType, attrList);
        }
        for (AttributeType optAttr : oc.getOptionalAttributes()) {
          String attrName = optAttr.getNameOrOID();
          byte[] attrValBytes = null;
          NdbBlob blob = null;
          if (BackendImpl.blobAttributes.contains(attrName)) {
            Map<String, NdbBlob> attr2Blob =
              blobMap.get(objectClasses.get(oc));
            blob = attr2Blob.get(attrName);
          } else {
            attrValBytes = ocRs.getStringBytes(attrName);
            if (ocRs.wasNull()) {
              continue;
            }
          }
          AttributeType attributeType =
            DirectoryServer.getAttributeType(
            BackendImpl.attrName2LC.get(attrName), true);
          List<Attribute> attrList = userAttributes.get(attributeType);
          if (attrList == null) {
            attrList = new ArrayList<Attribute>();
          }
          Attribute attr = null;
          LinkedHashSet<String> options = null;
          Map<Integer, LinkedHashSet<String>> mid2tagMap =
            attr2tagMap.get(attrName);
          if (mid2tagMap != null) {
            options = mid2tagMap.get(mid);
          }
          if ((options == null) && !attrList.isEmpty()) {
            attr = attrList.get(attrList.size() - 1);
          }
          if (attr == null) {
            attrBuilder.setAttributeType(attributeType, attrName);
          } else {
            attrBuilder = new AttributeBuilder(attr);
          }
          if (blob != null) {
            if (blob.getNull()) {
              continue;
            }
            int len = blob.getLength().intValue();
            byte[] buf = new byte[len];
            blob.readData(buf, len);
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(buf)));
          } else {
            attrBuilder.add(AttributeValues.create(attributeType,
              ByteString.wrap(attrValBytes)));
          }

          // Create or update an attribute.
          if (options != null) {
            attrBuilder.setOptions(options);
          }
          attr = attrBuilder.toAttribute();
          if (attrList.isEmpty()) {
            attrList.add(attr);
          } else {
            attrList.set(attrList.size() - 1, attr);
          }

          userAttributes.put(attributeType, attrList);
        }
      }
      if (ocRsIterator.hasNext()) {
        ocRs = ocRsIterator.next();
      }
    }

    // Operational attributes.
    if (ocRs.next()) {
      for (String attrName : BackendImpl.operationalAttributes) {
        byte[] attrValBytes = ocRs.getStringBytes(attrName);
        if (ocRs.wasNull()) {
          continue;
        }
        AttributeType attributeType =
          DirectoryServer.getAttributeType(
          BackendImpl.attrName2LC.get(attrName), true);
View Full Code Here

Examples of com.mysql.cluster.ndbj.NdbResultSet

  public long getID(AbstractTransaction txn, DN dn,
    NdbOperation.LockMode lockMode)
       throws NdbApiException
  {
    NdbOperation op = null;
    NdbResultSet rs = null;
    long eid = 0;

    NdbTransaction ndbTxn = txn.getNdbTransaction();

    op = ndbTxn.getSelectOperation(name, lockMode);

    int componentIndex = dn.getNumComponents() - 1;
    for (int i=0; i < BackendImpl.DN2ID_DN_NC; i++) {
      while (componentIndex >= 0) {
        op.equalString(BackendImpl.DN2ID_DN + Integer.toString(i),
          dn.getRDN(componentIndex).toNormalizedString());
        componentIndex--;
        i++;
      }
      op.equalString(BackendImpl.DN2ID_DN +
        Integer.toString(i), "");
    }

    op.getValue(BackendImpl.EID);

    rs = op.resultData();
    ndbTxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    if (rs.next()) {
      eid = rs.getLong(BackendImpl.EID);
    }

    return eid;
  }
View Full Code Here

Examples of com.mysql.cluster.ndbj.NdbResultSet

   */
  public Set<String> getReferrals(AbstractTransaction txn, long id)
       throws NdbApiException
  {
    NdbIndexScanOperation op = null;
    NdbResultSet rs = null;
    Set<String> referrals = new HashSet<String>();

    NdbTransaction ndbDATxn =
      txn.getNdbDATransaction(BackendImpl.REFERRALS_TABLE, id);

    op = ndbDATxn.getSelectIndexScanOperation(
      PRIMARY_INDEX_NAME, BackendImpl.REFERRALS_TABLE,
      NdbOperation.LockMode.LM_CommittedRead);
    op.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, id);

    op.getValue(ATTR_REFERRAL_URL);
    rs = op.resultData();

    ndbDATxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    while (rs.next()) {
      String referral = rs.getString(ATTR_REFERRAL_URL);
      if (rs.wasNull() || (referral.length() == 0)) {
        break;
      }
      referrals.add(referral);
    }

View Full Code Here

Examples of com.mysql.cluster.ndbj.NdbResultSet

   */
  public boolean hasSubordinates(AbstractTransaction txn, DN dn)
    throws NdbApiException
  {
    NdbIndexScanOperation op;
    NdbResultSet rs;

    NdbTransaction ndbTxn = txn.getNdbTransaction();

    // Set batch size and parallel scans to
    // their minimum values to reduce churn.
    op = ndbTxn.getSelectIndexScanOperation(
      PRIMARY_INDEX_NAME, name,
      NdbOperation.LockMode.LM_CommittedRead,
      NdbScanOperation.ScanFlag.NO_FLAG, 1, 1);

    int numComponents = dn.getNumComponents();
    int componentIndex = numComponents - 1;
    for (int i=0; i < numComponents; i++) {
      op.setBoundString(BackendImpl.DN2ID_DN +
        Integer.toString(i),
        NdbIndexScanOperation.BoundType.BoundEQ,
        dn.getRDN(componentIndex).toNormalizedString());
      componentIndex--;
    }

    if (dn.getNumComponents() < BackendImpl.DN2ID_DN_NC) {
      String nextRDNColumn =
        BackendImpl.DN2ID_DN + Integer.toString(numComponents);
      op.setBoundString(nextRDNColumn,
        NdbIndexScanOperation.BoundType.BoundLT, "");
    }

    // FIXME: Need NDB/J API like native interpretExitLastRow
    // to do this more efficiently without additional hops.
    op.getValue(BackendImpl.EID);

    rs = op.resultData();
    ndbTxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    if (rs.next()) {
      return true;
    }

    return false;
  }
View Full Code Here

Examples of com.mysql.cluster.ndbj.NdbResultSet

  public long numSubordinates(AbstractTransaction txn, DN dn,
    boolean subtree) throws NdbApiException
  {
    long numSubordinates = 0;
    NdbIndexScanOperation op;
    NdbResultSet rs;

    NdbTransaction ndbTxn = txn.getNdbTransaction();

    op = ndbTxn.getSelectIndexScanOperation(
      PRIMARY_INDEX_NAME, name,
      NdbOperation.LockMode.LM_CommittedRead);

    int numComponents = dn.getNumComponents();
    int componentIndex = numComponents - 1;
    for (int i=0; i < numComponents; i++) {
      op.setBoundString(BackendImpl.DN2ID_DN +
        Integer.toString(i),
        NdbIndexScanOperation.BoundType.BoundEQ,
        dn.getRDN(componentIndex).toNormalizedString());
      componentIndex--;
    }

    // FIXME: Need multi range bound here to optimize in
    // NOT subtree case which would prevent subtree walk
    // when it is not needed. need NDB/J API to do that.
    // native API: NdbIndexScanOperation::end_of_bound()
    if (dn.getNumComponents() < BackendImpl.DN2ID_DN_NC) {
      String nextRDNColumn =
        BackendImpl.DN2ID_DN + Integer.toString(numComponents);
      op.setBoundString(nextRDNColumn,
        NdbIndexScanOperation.BoundType.BoundLT, "");
    }

    // FIXME: Need NDB/J API like native interpretExitLastRow
    // to do this more efficiently without additional hops.
    op.getValue(BackendImpl.EID);

    String subtreeColumn = BackendImpl.DN2ID_DN +
      Integer.toString(dn.getNumComponents() + 1);
    if (!subtree &&
        (dn.getNumComponents() < BackendImpl.DN2ID_DN_NC))
    {
      op.getValue(subtreeColumn);
    }

    rs = op.resultData();
    ndbTxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    while (rs.next()) {
      if (!subtree &&
          (dn.getNumComponents() < BackendImpl.DN2ID_DN_NC))
      {
        String columnValue = rs.getString(subtreeColumn);
        if ((columnValue != null) && (columnValue.length() > 0))
        {
          continue;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.