Package com.orientechnologies.orient.core.id

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


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

      final ORID rid = iRecord.getIdentity();
      if (rid.isValid())
        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

  }

  public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException {
    final long timer = OProfiler.getInstance().startChrono();

    final ORID rootRid = new ORecordId();

    try {
      final OMemoryInputStream stream = new OMemoryInputStream(iStream);

      byte protocolVersion = stream.peek();
      if (protocolVersion != -1) {
        // @COMPATIBILITY BEFORE 0.9.25
        stream.getAsByte();
        if (protocolVersion != CURRENT_PROTOCOL_VERSION)
          throw new OSerializationException(
              "The index has been created with a previous version of OrientDB. Soft transitions between version is a featured supported since 0.9.25. In order to use it with this version of OrientDB you need to export and import your database. "
                  + protocolVersion + "<->" + CURRENT_PROTOCOL_VERSION);
      }

      rootRid.fromStream(stream.getAsByteArrayFixed(ORecordId.PERSISTENT_SIZE));

      size = stream.getAsInteger();
      if (protocolVersion == -1)
        // @COMPATIBILITY BEFORE 0.9.25
        lastPageSize = stream.getAsShort();
      else
        lastPageSize = stream.getAsInteger();

      serializerFromStream(stream);

      // LOAD THE ROOT OBJECT AFTER ALL
      if (rootRid.isValid())
        root = loadEntry(null, rootRid);

      return this;

    } catch (Exception e) {
View Full Code Here

    Assert.assertTrue(result.iterator().next().toString().equals("#13:54"));

    result = database.command(new OCommandSQL("find references 19:0")).execute();

    Assert.assertTrue(result.size() == 2);
    ORID rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals("#22:0") || rid.toString().equals("#21:0"));
    rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals("#22:0") || rid.toString().equals("#21:0"));

    result = database.command(new OCommandSQL("find references 9:0")).execute();
    Assert.assertTrue(result.size() == 0);

    result.clear();
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

    recordsToCommit.add((OMVRBTreeEntryPersistent<K, V>) iNode);
  }

  @Override
  public int hashCode() {
    final ORID rid = record.getIdentity();
    return rid == null ? 0 : rid.hashCode();
  }
View Full Code Here

    if (iLinked == null)
      // NULL REFERENCE
      return null;

    OIdentifiable resultRid = null;
    ORID rid;

    if (iLinked instanceof ORID) {
      // JUST THE REFERENCE
      rid = (ORID) iLinked;
    } else {
      if (!(iLinked instanceof ORecordInternal<?>)) {
        // NOT RECORD: TRY TO EXTRACT THE DOCUMENT IF ANY
        final String boundDocumentField = OObjectSerializerHelper.getDocumentBoundField(iLinked.getClass());
        if (boundDocumentField != null)
          iLinked = OObjectSerializerHelper.getFieldValue(iLinked, boundDocumentField);
      }

      if (!(iLinked instanceof ORecordInternal<?>))
        throw new IllegalArgumentException("Invalid object received. Expected a record but received type="
            + iLinked.getClass().getName() + " and value=" + iLinked);

      // RECORD
      ORecordInternal<?> iLinkedRecord = (ORecordInternal<?>) iLinked;
      rid = iLinkedRecord.getIdentity();

      if (rid.isNew() || iLinkedRecord.isDirty()) {
        if (iLinkedRecord.getDatabase() == null && iParentRecord != null)
          // OVERWRITE THE DATABASE TO THE SAME OF THE PARENT ONE
          iLinkedRecord.setDatabase(iParentRecord.getDatabase());

        if (iLinkedRecord instanceof ODocument) {
          final OClass schemaClass = ((ODocument) iLinkedRecord).getSchemaClass();
          iLinkedRecord.getDatabase().save(iLinkedRecord,
              schemaClass != null ? iLinkedRecord.getDatabase().getClusterNameById(schemaClass.getDefaultClusterId()) : null);
        } else
          // STORE THE TRAVERSED OBJECT TO KNOW THE RECORD ID. CALL THIS VERSION TO AVOID CLEAR OF STACK IN THREAD-LOCAL
          iLinkedRecord.getDatabase().save(iLinkedRecord);

        iLinkedRecord.getDatabase().registerPojo(iLinkedRecord.getDatabase().getUserObjectByRecord(iLinkedRecord, null),
            iLinkedRecord);

        resultRid = iLinkedRecord;
      }

      if (iParentRecord != null && iParentRecord.getDatabase() instanceof ODatabaseRecord) {
        final ODatabaseRecord db = iParentRecord.getDatabase();
        if (!db.isRetainRecords())
          // REPLACE CURRENT RECORD WITH ITS ID: THIS SAVES A LOT OF MEMORY
          resultRid = iLinkedRecord.getIdentity();
      }
    }

    if (rid.isValid())
      rid.toString(buffer);

    return resultRid;
  }
View Full Code Here

    long totalRecords = 0;

    System.out.print("\nImporting records...");

    ORID rid;
    int lastClusterId = -1;
    long clusterRecords = 0;
    while (jsonReader.lastChar() != ']') {
      rid = importRecord();

      if (rid != null) {
        ++clusterRecords;

        if (rid.getClusterId() != lastClusterId || jsonReader.lastChar() == ']') {
          // CHANGED CLUSTERID: DUMP STATISTICS
          System.out.print("\n- Imported records into the cluster '" + database.getClusterNameById(lastClusterId) + "': "
              + clusterRecords + " records");
          clusterRecords = 0;
          lastClusterId = rid.getClusterId();
        }

        ++totalRecords;
      } else
        lastClusterId = 0;
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.