Package com.orientechnologies.orient.core.db.record

Examples of com.orientechnologies.orient.core.db.record.OIdentifiable


    modificationLock.requestModificationLock();
    try {
      checkForKeyType(key);
      acquireExclusiveLock();
      try {
        final OIdentifiable value = indexEngine.get(key);

        if (value != null) {
          // CHECK IF THE ID IS THE SAME OF CURRENT: THIS IS THE UPDATE CASE
          if (!value.equals(iSingleValue)) {
            final Boolean mergeSameKey = metadata != null ? (Boolean) metadata.field(OIndex.MERGE_KEYS) : Boolean.FALSE;
            if (mergeSameKey != null && mergeSameKey)
              // IGNORE IT, THE EXISTENT KEY HAS BEEN MERGED
              ;
            else
              throw new ORecordDuplicatedException(String.format(
                  "Cannot index record %s: found duplicated key '%s' in index '%s' previously assigned to the record %s",
                  iSingleValue.getIdentity(), key, getName(), value.getIdentity()), value.getIdentity());
          } else
            return this;
        }

        if (!iSingleValue.getIdentity().isPersistent())
View Full Code Here


  protected void putInSnapshot(Object key, OIdentifiable value, Map<Object, Object> snapshot) {
    key = getCollatingValue(key);

    Object snapshotValue = snapshot.get(key);
    if (snapshotValue == null) {
      final OIdentifiable storedValue = indexEngine.get(key);

      final Set<OIdentifiable> values = new LinkedHashSet<OIdentifiable>();

      if (storedValue != null)
        values.add(storedValue.getIdentity());

      values.add(value.getIdentity());

      snapshot.put(key, values);
    } else if (snapshotValue instanceof Set) {
View Full Code Here

        if (values.isEmpty())
          continue;

        final Iterator<OIdentifiable> valuesIterator = values.iterator();
        if (values.size() > 1) {
          final OIdentifiable valueOne = valuesIterator.next();
          final OIdentifiable valueTwo = valuesIterator.next();
          throw new ORecordDuplicatedException(String.format(
              "Cannot index record %s: found duplicated key '%s' in index '%s' previously assigned to the record %s",
              valueTwo.getIdentity(), key, getName(), valueOne.getIdentity()), valueOne.getIdentity());
        }

        final OIdentifiable value = valuesIterator.next();
        indexEngine.put(key, value.getIdentity());
      } else if (snapshotValue.equals(RemovedValue.INSTANCE))
        indexEngine.remove(key);
      else
        assert false : "Provided value can not be committed";
    }
View Full Code Here

    checkForRebuild();

    key = getCollatingValue(key);

    // CHECK IF ALREADY EXIST
    final OIdentifiable indexedRID = get(key);
    if (indexedRID != null && !indexedRID.getIdentity().equals(record.getIdentity())) {
      final Boolean mergeSameKey = metadata != null && (Boolean) metadata.field(OIndex.MERGE_KEYS);
      if (mergeSameKey != null && mergeSameKey)
        return (ODocument) indexedRID.getRecord();
      else
        throw new OIndexException("Cannot index record : " + record + " found duplicated key '" + key + "' in index " + getName()
            + " previously assigned to the record " + indexedRID);
    }
    return null;
View Full Code Here

    return new OIndexAbstractCursor() {
      private Iterator<?> keysIterator = sortedKeys.iterator();

      @Override
      public Map.Entry<Object, OIdentifiable> nextEntry() {
        OIdentifiable result = null;
        Object key = null;
        while (keysIterator.hasNext() && result == null) {
          key = keysIterator.next();
          key = getCollatingValue(key);

          acquireSharedLock();
          try {
            result = indexEngine.get(key);
          } finally {
            releaseSharedLock();
          }
        }

        if (result == null)
          return null;

        final Object resultKey = key;
        final OIdentifiable resultValue = result;

        return new Map.Entry<Object, OIdentifiable>() {
          @Override
          public Object getKey() {
            return resultKey;
View Full Code Here

  private void addIndexesEntries(ODocument document) {
    document = checkForLoading(document);

    // STORE THE RECORD IF NEW, OTHERWISE ITS RID
    final OIdentifiable rid = document.getIdentity().isPersistent() ? document.placeholder() : document;

    final OClass cls = document.getSchemaClass();
    if (cls != null) {
      final Collection<OIndex<?>> indexes = cls.getIndexes();
      for (final OIndex<?> index : indexes) {
View Full Code Here

      newEntries.put(record, NEWMAP_VALUE);
      setDirty();
      return null;
    }

    final OIdentifiable oldValue = super.internalPut(e, null);

    if (!isMarshalling()) {
      if (oldValue != null)
        fireCollectionChangedEvent(new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(
            OMultiValueChangeEvent.OChangeType.UPDATE, e, e, oldValue));
View Full Code Here

      PROFILER.stopChrono(PROFILER.getProcessMetric("mvrbtree.putAll"), "Put multiple values in a MVRBTreeRID", timer);
    }
  }

  public OIdentifiable remove(final Object o) {
    final OIdentifiable removed;

    if (hasNewItems() && newEntries.containsKey(o)) {
      // REMOVE IT INSIDE NEW ITEMS MAP
      removed = (OIdentifiable) o;
      newEntries.remove(o);
View Full Code Here

    Map.Entry<Object, OIdentifiable> entry = cursor.nextEntry();
    while (entry != null) {
      ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx);
      Integer key = (Integer) entry.getKey();

      OIdentifiable identifiable = entry.getValue();
      ODocument doc = identifiable.getRecord();

      long ts = doc.<Long> field("ts");
      if (ts > lastTs)
        lastTs = ts;
View Full Code Here

    Map.Entry<Object, OIdentifiable> entry = cursor.nextEntry();
    while (entry != null) {
      ODatabaseRecordThreadLocal.INSTANCE.set(baseDocumentTx);
      Integer key = (Integer) entry.getKey();

      OIdentifiable identifiable = entry.getValue();
      ODocument doc = identifiable.getRecord();

      long ts = doc.<Long> field("ts");
      if (ts > lastTs)
        lastTs = ts;
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.record.OIdentifiable

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.