Package com.orientechnologies.orient.core.id

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


        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


    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

        }
      }

      final ORecordInternal<?> obj = constructor.newInstance(iDatabase);

      final ORID rid = new ORecordId().fromStream(iStream);

      obj.setIdentity(rid.getClusterId(), rid.getClusterPosition());
      return obj;
    } catch (Exception e) {
      if (constructor == null)
        OLogManager.instance().error(this, "Constructor not found for record class '%s'", e, OSerializationException.class,
            iDatabase.getRecordType());
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

    rebuild(iProgressListener);
    return this;
  }

  public OIndex loadFromConfiguration(final ODocument iConfig) {
    final ORID rid = (ORID) iConfig.field(CONFIG_MAP_RID, ORID.class);
    if (rid == null)
      return null;

    configuration = iConfig;
    name = configuration.field(OIndex.CONFIG_NAME);
View Full Code Here

      value = iKey;
    else
      value = super.get(iKey);

    if (value != null && value instanceof ORID) {
      final ORID rid = (ORID) value;

      try {
        final ORecord<?> record = database.load(rid);
        // OVERWRITE IT
        super.put(iKey, record);
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

  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

    return tot;
  }

  @Override
  public OIndex put(final Object iKey, OIdentifiable iValue) {
    final ORID rid = iValue.getIdentity();

    if (!rid.isValid())
      // EARLY SAVE IT
      ((ORecord<?>) iValue).save();

    database.getTransaction().addIndexEntry(delegate, super.getName(), OPERATION.PUT, iKey, rid);
    return this;
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

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.