Package com.orientechnologies.orient.core.record

Examples of com.orientechnologies.orient.core.record.ORecord


      OPhysicalPosition[] positions = storage.ceilingPhysicalPositions(clusterId, new OPhysicalPosition(
          OClusterPositionFactory.INSTANCE.valueOf(0)));
      while (positions.length > 0) {
        for (OPhysicalPosition position : positions) {
          ORecord record = database.load(new ORecordId(clusterId, position.clusterPosition));
          if (record instanceof ODocument) {
            ODocument document = (ODocument) record;
            rewriteLinksInDocument(document);

            documents++;
View Full Code Here


          // PERSISTENT RIDS
          boolean first = true;
          for (OIdentifiable rid : tree.keySet()) {
            if (rid instanceof ORecord) {
              final ORecord record = (ORecord) rid;
              if (record.isDirty())
                record.save();
            }

            if (!first)
              buffer.append(OStringSerializerHelper.COLLECTION_SEPARATOR);
            else
View Full Code Here

        oldDelegate.setAutoConvertToRecord(false);

        for (OIdentifiable identifiable : oldDelegate)
          delegate.add(identifiable);

        final ORecord owner = oldDelegate.getOwner();
        delegate.setOwner(owner);
        owner.setDirty();

        oldDelegate.setAutoConvertToRecord(oldAutoConvert);
        oldDelegate.requestDelete();

      } else if (delegate.size() <= bottomThreshold && !isEmbedded()) {
        ORidBagDelegate oldDelegate = delegate;
        boolean oldAutoConvert = oldDelegate.isAutoConvertToRecord();
        oldDelegate.setAutoConvertToRecord(false);
        delegate = new OEmbeddedRidBag();

        for (OIdentifiable identifiable : oldDelegate)
          delegate.add(identifiable);

        final ORecord owner = oldDelegate.getOwner();
        delegate.setOwner(owner);
        owner.setDirty();

        oldDelegate.setAutoConvertToRecord(oldAutoConvert);
        oldDelegate.requestDelete();
      }
    }
View Full Code Here

  public OIdentifiable process() {
    while (target.hasNext()) {
      record = target.next();
      index++;

      final ORecord rec = record.getRecord();
      if (rec instanceof ODocument) {
        ODocument doc = (ODocument) rec;
        if (!doc.getIdentity().isPersistent() && doc.fields() == 1) {
          // EXTRACT THE FIELD CONTEXT
          Object fieldvalue = doc.field(doc.fieldNames()[0]);
View Full Code Here

  private OIdentifiable recursiveLinkSave(OIdentifiable link) {

    if (link instanceof ORID) {
      if (((ORID) link).isValid() && ((ORID) link).isNew()) {
        final ODatabaseRecord database = ODatabaseRecordThreadLocal.INSTANCE.get();
        ORecord record = link.getRecord();
        database.save(record);
        return record;
      }
    } else if (link instanceof ORecord) {
      ORID rid = link.getIdentity();
View Full Code Here

            // CREATE THE RIGHT RECORD INSTANCE
            iRecord = Orient.instance().getRecordFactoryManager().newInstance((byte) fieldValueAsString.charAt(0));
          }
        } else if (needReload && fieldName.equals(ODocumentHelper.ATTRIBUTE_RID) && iRecord instanceof ODocument) {
          if (fieldValue != null && fieldValue.length() > 0) {
            ORecord localRecord = ODatabaseRecordThreadLocal.INSTANCE.get().load(new ORecordId(fieldValueAsString));
            if (localRecord != null)
              iRecord = localRecord;
          }
        } else if (fieldName.equals(ODocumentHelper.ATTRIBUTE_CLASS) && iRecord instanceof ODocument) {
          ((ODocument) iRecord).setClassNameIfExists("null".equals(fieldValueAsString) ? null : fieldValueAsString);
View Full Code Here

      // JUST THE REFERENCE
      rid = (ORID) iLinked;

      if (rid.isValid() && rid.isNew()) {
        // SAVE AT THE FLY AND STORE THE NEW RID
        final ORecord record = rid.getRecord();

        final ODatabaseRecord database = ODatabaseRecordThreadLocal.INSTANCE.get();
        if (database.getTransaction().isActive()) {
          // USE THE DEFAULT CLUSTER
          database.save((ORecord) record);

        } else
          database.save((ORecord) record);

        if (record != null)
          rid = record.getIdentity();
        resultRid = rid;
      }
    } else {
      if (iLinked instanceof String)
        iLinked = new ORecordId((String) iLinked);
      else if (!(iLinked instanceof ORecord)) {
        // NOT RECORD: TRY TO EXTRACT THE DOCUMENT IF ANY
        final String boundDocumentField = OObjectSerializerHelperManager.getInstance().getDocumentBoundField(iLinked.getClass());
        if (boundDocumentField != null)
          iLinked = OObjectSerializerHelperManager.getInstance().getFieldValue(iLinked, boundDocumentField);
      }

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

      // RECORD
      ORecord iLinkedRecord = ((OIdentifiable) iLinked).getRecord();
      rid = iLinkedRecord.getIdentity();

      if ((rid.isNew() && !rid.isTemporary()) || iLinkedRecord.isDirty()) {
        final ODatabaseRecordInternal database = ODatabaseRecordThreadLocal.INSTANCE.get();
        if (iLinkedRecord instanceof ODocument) {
          final OClass schemaClass = ((ODocument) iLinkedRecord).getSchemaClass();
          database.save(iLinkedRecord, schemaClass != null ? database.getClusterNameById(schemaClass.getClusterForNewInstance())
              : null);
        } else
          // STORE THE TRAVERSED OBJECT TO KNOW THE RECORD ID. CALL THIS VERSION TO AVOID CLEAR OF STACK IN THREAD-LOCAL
          database.save(iLinkedRecord);

        final ODatabaseComplex<?> dbOwner = database.getDatabaseOwner();
        dbOwner.registerUserObjectAfterLinkSave(iLinkedRecord);

        resultRid = iLinkedRecord;
      }

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

    if (rid.isValid())
      rid.toString(buffer);
View Full Code Here

      // TRY WITH THE DATABASE CONSTRUCTOR
      for (Constructor<?> c : cls.getDeclaredConstructors()) {
        Class<?>[] params = c.getParameterTypes();

        if (params.length == 2 && params[1].equals(ORID.class)) {
          ORecord rec = (ORecord) c.newInstance(new ORecordId(content.toString()));
          // rec.load();
          return rec;
        }
      }
    } catch (Exception e) {
View Full Code Here

        buffer.append('\"');
      } else {
        if (iFormat != null && iFormat.contains("shallow"))
          buffer.append("{}");
        else {
          final ORecord rec = linked.getRecord();
          if (rec != null)
            buffer.append(rec.toJSON(iFormat));
          else
            buffer.append("null");
        }
      }
View Full Code Here

  public Object fromStream(final byte[] iStream) throws IOException {
    if (iStream == null || iStream.length == 0)
      // NULL VALUE
      return null;

    final ORecord obj = Orient.instance().getRecordFactoryManager().newInstance();

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

    ORecordInternal.setIdentity(obj, rid.getClusterId(), rid.getClusterPosition());
    return obj;
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.record.ORecord

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.