Package com.orientechnologies.orient.core.record

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


   public Object execute(final OServer iServer, ODistributedServerManager iManager, final ODatabaseDocumentTx database)
       throws Exception {
     ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "updating record %s/%s v.%s",
         database.getName(), rid.toString(), version.toString());

     ORecord loadedRecord = rid.getRecord();
     if (loadedRecord == null)
       throw new ORecordNotFoundException("Record " + rid + " was not found on update");

     if (loadedRecord instanceof ODocument) {
       // APPLY CHANGES FIELD BY FIELD TO MARK DIRTY FIELDS FOR INDEXES/HOOKS
       final ODocument newDocument = new ODocument().fromStream(content);
       ((ODocument) loadedRecord).merge(newDocument, false, false);
     } else
       ORecordInternal.fill(loadedRecord, rid, version, content, true);

     loadedRecord = database.save(loadedRecord);

     ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "+-> updated record %s/%s v.%s",
         database.getName(), rid.toString(), loadedRecord.getRecordVersion().toString());

     return loadedRecord.getRecordVersion();
   }
View Full Code Here


   }

   @Override
   public Object execute(final OServer iServer, ODistributedServerManager iManager, final ODatabaseDocumentTx database)
       throws Exception {
     final ORecord record = database.load(rid);
     if (record == null)
       return null;

     return new ORawBuffer(record);
   }
View Full Code Here

    if (value == null)
      return null;

    if (value instanceof ORecordId && autoConvert2Record && ODatabaseRecordThreadLocal.INSTANCE.isDefined()) {
      try {
        final ORecord rec = ((ORecordId) value).getRecord();
        if (underlying instanceof OLazyIterator<?>)
          ((OLazyIterator<OIdentifiable>) underlying).update(rec);
        value = rec;
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error on iterating record collection", e);
View Full Code Here

      throw new OCommandExecutionException("Class '" + baseClassName + "' is not defined in database schema");

    OClass cls = null;
    if (iLeft instanceof OIdentifiable) {
      // GET THE RECORD'S CLASS
      final ORecord record = ((OIdentifiable) iLeft).getRecord();
      if (record instanceof ODocument) {
        cls = ((ODocument) record).getSchemaClass();
      }
    } else if (iLeft instanceof String)
      // GET THE CLASS BY NAME
View Full Code Here

       // BECAUSE IT'S ALWAYS INCREMENTED)
       for (int retry = 0; retry < MAX_RETRIES; ++retry) {
         ODistributedServerLog
             .debug(this, cluster.getLocalNodeName(), iRemoteNode, DIRECTION.IN, "Resolved conflict automatically between versions on CREATE record %s/%s v.%d (other RID=%s v.%d). Current record version will be overwritten", database.getName(), iCurrentRID, iCurrentVersion, iOtherRID, iOtherVersion);

         final ORecord record = iCurrentRID.getRecord();
         ORecordInternal.setVersion(record, iOtherVersion - 1);
         record.setDirty();

         try {
           record.save();
           return;
         } catch (OConcurrentModificationException e) {
           // CONCURRENT OPERATION, RETRY AGAIN?
         }
       }
View Full Code Here

   }

   protected int deleteRecord(final ODatabaseRecord iDatabase, final ORID rid, final ORecordVersion version) {
     try {
       // TRY TO SEE IF THE RECORD EXISTS
       final ORecord record = rid.getRecord();
       if (record == null)
         return 0;

       iDatabase.delete(rid, version);
       return 1;
View Full Code Here

     return 1;
   }

   protected ORecord createRecord(final ODatabaseRecordInternal iDatabase, final ORecordId rid, final byte[] buffer,
       final byte recordType) {
     final ORecord record = Orient.instance().getRecordFactoryManager().newInstance(recordType);
     fillRecord(rid, buffer, OVersionFactory.instance().createVersion(), record, iDatabase);
     iDatabase.save(record);
     return record;
   }
View Full Code Here

     return record;
   }

   protected ORecordVersion updateRecord(final ODatabaseRecordInternal iDatabase, final ORecordId rid, final byte[] buffer,
       final ORecordVersion version, final byte recordType, boolean updateContent) {
     final ORecord newRecord = Orient.instance().getRecordFactoryManager().newInstance(recordType);
     fillRecord(rid, buffer, version, newRecord, null);

     ORecordInternal.setContentChanged(newRecord, updateContent);

     final ORecord currentRecord;
     if (newRecord instanceof ODocument) {
       currentRecord = iDatabase.load(rid);

       if (currentRecord == null)
         throw new ORecordNotFoundException(rid.toString());

       ((ODocument) currentRecord).merge((ODocument) newRecord, false, false);

     } else
       currentRecord = newRecord;

     currentRecord.getRecordVersion().copyFrom(version);

     iDatabase.save(currentRecord);

     if (currentRecord.getIdentity().toString().equals(iDatabase.getStorage().getConfiguration().indexMgrRecordId)
         && !iDatabase.getStatus().equals(STATUS.IMPORTING)) {
       // FORCE INDEX MANAGER UPDATE. THIS HAPPENS FOR DIRECT CHANGES FROM REMOTE LIKE IN GRAPH
       iDatabase.getMetadata().getIndexManager().reload();
     }
     return currentRecord.getRecordVersion();
   }
View Full Code Here

    byte[] data = null;
    if (candidate instanceof byte[]) {
      data = (byte[]) candidate;
    } else if (candidate instanceof ORecordId) {
      final ORecord rec = ((ORecordId) candidate).getRecord();
      if (rec instanceof ORecordBytes) {
        data = ((ORecordBytes) rec).toStream();
      }
    } else if (candidate instanceof OSerializableStream) {
      data = ((OSerializableStream) candidate).toStream();
View Full Code Here

    return buffer.append(']').toString();
  }

  protected V internalPut(final K key, final V value) throws OLowMemoryException {
    ORecord rec;

    if (key instanceof ORecord) {
      // RECORD KEY: ASSURE IT'S PERSISTENT TO AVOID STORING INVALID RIDs
      rec = (ORecord) key;
      if (!rec.getIdentity().isValid())
        rec.save();
    }

    if (value instanceof ORecord) {
      // RECORD VALUE: ASSURE IT'S PERSISTENT TO AVOID STORING INVALID RIDs
      rec = (ORecord) value;
      if (!rec.getIdentity().isValid())
        rec.save();
    }

    for (int i = 0; i < OPTIMIZE_MAX_RETRY; ++i) {
      try {
        return super.put(key, value);
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.