Package com.mysql.cluster.ndbj

Examples of com.mysql.cluster.ndbj.NdbResultSet


        NdbOperation op = tx.getSelectOperation(model.table_A);
        assert op != null;
        final int int_val = 1;
        op.equalInt("id", int_val);
        op.getValue("id"); // XXX error with index instead of "id"
        final NdbResultSet rs = op.resultData();
        tx.execute(ExecType.Commit, AbortOption.AbortOnError, true);
        while (rs.next()) {
            int id = rs.getInt("id"); // XXX error with index instead of "id"
            assert id == int_val;
        }
        tx.close();
        tx = null;
    }
View Full Code Here


        }
        commitTransaction();

        // check fetched values
        for (int i = 0, j = from; i < count; i++, j++) {
            final NdbResultSet rs = rss[i];
            final boolean hasNext = rs.next();
            assert hasNext;

            // check key attribute
            final int id = rs.getInt(model.name_id);
            verify(id == j);

            // check other attributes
            final int id1 = getCommonAttributes(rs);
            verify(id1 == j);

            assert !rs.next();
        }
        closeTransaction();
    }
View Full Code Here

        //executeOperations();
        commitTransaction();

        // check fetched values
        for (int i = 0, j = from; i < count; i++, j++) {
            final NdbResultSet rs = rss[i];
            final boolean hasNext = rs.next();
            assert hasNext;

            // check varbinary
            final byte[] cvarbinary_def
                = rs.getBytes(model.name_B0_cvarbinary_def);
            verify(Arrays.equals(bytes, cvarbinary_def));

            assert !rs.next();
        }
        closeTransaction();
    }
View Full Code Here

        //executeOperations();
        commitTransaction();

        // check fetched values
        for (int i = 0, j = from; i < count; i++, j++) {
            final NdbResultSet rs = rss[i];
            final boolean hasNext = rs.next();
            assert hasNext;

            // check varchar
            if (true) {
                final String cvarchar_def
                    = rs.getString(model.name_B0_cvarchar_def);
                verify(string.equals(cvarchar_def));
            } else {
                // verification imposes a string->bytes conversion penalty
                final byte[] cvarchar_def
                    = rs.getStringBytes(model.name_B0_cvarchar_def);
                verify(Arrays.equals(string.getBytes(), cvarchar_def));
            }

            assert !rs.next();
        }
        closeTransaction();
    }
View Full Code Here

        // fetch the foreign keys from B0 and read attributes from A
        final NdbResultSet[] abs = new NdbResultSet[nOps];
        for (int i = 1, j = 0; i <= nOps; i++, j++) {
            // fetch the foreign key value from B0
            NdbResultSet rs;
            {
                // get a read operation for the table
                NdbOperation op = tx.getSelectOperation(model.table_B0);
                assert op != null;

                // set key attribute
                op.equalInt(model.name_id, i);

                // define fetched attributes
                op.getValue(model.name_B0_a_id);

                // get attributes (not readable until after commit)
                rs = op.resultData();
            }
            executeOperations(); // start the scan; don't commit yet

            // fetch the attributes from A
            {
                // get a read operation for the table
                NdbOperation op = tx.getSelectOperation(model.table_A);
                assert op != null;

                // set key attribute
                final int a_id = rs.getInt(model.name_B0_a_id);
                assert a_id == ((i - 1) % nOps) + 1;
                op.equalInt(model.name_id, a_id);

                // define fetched attributes
                op.getValue(model.name_id);
                fetchCommonAttributes(op);

                // get attributes (not readable until after commit)
                abs[j] = op.resultData();
            }

            // execute the operation now if in non-batching mode
            if (!batch)
                executeOperations();
        }
        commitTransaction();

        // check fetched values
        for (int i = 1, j = 0; i <= nOps; i++, j++) {
            final NdbResultSet ab = abs[j];
            final boolean hasNext = ab.next();
            assert hasNext;

            // check key attribute
            final int id = ab.getInt(model.name_id);
            //out.println("id = " + id + ", i = " + i);
            verify(id == ((i - 1) % nOps) + 1);

            // check other attributes
            final int k = getCommonAttributes(ab);
            verify(k == id);

            assert !ab.next();
        }
        closeTransaction();
    }
View Full Code Here

        }
        commitTransaction();

        // check fetched values
        for (int i = 1, j = 0; i <= nOps; i++, j++) {
            final NdbResultSet ab = abs[j];
            final boolean hasNext = ab.next();
            assert hasNext;

            // check key attribute
            final int id = ab.getInt(model.name_id);
            //out.println("id = " + id + ", i = " + i);
            verify(id == ((i - 1) % nOps) + 1);

            // check other attributes
            final int k = getCommonAttributes(ab);
            verify(k == id);

            assert !ab.next();
        }
        closeTransaction();
    }
View Full Code Here

            NdbOperation.LockMode.LM_CommittedRead);
          indexScanOp.setBoundString(BackendImpl.IDX_VAL,
            NdbIndexScanOperation.BoundType.BoundEQ,
            filter.getAssertionValue().toString());
          indexScanOp.getValue(BackendImpl.EID);
          NdbResultSet rs = indexScanOp.resultData();
          rsList.add(rs);
          defined = true;
        }
        break;

      case GREATER_OR_EQUAL:
        attrName = filter.getAttributeType().getNameOrOID();
        if (BackendImpl.indexes.contains(attrName)) {
          NdbIndexScanOperation indexScanOp =
            ndbTxn.getSelectIndexScanOperation(BackendImpl.IDX_VAL,
            BackendImpl.IDX_TABLE_PREFIX + attrName,
            NdbOperation.LockMode.LM_CommittedRead);
          indexScanOp.setBoundString(BackendImpl.IDX_VAL,
            NdbIndexScanOperation.BoundType.BoundGE,
            filter.getAssertionValue().toString());
          indexScanOp.getValue(BackendImpl.EID);
          NdbResultSet rs = indexScanOp.resultData();
          rsList.add(rs);
          defined = true;
        }
        break;

      case LESS_OR_EQUAL:
        attrName = filter.getAttributeType().getNameOrOID();
        if (BackendImpl.indexes.contains(attrName)) {
          NdbIndexScanOperation indexScanOp =
            ndbTxn.getSelectIndexScanOperation(BackendImpl.IDX_VAL,
            BackendImpl.IDX_TABLE_PREFIX + attrName,
            NdbOperation.LockMode.LM_CommittedRead);
          indexScanOp.setBoundString(BackendImpl.IDX_VAL,
            NdbIndexScanOperation.BoundType.BoundLE,
            filter.getAssertionValue().toString());
          indexScanOp.getValue(BackendImpl.EID);
          NdbResultSet rs = indexScanOp.resultData();
          rsList.add(rs);
          defined = true;
        }
        break;

      case PRESENT:
        attrName = filter.getAttributeType().getNameOrOID();
        if (BackendImpl.indexes.contains(attrName)) {
          NdbIndexScanOperation indexScanOp =
            ndbTxn.getSelectIndexScanOperation(BackendImpl.IDX_VAL,
            BackendImpl.IDX_TABLE_PREFIX + attrName,
            NdbOperation.LockMode.LM_CommittedRead);
          indexScanOp.setBoundString(BackendImpl.IDX_VAL,
            NdbIndexScanOperation.BoundType.BoundLT, "");
          indexScanOp.getValue(BackendImpl.EID);
          NdbResultSet rs = indexScanOp.resultData();
          rsList.add(rs);
          defined = true;
        }
        break;
View Full Code Here

  public boolean remove(AbstractTransaction txn, Entry entry)
       throws NdbApiException
  {
    DN dn = entry.getDN();

    NdbResultSet rs = null;

    NdbTransaction ndbTxn = txn.getNdbTransaction();

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

    boolean extensibleObject = false;

    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);
    op.getValue(BackendImpl.DN2ID_OC);
    op.getValue(BackendImpl.DN2ID_XOC);

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

    long eid = 0;
    NdbTransaction ndbDATxn = null;
    String[] ocsStringArray = null;
    String[] xocsStringArray = null;
    List<NdbResultSet> ocRsList = new ArrayList<NdbResultSet>();
    NdbIndexScanOperation indexScanOp = null;

    if (rs.next()) {
      eid = rs.getLong(BackendImpl.EID);
      String ocsString = rs.getString(BackendImpl.DN2ID_OC);
      ocsStringArray = ocsString.split(" ");

      String xocsString = rs.getString(BackendImpl.DN2ID_XOC);
      xocsStringArray = xocsString.split(" ");
      if (xocsString.length() > 0) {
        extensibleObject = true;
      }

      for (String ocName : ocsStringArray) {
        ObjectClass oc =
          DirectoryServer.getObjectClass(ocName, true);
        if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
          continue;
        }
        if (ndbDATxn == null) {
          ndbDATxn = txn.getNdbDATransaction(ocName, eid);
        }
        indexScanOp =
          ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, ocName);
        indexScanOp.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, eid);
        indexScanOp.getValue(BackendImpl.MID);
        ocRsList.add(indexScanOp.resultData());
      }

      // Extensible object.
      if (extensibleObject) {
        for (String xocName : xocsStringArray) {
          ObjectClass xoc =
            DirectoryServer.getObjectClass(xocName, true);
          if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
            continue;
          }
          if (ndbDATxn == null) {
            ndbDATxn = txn.getNdbDATransaction(xocName, eid);
          }
          indexScanOp =
            ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, xocName);
          indexScanOp.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, eid);
          indexScanOp.getValue(BackendImpl.MID);
          ocRsList.add(indexScanOp.resultData());
        }
      }
    }

    // Attribute options.
    if (ndbDATxn == null) {
      ndbDATxn = txn.getNdbDATransaction(BackendImpl.TAGS_TABLE, eid);
    }
    indexScanOp = ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME,
      BackendImpl.TAGS_TABLE);
    indexScanOp.setBoundLong(BackendImpl.EID,
      NdbIndexScanOperation.BoundType.BoundEQ, eid);
    indexScanOp.getValue(BackendImpl.TAG_ATTR);
    indexScanOp.getValue(BackendImpl.MID);
    NdbResultSet tagRs = indexScanOp.resultData();

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

    Iterator<NdbResultSet> rsIterator = ocRsList.iterator();
    for (String ocName : ocsStringArray) {
      ObjectClass oc =
        DirectoryServer.getObjectClass(ocName, true);
      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }
      NdbResultSet ocRs = rsIterator.next();
      while (ocRs.next()) {
        int mid = ocRs.getInt(BackendImpl.MID);
        op = ndbDATxn.getDeleteOperation(ocName);
        op.equalLong(BackendImpl.EID, eid);
        op.equalInt(BackendImpl.MID, mid);
      }
    }

    // Extensible object.
    if (extensibleObject) {
      for (String xocName : xocsStringArray) {
        ObjectClass xoc =
          DirectoryServer.getObjectClass(xocName, true);
        if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
          continue;
        }
        NdbResultSet ocRs = rsIterator.next();
        while (ocRs.next()) {
          int mid = ocRs.getInt(BackendImpl.MID);
          op = ndbDATxn.getDeleteOperation(xocName);
          op.equalLong(BackendImpl.EID, eid);
          op.equalInt(BackendImpl.MID, mid);
        }
      }
View Full Code Here

  public Entry get(AbstractTransaction txn, long eid,
    NdbOperation.LockMode lockMode)
       throws NdbApiException, DirectoryException
  {
    NdbIndexScanOperation indexScanOp = null;
    NdbResultSet rs = null;
    DN dn = null;

    NdbTransaction ndbTxn = txn.getNdbTransaction();

    indexScanOp = ndbTxn.getSelectIndexScanOperation(
      BackendImpl.EID, name, lockMode);
    indexScanOp.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, eid);
    for (int i = 0; i < BackendImpl.DN2ID_DN_NC; i++) {
      indexScanOp.getValue(BackendImpl.DN2ID_DN +
        Integer.toString(i));
    }
    indexScanOp.getValue(BackendImpl.DN2ID_OC);
    indexScanOp.getValue(BackendImpl.DN2ID_XOC);

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

    if (rs.next()) {
      StringBuilder dnBuffer = new StringBuilder();
      int dnColumnIndex = BackendImpl.DN2ID_DN_NC - 1;
      while (dnColumnIndex >= 0) {
        String rdnString = rs.getString(BackendImpl.DN2ID_DN +
          Integer.toString(dnColumnIndex));
        if (rdnString.length() > 0) {
          dnBuffer.append(rdnString);
          if (dnColumnIndex > 0) {
            dnBuffer.append(",");
View Full Code Here

   */
  public Entry get(AbstractTransaction txn, DN dn,
    NdbOperation.LockMode lockMode) throws NdbApiException
  {
    NdbOperation op = null;
    NdbResultSet rs = null;

    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);
    op.getValue(BackendImpl.DN2ID_OC);
    op.getValue(BackendImpl.DN2ID_XOC);

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

    if (rs.next()) {
      long eid = rs.getLong(BackendImpl.EID);
      if (eid == 0) {
        return null;
      }
      Entry entry = getNDBEntry(txn, rs, dn, eid);
      if (entry != null) {
View Full Code Here

TOP

Related Classes of com.mysql.cluster.ndbj.NdbResultSet

Copyright © 2018 www.massapicom. 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.