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

Examples of com.orientechnologies.orient.core.db.record.ridbag.ORidBag


    compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER));
    compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo"));
    compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER));

    final ORidBag ridBag = new ORidBag();
    final List<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> firedEvents = new ArrayList<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>>();

    ridBag.add(new ORecordId("#10:1"));
    ridBag.add(new ORecordId("#10:2"));
    ridBag.add(new ORecordId("#10:3"));
    ridBag.remove(new ORecordId("#10:2"));

    ridBag.addChangeListener(new OMultiValueChangeListener<OIdentifiable, OIdentifiable>() {
      public void onAfterRecordChanged(final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> event) {
        firedEvents.add(event);
      }
    });

    ridBag.add(new ORecordId("#10:4"));
    ridBag.remove(new ORecordId("#10:1"));

    Map<OCompositeKey, Integer> keysToAdd = new HashMap<OCompositeKey, Integer>();
    Map<OCompositeKey, Integer> keysToRemove = new HashMap<OCompositeKey, Integer>();

    for (OMultiValueChangeEvent<OIdentifiable, OIdentifiable> multiValueChangeEvent : firedEvents)
View Full Code Here


    assertEquals(OType.LINKLIST, OType.getTypeByValue(new ORecordLazyList(new ODocument())));

    assertEquals(OType.LINKMAP, OType.getTypeByValue(new ORecordLazyMap(new ODocument())));

    assertEquals(OType.LINKBAG, OType.getTypeByValue(new ORidBag()));

    assertEquals(OType.CUSTOM, OType.getTypeByValue(new CustomClass()));

    assertEquals(OType.EMBEDDEDLIST, OType.getTypeByValue(new Object[] {}));
View Full Code Here

      for (String fieldName : vertex.fieldNames()) {
        if (fieldName.startsWith(OrientVertex.CONNECTION_IN_PREFIX) || fieldName.startsWith(OrientVertex.CONNECTION_OUT_PREFIX)) {
          Object oldValue = vertex.field(fieldName);
          if (oldValue instanceof OMVRBTreeRIDSet) {
            OMVRBTreeRIDSet oldTree = (OMVRBTreeRIDSet) oldValue;
            ORidBag bag = new ORidBag();
            bag.addAll(oldTree);

            vertex.field(fieldName, bag);
          }
        }
      }
View Full Code Here

    db.create();
    db.declareIntent(new OIntentMassiveInsert());

    ODocument document = new ODocument();
    ORidBag ridBag = new ORidBag();
    ridBag.setAutoConvertToRecord(false);

    document.field("ridBag", ridBag);
    for (int i = 0; i < 100; i++) {
      final ORID ridToAdd = new ORecordId(0, OClusterPositionFactory.INSTANCE.valueOf(positionCounter.incrementAndGet()));
      ridBag.add(ridToAdd);
      ridTree.add(ridToAdd);
    }
    document.save();

    docContainerRid = document.getIdentity();

    List<Future<Void>> futures = new ArrayList<Future<Void>>();

    for (int i = 0; i < 5; i++)
      futures.add(threadExecutor.submit(new RidAdder(i)));

    for (int i = 0; i < 5; i++)
      futures.add(threadExecutor.submit(new RidDeleter(i)));

    latch.countDown();

    Thread.sleep(30 * 60000);
    cont = false;

    for (Future<Void> future : futures)
      future.get();

    document = db.load(document.getIdentity());
    document.setLazyLoad(false);

    ridBag = document.field("ridBag");

    for (OIdentifiable identifiable : ridBag)
      Assert.assertTrue(ridTree.remove(identifiable.getIdentity()));

    Assert.assertTrue(ridTree.isEmpty());

    System.out.println("Result size is " + ridBag.size());
    db.close();
  }
View Full Code Here

          while (true) {
            ODocument document = db.load(docContainerRid);
            document.setLazyLoad(false);

            ORidBag ridBag = document.field("ridBag");
            for (ORID rid : ridsToAdd)
              ridBag.add(rid);

            try {
              document.save();
            } catch (OConcurrentModificationException e) {
              continue;
View Full Code Here

      try {
        while (cont) {
          while (true) {
            ODocument document = db.load(docContainerRid);
            document.setLazyLoad(false);
            ORidBag ridBag = document.field("ridBag");
            Iterator<OIdentifiable> iterator = ridBag.iterator();

            List<ORID> ridsToDelete = new ArrayList<ORID>();
            int counter = 0;
            while (iterator.hasNext()) {
              OIdentifiable identifiable = iterator.next();
View Full Code Here

  public void testAddTwoNewDocuments() {
    database.begin();
    ODocument rootDoc = new ODocument();

    ORidBag ridBag = new ORidBag();
    rootDoc.field("ridBag", ridBag);

    rootDoc.save();
    database.commit();

    database.begin();

    ODocument docOne = new ODocument();
    ODocument docTwo = new ODocument();

    ridBag.add(docOne);
    ridBag.add(docTwo);

    rootDoc.save();

    database.rollback();

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    Assert.assertEquals(ridBag.size(), 0);
  }
View Full Code Here

    cmeDoc.save();

    database.begin();
    ODocument rootDoc = new ODocument();

    ORidBag ridBag = new ORidBag();
    rootDoc.field("ridBag", ridBag);

    rootDoc.save();
    database.commit();

    ODocument staleCMEDoc = database.load(cmeDoc.getIdentity());
    Assert.assertNotSame(staleCMEDoc, cmeDoc);
    cmeDoc.field("v", "v");
    cmeDoc.save();

    database.begin();

    ODocument docOne = new ODocument();
    ODocument docTwo = new ODocument();

    ridBag.add(docOne);
    ridBag.add(docTwo);

    staleCMEDoc.field("v", "v1");
    staleCMEDoc.save();

    try {
      database.commit();
      Assert.fail();
    } catch (OConcurrentModificationException e) {
    }

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    Assert.assertEquals(ridBag.size(), 0);
  }
View Full Code Here

  public void testAddTwoAdditionalNewDocuments() {
    database.begin();

    ODocument rootDoc = new ODocument();

    ORidBag ridBag = new ORidBag();
    rootDoc.field("ridBag", ridBag);

    ODocument docOne = new ODocument();
    ODocument docTwo = new ODocument();

    ridBag.add(docOne);
    ridBag.add(docTwo);

    rootDoc.save();

    database.commit();

    long recordsCount = database.countClusterElements(database.getDefaultClusterId());

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    database.begin();

    ODocument docThree = new ODocument();
    ODocument docFour = new ODocument();

    ridBag.add(docThree);
    ridBag.add(docFour);

    rootDoc.save();

    database.rollback();

    Assert.assertEquals(database.countClusterElements(database.getDefaultClusterId()), recordsCount);

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    Assert.assertEquals(ridBag.size(), 2);

    Iterator<OIdentifiable> iterator = ridBag.iterator();
    List<OIdentifiable> addedDocs = new ArrayList<OIdentifiable>(Arrays.asList(docOne, docTwo));

    Assert.assertTrue(addedDocs.remove(iterator.next()));
    Assert.assertTrue(addedDocs.remove(iterator.next()));
  }
View Full Code Here

    database.begin();

    ODocument rootDoc = new ODocument();

    ORidBag ridBag = new ORidBag();
    rootDoc.field("ridBag", ridBag);

    ODocument docOne = new ODocument();
    ODocument docTwo = new ODocument();

    ridBag.add(docOne);
    ridBag.add(docTwo);

    rootDoc.save();

    database.commit();

    long recordsCount = database.countClusterElements(database.getDefaultClusterId());

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    ODocument staleCMEDoc = database.load(cmeDoc.getIdentity());
    Assert.assertNotSame(staleCMEDoc, cmeDoc);
    cmeDoc.field("v", "v");
    cmeDoc.save();

    database.begin();

    ODocument docThree = new ODocument();
    ODocument docFour = new ODocument();

    ridBag.add(docThree);
    ridBag.add(docFour);

    rootDoc.save();

    staleCMEDoc.field("v", "v1");
    staleCMEDoc.save();

    try {
      database.commit();
      Assert.fail();
    } catch (OConcurrentModificationException e) {
    }

    Assert.assertEquals(database.countClusterElements(database.getDefaultClusterId()), recordsCount);

    rootDoc = database.load(rootDoc.getIdentity());
    ridBag = rootDoc.field("ridBag");

    Assert.assertEquals(ridBag.size(), 2);

    Iterator<OIdentifiable> iterator = ridBag.iterator();
    List<OIdentifiable> addedDocs = new ArrayList<OIdentifiable>(Arrays.asList(docOne, docTwo));

    Assert.assertTrue(addedDocs.remove(iterator.next()));
    Assert.assertTrue(addedDocs.remove(iterator.next()));
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.record.ridbag.ORidBag

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.