Package com.orientechnologies.orient.core.id

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


  public OIndexInternal loadFromConfiguration(final ODocument iConfig) {
    acquireExclusiveLock();
    try {

      final ORID rid = (ORID) iConfig.field(CONFIG_MAP_RID, ORID.class);
      if (rid == null)
        return null;

      configuration = iConfig;
      name = configuration.field(OIndexInternal.CONFIG_NAME);
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

          if (value != null) {
            if (!(value instanceof ORecord<?>))
              throw new ODatabaseException("Invalid property value in '" + p.getName() + "': found " + value.getClass()
                  + " while it was expected a ORecord");

            ORID rid = ((ORecord<?>) value).getIdentity();
            out.writeInt(rid.getClusterId());
            out.writeLong(rid.getClusterPosition());
          }
          break;
        case LINKLIST:
          break;
        case LINKSET:
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

    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

  }

  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

    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

      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

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.