Package com.orientechnologies.orient.core.id

Examples of com.orientechnologies.orient.core.id.ORID


      return (ODocument) iPojo;

    ODocument record = objects2Records.get(System.identityHashCode(iPojo));
    if (record == null) {
      // SEARCH BY RID
      final ORID rid = OObjectSerializerHelper.getObjectID(this, iPojo);
      if (rid != null && rid.isValid()) {
        record = rid2Records.get(rid);
        if (record == null)
          // LOAD IT
          record = underlying.load(rid);
      } else if (iCreateIfNotAvailable) {
View Full Code Here


        OObjectSerializerHelper.setObjectID(iRecord.getIdentity(), iObject);
        OObjectSerializerHelper.setObjectVersion(iRecord.getVersion(), iObject);
      }

      final ORID rid = iRecord.getIdentity();
      // if (rid.isValid() && !rid.isTemporary())
      rid2Records.put(rid, doc);
    }
  }
View Full Code Here

      objects2Records.remove(System.identityHashCode(iObject));

    if (iRecord != null) {
      records2Objects.remove(iRecord);

      final ORID rid = iRecord.getIdentity();
      if (rid.isValid())
        rid2Records.remove(rid);
    }
  }
View Full Code Here

        for (Entry<String, Object> e : map.entrySet()) {
          map.put(e.getKey(), convertParameter(e.getValue()));
        }

      } else if (iParameter != null && !OType.isSimpleType(iParameter)) {
        final ORID rid = getIdentity(iParameter);
        if (rid != null && rid.isValid())
          // REPLACE OBJECT INSTANCE WITH ITS RECORD ID
          return rid;
      }

    return iParameter;
View Full Code Here

    List<ODocument> resultset = database.query(new OSQLSynchQuery<ODocument>(query));
    Assert.assertFalse(resultset.isEmpty());
    Assert.assertTrue(resultset.size() <= 3);

    while (!resultset.isEmpty()) {
      ORID last = resultset.get(resultset.size() - 1).getIdentity();

      resultset = database.query(new OSQLSynchQuery<ODocument>(query + " range " + last.next()));
      Assert.assertTrue(resultset.size() <= 3);

      for (ODocument d : resultset)
        Assert.assertTrue(d.getIdentity().getClusterId() >= last.getClusterId()
            && d.getIdentity().getClusterPosition() > last.getClusterPosition());
    }

    database.close();
  }
View Full Code Here

  public void queryWithPagination() {
    database.open("admin", "admin");

    final OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("select from Profile LIMIT 3");

    ORID last = new ORecordId();

    for (List<ODocument> resultset = database.query(query); !resultset.isEmpty(); resultset = query.execute()) {
      Assert.assertTrue(resultset.size() <= 3);

      for (ODocument d : resultset)
        Assert.assertTrue(d.getIdentity().getClusterId() >= last.getClusterId()
            && d.getIdentity().getClusterPosition() > last.getClusterPosition());

      last = resultset.get(resultset.size() - 1).getIdentity();
    }

    database.close();
View Full Code Here

          continue;

        final long ts = System.currentTimeMillis();

        final int position = random.nextInt(lastClusterPosition.intValue());
        final ORID orid = new ORecordId(defaultClusterId, OClusterPositionFactory.INSTANCE.valueOf(position));

        lockManager.acquireLock(this, orid, OLockManager.LOCK.EXCLUSIVE);
        try {

          try {
View Full Code Here

          if (lastClusterPosition == null)
            continue;

          final long ts = System.currentTimeMillis();
          final long position = random.nextInt(lastClusterPosition.intValue());
          final ORID orid = new ORecordId(defaultClusterId, OClusterPositionFactory.INSTANCE.valueOf(position));

          lockManager.acquireLock(this, orid, OLockManager.LOCK.EXCLUSIVE);
          try {
            ODatabaseDocumentTx base_db = ODatabaseDocumentPool.global().acquire(URL_BASE, "admin", "admin");
            final List<ORID> ridsToRemove = new ArrayList<ORID>();
View Full Code Here

  public OTransaction lockRecord(final OIdentifiable iRecord, final OStorage.LOCKING_STRATEGY iLockingStrategy) {
    final OStorage stg = database.getStorage();
    if (!(stg.getUnderlying() instanceof OStorageEmbedded))
      throw new OLockException("Cannot lock record across remote connections");

    final ORID rid = iRecord.getIdentity();
    // if (locks.containsKey(rid))
    // throw new IllegalStateException("Record " + rid + " is already locked");

    if (iLockingStrategy == OStorage.LOCKING_STRATEGY.KEEP_EXCLUSIVE_LOCK)
      ((OStorageEmbedded) stg.getUnderlying()).acquireWriteLock(rid);
View Full Code Here

  public OTransaction unlockRecord(final OIdentifiable iRecord) {
    final OStorage stg = database.getStorage();
    if (!(stg.getUnderlying() instanceof OStorageEmbedded))
      throw new OLockException("Cannot lock record across remote connections");

    final ORID rid = iRecord.getIdentity();

    final OStorage.LOCKING_STRATEGY lock = locks.remove(rid);

    if (lock == null)
      throw new OLockException("Cannot unlock a never acquired lock");
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.id.ORID

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.