Package com.orientechnologies.orient.core.db.record

Examples of com.orientechnologies.orient.core.db.record.OIdentifiable


    bag.add(new ORecordId("#77:1"));
    Iterator<OIdentifiable> iterator = bag.iterator();
    Assert.assertTrue(iterator.hasNext());

    OIdentifiable identifiable = iterator.next();
    Assert.assertEquals(identifiable, new ORecordId("#77:1"));

    Assert.assertTrue(!iterator.hasNext());
    assertEmbedded(bag.isEmbedded());
  }
View Full Code Here


    for (OIdentifiable identifiable : bag)
      rids.add(identifiable);

    Iterator<OIdentifiable> iterator = bag.iterator();
    while (iterator.hasNext()) {
      final OIdentifiable identifiable = iterator.next();
      if (identifiable.equals(new ORecordId("#77:4"))) {
        iterator.remove();
        assertTrue(rids.remove(identifiable));
      }
    }
View Full Code Here

    int r6c = 0;
    int r4c = 0;
    int r7c = 0;

    while (iterator.hasNext()) {
      OIdentifiable identifiable = iterator.next();
      if (identifiable.equals(new ORecordId("#77:2"))) {
        if (r2c < 2) {
          r2c++;
          iterator.remove();
          rids.remove(identifiable);
        }
      }

      if (identifiable.equals(new ORecordId("#77:3"))) {
        if (r3c < 1) {
          r3c++;
          iterator.remove();
          rids.remove(identifiable);
        }
      }

      if (identifiable.equals(new ORecordId("#77:6"))) {
        if (r6c < 1) {
          r6c++;
          iterator.remove();
          rids.remove(identifiable);
        }
      }

      if (identifiable.equals(new ORecordId("#77:4"))) {
        if (r4c < 1) {
          r4c++;
          iterator.remove();
          rids.remove(identifiable);
        }
      }

      if (identifiable.equals(new ORecordId("#77:7"))) {
        if (r7c < 1) {
          r7c++;
          iterator.remove();
          rids.remove(identifiable);
        }
View Full Code Here

      docToAdd.save();
    }

    Iterator<OIdentifiable> iterator = docsToAdd.listIterator(7);
    while (iterator.hasNext()) {
      OIdentifiable docToAdd = iterator.next();
      ridBag.remove(docToAdd);
      iterator.remove();
    }

    document.save();
View Full Code Here

  private void massiveInsertionIteration(Random rnd, List<OIdentifiable> rids, ORidBag bag) {
    Iterator<OIdentifiable> bagIterator = bag.iterator();

    while (bagIterator.hasNext()) {
      OIdentifiable bagValue = bagIterator.next();
      Assert.assertTrue(rids.contains(bagValue));
    }

    Assert.assertEquals(bag.size(), rids.size());

    for (int i = 0; i < 100; i++) {
      if (rnd.nextDouble() < 0.2 & rids.size() > 5) {
        final int index = rnd.nextInt(rids.size());
        final OIdentifiable rid = rids.remove(index);
        bag.remove(rid);
      } else {
        final int positionIndex = rnd.nextInt(300);
        final OClusterPosition position = OClusterPositionFactory.INSTANCE.valueOf(positionIndex);

        final ORecordId recordId = new ORecordId(1, position);
        rids.add(recordId);
        bag.add(recordId);
      }
    }

    bagIterator = bag.iterator();

    while (bagIterator.hasNext()) {
      final OIdentifiable bagValue = bagIterator.next();
      Assert.assertTrue(rids.contains(bagValue));

      if (rnd.nextDouble() < 0.05) {
        bagIterator.remove();
        Assert.assertTrue(rids.remove(bagValue));
      }
    }

    Assert.assertEquals(bag.size(), rids.size());
    bagIterator = bag.iterator();

    while (bagIterator.hasNext()) {
      final OIdentifiable bagValue = bagIterator.next();
      Assert.assertTrue(rids.contains(bagValue));
    }
  }
View Full Code Here

    documentCopy.reload("*:-1", true);
    embeddedList = documentCopy.field("embeddedList");
    doc = embeddedList.get(0);

    iterator = doc.<ORidBag> field("ridBag").iterator();
    OIdentifiable remvedItem = iterator.next();
    iterator.remove();
    doc.<ORidBag> field("ridBag").add(docToAdd.getIdentity());

    Assert.assertTrue(!ODocumentHelper.hasSameContentOf(document, database, documentCopy, database, null));
    doc.<ORidBag> field("ridBag").remove(docToAdd.getIdentity());
View Full Code Here

    Random rnd = new Random();

    for (int i = 0; i < newDocs.size(); i++) {
      if (rnd.nextBoolean()) {
        OIdentifiable newDoc = newDocs.get(i);
        rids.remove(newDoc);
        ridBag.remove(newDoc);
        newDocs.remove(newDoc);

        size--;
View Full Code Here

     * @return
     * @throws SqlInjectionException
     */
    public ODocument getByName(String tagName) throws SqlInjectionException {
        if (Logger.isTraceEnabled()) Logger.trace("Method Start");
        OIdentifiable record = findByName(tagName);
        ODocument doc = record==null?null:(ODocument)db.load(record.getIdentity());
        if (Logger.isTraceEnabled()) Logger.trace("Method End");
        return doc;
    }
View Full Code Here

  }//getNewModelInstance(String collectionName)
 
  public boolean existsCollection(String collectionName) throws SqlInjectionException{
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    OIndex idx = db.getMetadata().getIndexManager().getIndex(COLLECTION_NAME_INDEX);
    OIdentifiable record = (OIdentifiable) idx.get( collectionName );
    if (Logger.isTraceEnabled()) Logger.trace("Method End");
    return (record!=null) ;
  }
View Full Code Here

  }
 
  public ODocument getByName(String collectionName) throws SqlInjectionException{
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    OIndex idx = db.getMetadata().getIndexManager().getIndex(COLLECTION_NAME_INDEX);
    OIdentifiable record = (OIdentifiable) idx.get( collectionName );
    if (record==null) return null;
    return db.load(record.getIdentity());
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.record.OIdentifiable

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.