Skip to content

Commit

Permalink
Revert "Merge pull request #8559 from orientechnologies/revert-8432-d…
Browse files Browse the repository at this point in the history
…iffUpdateRedesignTracking"

This reverts commit 6cc7e54, reversing
changes made to f5810cd.
  • Loading branch information
markodjurovic committed Sep 24, 2018
1 parent 5a1ea48 commit 16b73cd
Show file tree
Hide file tree
Showing 30 changed files with 5,361 additions and 533 deletions.
Expand Up @@ -45,6 +45,8 @@ public class ORecordOperation implements Comparable {
public ORecordCallback<Long> createdCallback = null; public ORecordCallback<Long> createdCallback = null;
public ORecordCallback<Integer> updatedCallback = null; public ORecordCallback<Integer> updatedCallback = null;


private Object resultData;

public ORecordOperation() { public ORecordOperation() {
} }


Expand Down Expand Up @@ -82,6 +84,10 @@ public ORecord getRecord() {
return record != null ? record.getRecord() : null; return record != null ? record.getRecord() : null;
} }


public OIdentifiable getRecordContainer() {
return record;
}

public ORID getRID() { public ORID getRID() {
return record != null ? record.getIdentity() : null; return record != null ? record.getIdentity() : null;
} }
Expand Down Expand Up @@ -127,4 +133,13 @@ public byte getType() {
public int compareTo(Object o) { public int compareTo(Object o) {
return record.compareTo(((ORecordOperation) o).record); return record.compareTo(((ORecordOperation) o).record);
} }

public Object getResultData() {
return resultData;
}

public void setResultData(Object resultData) {
this.resultData = resultData;
}

} }
Expand Up @@ -63,9 +63,9 @@
* </ul> * </ul>
* <br> * <br>
* The representation is automatically converted to tree-based implementation when top threshold is reached. And backward to * The representation is automatically converted to tree-based implementation when top threshold is reached. And backward to
* embedded one when size is decreased to bottom threshold. <br> * embedded one when size is decreased to bottom threshold. <br> The thresholds could be configured by {@link
* The thresholds could be configured by {@link OGlobalConfiguration#RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD} and * OGlobalConfiguration#RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD} and {@link OGlobalConfiguration#RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD}.
* {@link OGlobalConfiguration#RID_BAG_SBTREEBONSAI_TO_EMBEDDED_THRESHOLD}. <br> * <br>
* <br> * <br>
* This collection is used to efficiently manage relationships in graph model.<br> * This collection is used to efficiently manage relationships in graph model.<br>
* <br> * <br>
Expand Down Expand Up @@ -150,14 +150,32 @@ public void addAll(Collection<OIdentifiable> values) {
delegate.addAll(values); delegate.addAll(values);
} }


@Override
public void add(OIdentifiable identifiable) { public void add(OIdentifiable identifiable) {
delegate.add(identifiable); delegate.add(identifiable);
} }


@Override
public void remove(OIdentifiable identifiable) { public void remove(OIdentifiable identifiable) {
delegate.remove(identifiable); delegate.remove(identifiable);
} }


/**
* for internal use only
*
* @param index
* @param newValue
*
* @return
*/
public boolean changeValue(int index, OIdentifiable newValue) {
if (isEmbedded()) {
return ((OEmbeddedRidBag) delegate).swap(index, newValue);
} else {
throw new UnsupportedOperationException("Operation not supported for SB Tree ridbags");
}
}

public boolean isEmpty() { public boolean isEmpty() {
return delegate.isEmpty(); return delegate.isEmpty();
} }
Expand Down Expand Up @@ -243,7 +261,7 @@ public int toStream(BytesContainer bytesContainer) throws OSerializationExceptio
delegate.serialize(stream, offset, oldUuid); delegate.serialize(stream, offset, oldUuid);
return pointer; return pointer;
} }

public void checkAndConvert() { public void checkAndConvert() {
ODatabaseInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined(); ODatabaseInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined();
if (database != null && !database.getStorage().isRemote()) { if (database != null && !database.getStorage().isRemote()) {
Expand Down Expand Up @@ -488,4 +506,35 @@ public NavigableMap<OIdentifiable, Change> getChanges() {
public void replace(OMultiValueChangeEvent<Object, Object> event, Object newValue) { public void replace(OMultiValueChangeEvent<Object, Object> event, Object newValue) {
//not needed do nothing //not needed do nothing
} }

@Override
public boolean equals(Object other) {
if (!(other instanceof ORidBag)) {
return false;
}

ORidBag otherRidbag = (ORidBag) other;
if (!delegate.getClass().equals(otherRidbag.delegate.getClass())) {
return false;
}

Iterator<OIdentifiable> firstIter = delegate.rawIterator();
Iterator<OIdentifiable> secondIter = otherRidbag.delegate.rawIterator();
while (firstIter.hasNext()) {
if (!secondIter.hasNext()) {
return false;
}

OIdentifiable firstElement = firstIter.next();
OIdentifiable secondElement = secondIter.next();
if (!Objects.equals(firstElement, secondElement)) {
return false;
}
}
if (secondIter.hasNext()) {
return false;
}

return true;
}
} }
Expand Up @@ -61,16 +61,16 @@ public void setSize(int size) {
private static enum Tombstone { private static enum Tombstone {
TOMBSTONE TOMBSTONE
} }

public Object[] getEntries(){ public Object[] getEntries() {
return entries; return entries;
} }


private final class EntriesIterator implements Iterator<OIdentifiable>, OResettable, OSizeable { private final class EntriesIterator implements Iterator<OIdentifiable>, OResettable, OSizeable {
private final boolean convertToRecord; private final boolean convertToRecord;
private int currentIndex = -1; private int currentIndex = -1;
private int nextIndex = -1; private int nextIndex = -1;
private boolean currentRemoved; private boolean currentRemoved;


private EntriesIterator(boolean convertToRecord) { private EntriesIterator(boolean convertToRecord) {
reset(); reset();
Expand All @@ -93,8 +93,8 @@ public boolean hasNext() {
@Override @Override
public OIdentifiable next() { public OIdentifiable next() {
currentRemoved = false; currentRemoved = false;

currentIndex = nextIndex; currentIndex = nextIndex;
if (currentIndex == -1) if (currentIndex == -1)
throw new NoSuchElementException(); throw new NoSuchElementException();


Expand Down Expand Up @@ -148,6 +148,22 @@ public void remove() {
nextValue)); nextValue));
} }


protected void swapValueOnCurrent(OIdentifiable newValue) {
if (currentRemoved)
throw new IllegalStateException("Current element has already been removed");

if (currentIndex == -1)
throw new IllegalStateException("Next method was not called for given iterator");

final OIdentifiable oldValue = (OIdentifiable) entries[currentIndex];
entries[currentIndex] = newValue;

contentWasChanged = true;

fireCollectionChangedEvent(
new OMultiValueChangeEvent<>(OMultiValueChangeEvent.OChangeType.UPDATE, oldValue, oldValue, newValue));
}

@Override @Override
public void reset() { public void reset() {
currentIndex = -1; currentIndex = -1;
Expand Down Expand Up @@ -268,6 +284,28 @@ public void remove(OIdentifiable identifiable) {
} }
} }


/**
* for internal use only
*
* @param index
* @param newValue
*
* @return
*/
public boolean swap(int index, OIdentifiable newValue) {
EntriesIterator iter = (EntriesIterator) rawIterator();
int currIndex = 0;
while (iter.hasNext()) {
iter.next();
if (index == currIndex) {
iter.swapValueOnCurrent(newValue);
return true;
}
currIndex++;
}
return false;
}

@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return size == 0; return size == 0;
Expand Down
@@ -0,0 +1,88 @@
/*
* Copyright 2018 OrientDB.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.orientechnologies.orient.core.delta;

import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.metadata.schema.OTypeInterface;

import java.util.HashMap;
import java.util.Map;

/**
* @author marko
*/
public enum ODeltaDocumentFieldType implements OTypeInterface {

DELTA_RECORD(Byte.MAX_VALUE);

private final int id;
private static final Map<Integer, ODeltaDocumentFieldType> mappedIds = new HashMap<>();

static {
for (ODeltaDocumentFieldType type : values()) {
mappedIds.put(type.id, type);
}
}

ODeltaDocumentFieldType(int id) {
this.id = id;
}

@Override
public int getId() {
return id;
}

protected static OTypeInterface getFromClass(Class claz) {
if (claz == null) {
return null;
}

if (claz.equals(ODocumentDelta.class)) {
return DELTA_RECORD;
}

OType type = OType.getTypeByClass(claz);
return type;
}

public static OTypeInterface getFromId(int id) {
if (mappedIds.containsKey(id)) {
return mappedIds.get(id);
}

OType baseType = OType.getById((byte) id);
return baseType;
}

public static OTypeInterface getTypeByValue(Object value) {
if (value == null) {
return null;
}

if (value instanceof ODocumentDelta) {
return DELTA_RECORD;
}

OType type = OType.getTypeByValue(value);
return type;
}

@Override
public boolean isList() {
return false;
}
}

0 comments on commit 16b73cd

Please sign in to comment.