Skip to content

Commit

Permalink
OOM in remote client and FileNotFoundException in hash index were fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
laa committed Apr 16, 2015
1 parent c0b08dc commit c8a2e89
Show file tree
Hide file tree
Showing 50 changed files with 3,597 additions and 1,408 deletions.
Expand Up @@ -131,7 +131,8 @@ public class ODatabaseDocumentTx extends OListenerManger<ODatabaseListener> impl
} }
private final Map<String, Object> properties = new HashMap<String, Object>(); private final Map<String, Object> properties = new HashMap<String, Object>();
private final Map<ORecordHook, ORecordHook.HOOK_POSITION> unmodifiableHooks; private final Map<ORecordHook, ORecordHook.HOOK_POSITION> unmodifiableHooks;
private final Set<OIdentifiable> inHook = new HashSet<OIdentifiable>(); private final Set<OIdentifiable> inHook = Collections
.newSetFromMap(new IdentityHashMap<OIdentifiable, Boolean>());
protected ORecordSerializer serializer; protected ORecordSerializer serializer;
private String url; private String url;
private OStorage storage; private OStorage storage;
Expand Down Expand Up @@ -964,7 +965,7 @@ public Map<ORecordHook, ORecordHook.HOOK_POSITION> getHooks() {
* @return True if the input record is changed, otherwise false * @return True if the input record is changed, otherwise false
*/ */
public ORecordHook.RESULT callbackHooks(final ORecordHook.TYPE type, final OIdentifiable id) { public ORecordHook.RESULT callbackHooks(final ORecordHook.TYPE type, final OIdentifiable id) {
if (id == null || !pushInHook(id) || hooks.isEmpty()) if (id == null || hooks.isEmpty() || !pushInHook(id))
return ORecordHook.RESULT.RECORD_NOT_CHANGED; return ORecordHook.RESULT.RECORD_NOT_CHANGED;


try { try {
Expand Down Expand Up @@ -2644,11 +2645,7 @@ private void popInHook(OIdentifiable id) {
} }


private boolean pushInHook(OIdentifiable id) { private boolean pushInHook(OIdentifiable id) {
if (!inHook.contains(id)) { return inHook.add(id);
inHook.add(id);
return true;
}
return false;
} }


private void initAtFirstOpen(String iUserName, String iUserPassword) { private void initAtFirstOpen(String iUserName, String iUserPassword) {
Expand Down
Expand Up @@ -54,11 +54,7 @@
import com.orientechnologies.orient.core.exception.OConfigurationException; import com.orientechnologies.orient.core.exception.OConfigurationException;
import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.id.ORecordId; import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.index.OIndex; import com.orientechnologies.orient.core.index.*;
import com.orientechnologies.orient.core.index.OIndexDefinition;
import com.orientechnologies.orient.core.index.OIndexManagerProxy;
import com.orientechnologies.orient.core.index.ORuntimeKeyIndexDefinition;
import com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition;
import com.orientechnologies.orient.core.index.hashindex.local.OMurmurHash3HashFunction; import com.orientechnologies.orient.core.index.hashindex.local.OMurmurHash3HashFunction;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert; import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.orientechnologies.orient.core.metadata.OMetadataDefault; import com.orientechnologies.orient.core.metadata.OMetadataDefault;
Expand Down Expand Up @@ -1164,11 +1160,13 @@ private long importRecords() throws Exception {
long total = 0; long total = 0;


database.getMetadata().getIndexManager().dropIndex(EXPORT_IMPORT_MAP_NAME); database.getMetadata().getIndexManager().dropIndex(EXPORT_IMPORT_MAP_NAME);
OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.toString(), null);

exportImportHashTable = (OIndex<OIdentifiable>) database exportImportHashTable = (OIndex<OIdentifiable>) database
.getMetadata() .getMetadata()
.getIndexManager() .getIndexManager()
.createIndex(EXPORT_IMPORT_MAP_NAME, OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.toString(), .createIndex(EXPORT_IMPORT_MAP_NAME, OClass.INDEX_TYPE.DICTIONARY_HASH_INDEX.toString(),
new OSimpleKeyIndexDefinition(OType.LINK), null, null, null); new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK), null, null, null);


jsonReader.readNext(OJSONReader.BEGIN_COLLECTION); jsonReader.readNext(OJSONReader.BEGIN_COLLECTION);


Expand Down
@@ -1,22 +1,22 @@
/* /*
* *
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com) * * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* * * *
* * Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License. * * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at * * You may obtain a copy of the License at
* * * *
* * http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0
* * * *
* * Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and * * See the License for the specific language governing permissions and
* * limitations under the License. * * limitations under the License.
* * * *
* * For more information: http://www.orientechnologies.com * * For more information: http://www.orientechnologies.com
* *
*/ */
package com.orientechnologies.orient.core.index; package com.orientechnologies.orient.core.index;


import com.orientechnologies.orient.core.collate.OCollate; import com.orientechnologies.orient.core.collate.OCollate;
Expand All @@ -34,11 +34,18 @@
public abstract class OAbstractIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition { public abstract class OAbstractIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition {
protected OCollate collate = new ODefaultCollate(); protected OCollate collate = new ODefaultCollate();
private boolean nullValuesIgnored = true; private boolean nullValuesIgnored = true;
private int version = -1;


protected OAbstractIndexDefinition() { protected OAbstractIndexDefinition() {
super(new ODocument()); super(new ODocument());
} }


public OAbstractIndexDefinition(int version) {
super(new ODocument());

this.version = version;
}

public OCollate getCollate() { public OCollate getCollate() {
return collate; return collate;
} }
Expand Down Expand Up @@ -90,4 +97,19 @@ public boolean isNullValuesIgnored() {
public void setNullValuesIgnored(boolean value) { public void setNullValuesIgnored(boolean value) {
nullValuesIgnored = value; nullValuesIgnored = value;
} }

@Override
public int getVersion() {
return version;
}

protected void serializeToStream() {
document.field("version", version);
}

protected void serializeFromStream() {
final Integer ver = document.field("version");
if (ver != null)
version = ver;
}
} }
@@ -1,22 +1,22 @@
/* /*
* *
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com) * * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* * * *
* * Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License. * * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at * * You may obtain a copy of the License at
* * * *
* * http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0
* * * *
* * Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and * * See the License for the specific language governing permissions and
* * limitations under the License. * * limitations under the License.
* * * *
* * For more information: http://www.orientechnologies.com * * For more information: http://www.orientechnologies.com
* *
*/ */
package com.orientechnologies.orient.core.index; package com.orientechnologies.orient.core.index;


import java.util.Map; import java.util.Map;
Expand All @@ -30,8 +30,8 @@ public abstract class OAbstractIndexDefinitionMultiValue extends OPropertyIndexD
protected OAbstractIndexDefinitionMultiValue() { protected OAbstractIndexDefinitionMultiValue() {
} }


protected OAbstractIndexDefinitionMultiValue(final String iClassName, final String iField, final OType iType) { protected OAbstractIndexDefinitionMultiValue(final String iClassName, final String iField, final OType iType, int version) {
super(iClassName, iField, iType); super(iClassName, iField, iType, version);
} }


protected void processAdd(final Object value, final Map<Object, Integer> keysToAdd, final Map<Object, Integer> keysToRemove) { protected void processAdd(final Object value, final Map<Object, Integer> keysToAdd, final Map<Object, Integer> keysToRemove) {
Expand Down
Expand Up @@ -56,7 +56,9 @@ public OCompositeIndexDefinition() {
* @param iClassName * @param iClassName
* - name of class which is owner of this index * - name of class which is owner of this index
*/ */
public OCompositeIndexDefinition(final String iClassName) { public OCompositeIndexDefinition(final String iClassName, int version) {
super(version);

indexDefinitions = new ArrayList<OIndexDefinition>(5); indexDefinitions = new ArrayList<OIndexDefinition>(5);
className = iClassName; className = iClassName;
} }
Expand All @@ -69,7 +71,9 @@ public OCompositeIndexDefinition(final String iClassName) {
* @param iIndexes * @param iIndexes
* List of indexDefinitions to add in given index. * List of indexDefinitions to add in given index.
*/ */
public OCompositeIndexDefinition(final String iClassName, final List<? extends OIndexDefinition> iIndexes) { public OCompositeIndexDefinition(final String iClassName, final List<? extends OIndexDefinition> iIndexes, int version) {
super(version);

indexDefinitions = new ArrayList<OIndexDefinition>(5); indexDefinitions = new ArrayList<OIndexDefinition>(5);
for (OIndexDefinition indexDefinition : iIndexes) { for (OIndexDefinition indexDefinition : iIndexes) {
indexDefinitions.add(indexDefinition); indexDefinitions.add(indexDefinition);
Expand Down Expand Up @@ -355,27 +359,34 @@ public String toString() {
@Override @Override
public ODocument toStream() { public ODocument toStream() {
document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING); document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
final List<ODocument> inds = new ArrayList<ODocument>(indexDefinitions.size());
final List<String> indClasses = new ArrayList<String>(indexDefinitions.size());

try { try {
document.field("className", className); serializeToStream();
for (final OIndexDefinition indexDefinition : indexDefinitions) {
final ODocument indexDocument = indexDefinition.toStream();
inds.add(indexDocument);

indClasses.add(indexDefinition.getClass().getName());
}
document.field("indexDefinitions", inds, OType.EMBEDDEDLIST);
document.field("indClasses", indClasses, OType.EMBEDDEDLIST);
document.field("nullValuesIgnored", isNullValuesIgnored());
} finally { } finally {
document.setInternalStatus(ORecordElement.STATUS.LOADED); document.setInternalStatus(ORecordElement.STATUS.LOADED);
} }


return document; return document;
} }


@Override
protected void serializeToStream() {
super.serializeToStream();

final List<ODocument> inds = new ArrayList<ODocument>(indexDefinitions.size());
final List<String> indClasses = new ArrayList<String>(indexDefinitions.size());

document.field("className", className);
for (final OIndexDefinition indexDefinition : indexDefinitions) {
final ODocument indexDocument = indexDefinition.toStream();
inds.add(indexDocument);

indClasses.add(indexDefinition.getClass().getName());
}
document.field("indexDefinitions", inds, OType.EMBEDDEDLIST);
document.field("indClasses", indClasses, OType.EMBEDDEDLIST);
document.field("nullValuesIgnored", isNullValuesIgnored());
}

/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
Expand Down Expand Up @@ -412,6 +423,13 @@ public String toCreateIndexDDL(final String indexName, final String indexType) {
*/ */
@Override @Override
protected void fromStream() { protected void fromStream() {
serializeFromStream();
}

@Override
protected void serializeFromStream() {
super.serializeFromStream();

try { try {
className = document.field("className"); className = document.field("className");


Expand Down
Expand Up @@ -121,19 +121,24 @@ private OIndexInternal<?> createSBTreeIndex(String indexType, String valueContai
durableInNonTxMode = null; durableInNonTxMode = null;


if (OClass.INDEX_TYPE.UNIQUE.toString().equals(indexType)) { if (OClass.INDEX_TYPE.UNIQUE.toString().equals(indexType)) {
return new OIndexUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<OIdentifiable>(durableInNonTxMode, storage), return new OIndexUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<OIdentifiable>(durableInNonTxMode, storage,
valueContainerAlgorithm, metadata); getLastVersion()), valueContainerAlgorithm, metadata);
} else if (OClass.INDEX_TYPE.NOTUNIQUE.toString().equals(indexType)) { } else if (OClass.INDEX_TYPE.NOTUNIQUE.toString().equals(indexType)) {
return new OIndexNotUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<Set<OIdentifiable>>(durableInNonTxMode, return new OIndexNotUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<Set<OIdentifiable>>(durableInNonTxMode,
storage), valueContainerAlgorithm, metadata); storage, getLastVersion()), valueContainerAlgorithm, metadata);
} else if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) { } else if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) {
return new OIndexFullText(indexType, SBTREE_ALGORITHM, return new OIndexFullText(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<Set<OIdentifiable>>(durableInNonTxMode,
new OSBTreeIndexEngine<Set<OIdentifiable>>(durableInNonTxMode, storage), valueContainerAlgorithm, metadata); storage, getLastVersion()), valueContainerAlgorithm, metadata);
} else if (OClass.INDEX_TYPE.DICTIONARY.toString().equals(indexType)) { } else if (OClass.INDEX_TYPE.DICTIONARY.toString().equals(indexType)) {
return new OIndexDictionary(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<OIdentifiable>(durableInNonTxMode, storage), return new OIndexDictionary(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine<OIdentifiable>(durableInNonTxMode, storage,
valueContainerAlgorithm, metadata); getLastVersion()), valueContainerAlgorithm, metadata);
} }


throw new OConfigurationException("Unsupported type : " + indexType); throw new OConfigurationException("Unsupported type : " + indexType);
} }

@Override
public int getLastVersion() {
return OSBTreeIndexEngine.VERSION;
}
} }
Expand Up @@ -132,6 +132,7 @@ public static IndexMetadata loadMetadataInternal(final ODocument config, final S
} else { } else {
// @COMPATIBILITY 1.0rc6 new index model was implemented // @COMPATIBILITY 1.0rc6 new index model was implemented
final Boolean isAutomatic = config.field(OIndexInternal.CONFIG_AUTOMATIC); final Boolean isAutomatic = config.field(OIndexInternal.CONFIG_AUTOMATIC);
OIndexFactory factory = OIndexes.getFactory(type, algorithm);
if (Boolean.TRUE.equals(isAutomatic)) { if (Boolean.TRUE.equals(isAutomatic)) {
final int pos = indexName.lastIndexOf('.'); final int pos = indexName.lastIndexOf('.');
if (pos < 0) if (pos < 0)
Expand All @@ -144,15 +145,16 @@ public static IndexMetadata loadMetadataInternal(final ODocument config, final S
if (keyTypeStr == null) if (keyTypeStr == null)
throw new OIndexException("Can not convert from old index model to new one. " + "Index key type is absent."); throw new OIndexException("Can not convert from old index model to new one. " + "Index key type is absent.");
final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH)); final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH));
loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType);
loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType, factory.getLastVersion());


config.removeField(OIndexInternal.CONFIG_AUTOMATIC); config.removeField(OIndexInternal.CONFIG_AUTOMATIC);
config.removeField(OIndexInternal.CONFIG_KEYTYPE); config.removeField(OIndexInternal.CONFIG_KEYTYPE);
} else if (config.field(OIndexInternal.CONFIG_KEYTYPE) != null) { } else if (config.field(OIndexInternal.CONFIG_KEYTYPE) != null) {
final String keyTypeStr = config.field(OIndexInternal.CONFIG_KEYTYPE); final String keyTypeStr = config.field(OIndexInternal.CONFIG_KEYTYPE);
final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH)); final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH));


loadedIndexDefinition = new OSimpleKeyIndexDefinition(keyType); loadedIndexDefinition = new OSimpleKeyIndexDefinition(factory.getLastVersion(), keyType);


config.removeField(OIndexInternal.CONFIG_KEYTYPE); config.removeField(OIndexInternal.CONFIG_KEYTYPE);
} }
Expand Down Expand Up @@ -839,7 +841,7 @@ protected void checkForKeyType(final Object iKey) {
if (type == null) if (type == null)
return; return;


indexDefinition = new OSimpleKeyIndexDefinition(type); indexDefinition = new OSimpleKeyIndexDefinition(indexEngine.getVersion(), type);
updateConfiguration(); updateConfiguration();
} }
} }
Expand Down
@@ -1,22 +1,22 @@
/* /*
* *
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com) * * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* * * *
* * Licensed under the Apache License, Version 2.0 (the "License"); * * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License. * * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at * * You may obtain a copy of the License at
* * * *
* * http://www.apache.org/licenses/LICENSE-2.0 * * http://www.apache.org/licenses/LICENSE-2.0
* * * *
* * Unless required by applicable law or agreed to in writing, software * * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, * * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and * * See the License for the specific language governing permissions and
* * limitations under the License. * * limitations under the License.
* * * *
* * For more information: http://www.orientechnologies.com * * For more information: http://www.orientechnologies.com
* *
*/ */
package com.orientechnologies.orient.core.index; package com.orientechnologies.orient.core.index;


import java.util.List; import java.util.List;
Expand Down Expand Up @@ -133,4 +133,6 @@ public interface OIndexDefinition extends OIndexCallback {
boolean isNullValuesIgnored(); boolean isNullValuesIgnored();


void setNullValuesIgnored(boolean value); void setNullValuesIgnored(boolean value);

int getVersion();
} }

0 comments on commit c8a2e89

Please sign in to comment.