Skip to content

Commit

Permalink
Merge branch '2.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank committed May 25, 2016
2 parents e822a75 + 0fa4149 commit 5d4ff94
Show file tree
Hide file tree
Showing 44 changed files with 509 additions and 277 deletions.
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>2.1.17</version>
<version>2.1.18</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-parent</artifactId>
<version>2.1.17</version>
<version>2.1.18</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package com.orientechnologies.orient.core;

public class OConstants {
public static final String ORIENT_VERSION = "2.1.17";
public static final String ORIENT_VERSION = "2.1.18";

public static final String ORIENT_URL = "www.orientdb.com";
public static final String COPYRIGHT = "Copyrights (c) 2016 OrientDB LTD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ public void change(Object currentValue, Object newValue) {
DISK_WRITE_CACHE_FLUSH_LOCK_TIMEOUT("storage.diskCache.writeCacheFlushLockTimeout",
"Maximum amount of time till write cache will be wait before page flush in ms.", Integer.class, -1),

DISK_CACHE_FREE_SPACE_LIMIT("storage.diskCache.diskFreeSpaceLimit",
"Minimum amount of space on disk after which database will " + "work only in read mode, in megabytes", Long.class, 100),

@Deprecated

DISC_CACHE_FREE_SPACE_CHECK_INTERVAL("storage.diskCache.diskFreeSpaceCheckInterval",
"The interval (in seconds), after which the storage periodically "
+ "checks whether the amount of free disk space is enough to work in write mode", Integer.class, 5),
Expand All @@ -141,7 +137,7 @@ public void change(Object currentValue, Object newValue) {
*/
DISC_CACHE_FREE_SPACE_CHECK_INTERVAL_IN_PAGES("storage.diskCache.diskFreeSpaceCheckIntervalInPages",
"The interval (how many new pages should be added before free space will be checked), after which the storage periodically "
+ "checks whether the amount of free disk space is enough to work in write mode", Integer.class, 4096),
+ "checks whether the amount of free disk space is enough to work in write mode", Integer.class, 2048),

/**
* Keep disk cache state between moment when storage is closed and moment when it is opened again.
Expand Down Expand Up @@ -209,6 +205,9 @@ public void change(Object currentValue, Object newValue) {
DISK_CACHE_PAGE_SIZE("storage.diskCache.pageSize", "Size of page of disk buffer in kilobytes,!!! NEVER CHANGE THIS VALUE !!!",
Integer.class, 64),

DISK_CACHE_FREE_SPACE_LIMIT("storage.diskCache.diskFreeSpaceLimit", "Minimum amount of space on disk, which, when exceeded, "
+ "will cause the database to switch to read-only mode (in megabytes)", Long.class, 2 * WAL_MAX_SEGMENT_SIZE.getValueAsLong()),

PAGINATED_STORAGE_LOWEST_FREELIST_BOUNDARY("storage.lowestFreeListBound",
"The minimal amount of free space (in kb)" + " in page which is tracked in paginated storage", Integer.class, 16),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ public void setPreserveRids(boolean preserveRids) {

protected void parseSetting(final String option, final List<String> items) {
if (option.equalsIgnoreCase("-excludeAll")) {
includeClasses = new HashSet<String>();
excludeClasses = null;
includeClusters = new HashSet<String>();
excludeClusters = null;
includeInfo = false;
includeClusterDefinitions = false;
includeSchema = false;
Expand Down Expand Up @@ -262,7 +258,10 @@ protected void parseSetting(final String option, final List<String> items) {

} else if (option.equalsIgnoreCase("-includeSchema")) {
includeSchema = Boolean.parseBoolean(items.get(0));

if (includeSchema) {
includeClusterDefinitions = true;
includeInfo = true;
}
} else if (option.equalsIgnoreCase("-includeSecurity")) {
includeSecurity = Boolean.parseBoolean(items.get(0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,8 @@
import com.orientechnologies.orient.core.config.OStorageConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.*;
import com.orientechnologies.orient.core.db.record.ORecordElement.STATUS;
import com.orientechnologies.orient.core.db.record.ORecordLazyList;
import com.orientechnologies.orient.core.db.record.ORecordLazyMap;
import com.orientechnologies.orient.core.db.record.ORecordLazyMultiValue;
import com.orientechnologies.orient.core.db.record.ORecordLazySet;
import com.orientechnologies.orient.core.db.record.ORecordTrackedList;
import com.orientechnologies.orient.core.db.record.ORecordTrackedSet;
import com.orientechnologies.orient.core.db.record.OTrackedList;
import com.orientechnologies.orient.core.db.record.OTrackedMap;
import com.orientechnologies.orient.core.db.record.OTrackedSet;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
import com.orientechnologies.orient.core.exception.OQueryParsingException;
import com.orientechnologies.orient.core.id.ORID;
Expand All @@ -57,17 +48,8 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;

/**
* Helper class to manage documents.
Expand Down Expand Up @@ -274,7 +256,7 @@ public static <RET> RET getFieldValue(Object value, final String iFieldName, fin
else if (value instanceof Map<?, ?>)
value = getMapEntry((Map<String, ?>) value, fieldName);
else if (OMultiValue.isMultiValue(value)) {
final HashSet<Object> temp = new HashSet<Object>();
final HashSet<Object> temp = new LinkedHashSet<Object>();
for (Object o : OMultiValue.getMultiValueIterable(value)) {
if (o instanceof OIdentifiable) {
Object r = getFieldValue(o, iFieldName);
Expand Down Expand Up @@ -468,7 +450,7 @@ else if (Character.isDigit(indexAsString.charAt(0)))
} else {
// CONDITION
OSQLPredicate pred = new OSQLPredicate(indexAsString);
final HashSet<Object> values = new HashSet<Object>();
final HashSet<Object> values = new LinkedHashSet<Object>();

for (Object v : OMultiValue.getMultiValueIterable(value)) {
if (v instanceof OIdentifiable) {
Expand Down Expand Up @@ -532,7 +514,7 @@ else if (fieldName.contains("(")) {
} else if (value instanceof Map<?, ?>)
value = getMapEntry((Map<String, ?>) value, fieldName);
else if (OMultiValue.isMultiValue(value)) {
final Set<Object> values = new HashSet<Object>();
final Set<Object> values = new LinkedHashSet<Object>();
for (Object v : OMultiValue.getMultiValueIterable(value)) {
final Object item;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ORecordElement;
import com.orientechnologies.orient.core.db.record.ORecordLazyList;
import com.orientechnologies.orient.core.db.record.ORecordLazyMap;
import com.orientechnologies.orient.core.db.record.ORecordLazyMultiValue;
Expand All @@ -59,6 +60,7 @@
import com.orientechnologies.orient.core.serialization.OSerializableStream;
import com.orientechnologies.orient.core.serialization.serializer.ONetworkThreadLocalSerializer;
import com.orientechnologies.orient.core.storage.OStorageProxy;
import com.orientechnologies.orient.core.storage.impl.local.paginated.ORecordSerializationContext;
import com.orientechnologies.orient.core.type.tree.OMVRBTreeRIDSet;
import com.orientechnologies.orient.core.util.ODateHelper;

Expand Down Expand Up @@ -403,54 +405,69 @@ private byte[] readBinary(BytesContainer bytes) {

private Map<Object, OIdentifiable> readLinkMap(final BytesContainer bytes, final ODocument document) {
int size = OVarIntSerializer.readAsInteger(bytes);
Map<Object, OIdentifiable> result = new ORecordLazyMap(document);
while ((size--) > 0) {
OType keyType = readOType(bytes);
Object key = readSingleValue(bytes, keyType, document);
ORecordId value = readOptimizedLink(bytes);
if (value.equals(NULL_RECORD_ID))
result.put(key, null);
else
result.put(key, value);
ORecordLazyMap result = new ORecordLazyMap(document);
result.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
try {
while ((size--) > 0) {
OType keyType = readOType(bytes);
Object key = readSingleValue(bytes, keyType, document);
ORecordId value = readOptimizedLink(bytes);
if (value.equals(NULL_RECORD_ID))
result.put(key, null);
else
result.put(key, value);
}
return result;
} finally {
result.setInternalStatus(ORecordElement.STATUS.LOADED);
}
return result;
}

private Object readEmbeddedMap(final BytesContainer bytes, final ODocument document) {
int size = OVarIntSerializer.readAsInteger(bytes);
final Map<Object, Object> result = new OTrackedMap<Object>(document);
int last = 0;
while ((size--) > 0) {
OType keyType = readOType(bytes);
Object key = readSingleValue(bytes, keyType, document);
final int valuePos = readInteger(bytes);
final OType type = readOType(bytes);
if (valuePos != 0) {
int headerCursor = bytes.offset;
bytes.offset = valuePos;
Object value = readSingleValue(bytes, type, document);
if (bytes.offset > last)
last = bytes.offset;
bytes.offset = headerCursor;
result.put(key, value);
} else
result.put(key, null);
final OTrackedMap<Object> result = new OTrackedMap<Object>(document);
result.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
try {
int last = 0;
while ((size--) > 0) {
OType keyType = readOType(bytes);
Object key = readSingleValue(bytes, keyType, document);
final int valuePos = readInteger(bytes);
final OType type = readOType(bytes);
if (valuePos != 0) {
int headerCursor = bytes.offset;
bytes.offset = valuePos;
Object value = readSingleValue(bytes, type, document);
if (bytes.offset > last)
last = bytes.offset;
bytes.offset = headerCursor;
result.put(key, value);
} else
result.put(key, null);
}
if (last > bytes.offset)
bytes.offset = last;
return result;
} finally {
result.setInternalStatus(ORecordElement.STATUS.LOADED);
}
if (last > bytes.offset)
bytes.offset = last;
return result;
}

private Collection<OIdentifiable> readLinkCollection(BytesContainer bytes, Collection<OIdentifiable> found) {
final int items = OVarIntSerializer.readAsInteger(bytes);
for (int i = 0; i < items; i++) {
ORecordId id = readOptimizedLink(bytes);
if (id.equals(NULL_RECORD_ID))
found.add(null);
else
found.add(id);
((ORecordElement)found).setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
try {
final int items = OVarIntSerializer.readAsInteger(bytes);
for (int i = 0; i < items; i++) {
ORecordId id = readOptimizedLink(bytes);
if (id.equals(NULL_RECORD_ID))
found.add(null);
else
found.add(id);
}
return found;
} finally {
((ORecordElement)found).setInternalStatus(ORecordElement.STATUS.LOADED);
}
return found;
}

private ORecordId readOptimizedLink(final BytesContainer bytes) {
Expand All @@ -462,14 +479,19 @@ private Collection<?> readEmbeddedCollection(final BytesContainer bytes, final C
OType type = readOType(bytes);

if (type == OType.ANY) {
for (int i = 0; i < items; i++) {
OType itemType = readOType(bytes);
if (itemType == OType.ANY)
found.add(null);
else
found.add(readSingleValue(bytes, itemType, document));
((ORecordElement)found).setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
try {
for (int i = 0; i < items; i++) {
OType itemType = readOType(bytes);
if (itemType == OType.ANY)
found.add(null);
else
found.add(readSingleValue(bytes, itemType, document));
}
return found;
} finally {
((ORecordElement)found).setInternalStatus(ORecordElement.STATUS.LOADED);
}
return found;
}
// TODO: manage case where type is known
return null;
Expand Down Expand Up @@ -684,7 +706,8 @@ private int writeNullLink(BytesContainer bytes) {

private int writeOptimizedLink(BytesContainer bytes, OIdentifiable link) {
link = recursiveLinkSave(link);
assert link.getIdentity().isValid() || (ODatabaseRecordThreadLocal.INSTANCE.get().getStorage() instanceof OStorageProxy) : "Impossible to serialize invalid link";
assert link.getIdentity().getClusterId() >= 0
|| ORecordSerializationContext.getContext() == null : "Impossible to serialize invalid link";
int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId());
OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition());
return pos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,24 @@ else if (word.equalsIgnoreCase(KEYWORD_WHERE))
} else if (subjectName.startsWith("(")) {
subjectName = subjectName.trim();
query = database.command(new OSQLAsynchQuery<ODocument>(subjectName.substring(1, subjectName.length() - 1), this));
parserNextWord(true);
if (!parserIsEnded()) {
while (!parserIsEnded()) {
final String word = parserGetLastWord();

if (word.equals(KEYWORD_LOCK))
lockStrategy = parseLock();
else if (word.equals(KEYWORD_RETURN))
returning = parseReturn();
else if (word.equals(KEYWORD_UNSAFE))
unsafe = true;
else if (word.equalsIgnoreCase(KEYWORD_WHERE))
compiledFilter = OSQLEngine.getInstance()
.parseCondition(parserText.substring(parserGetCurrentPosition()), getContext(), KEYWORD_WHERE);

parserNextWord(true);
}
}
} else {
parserNextWord(true);

Expand Down Expand Up @@ -278,6 +295,9 @@ public long getDistributedTimeout() {
public boolean result(final Object iRecord) {
final ORecordAbstract record = ((OIdentifiable) iRecord).getRecord();

if(record instanceof ODocument && compiledFilter!=null && !Boolean.TRUE.equals(this.compiledFilter.evaluate(record, (ODocument)record, getContext()))){
return true;
}
try {
if (record.getIdentity().isValid()) {
if (returning.equalsIgnoreCase("BEFORE"))
Expand Down

0 comments on commit 5d4ff94

Please sign in to comment.