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<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;
private String url;
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
*/
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;

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

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

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.id.ORID;
import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.index.OIndex;
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.*;
import com.orientechnologies.orient.core.index.hashindex.local.OMurmurHash3HashFunction;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.orientechnologies.orient.core.metadata.OMetadataDefault;
Expand Down Expand Up @@ -1164,11 +1160,13 @@ private long importRecords() throws Exception {
long total = 0;

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

exportImportHashTable = (OIndex<OIdentifiable>) database
.getMetadata()
.getIndexManager()
.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);

Expand Down
@@ -1,22 +1,22 @@
/*
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.index;

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

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

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

this.version = version;
}

public OCollate getCollate() {
return collate;
}
Expand Down Expand Up @@ -90,4 +97,19 @@ public boolean isNullValuesIgnored() {
public void setNullValuesIgnored(boolean 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)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.index;

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

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

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
* - 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);
className = iClassName;
}
Expand All @@ -69,7 +71,9 @@ public OCompositeIndexDefinition(final String iClassName) {
* @param iIndexes
* 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);
for (OIndexDefinition indexDefinition : iIndexes) {
indexDefinitions.add(indexDefinition);
Expand Down Expand Up @@ -355,27 +359,34 @@ public String toString() {
@Override
public ODocument toStream() {
document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);
final List<ODocument> inds = new ArrayList<ODocument>(indexDefinitions.size());
final List<String> indClasses = new ArrayList<String>(indexDefinitions.size());

try {
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());
serializeToStream();
} finally {
document.setInternalStatus(ORecordElement.STATUS.LOADED);
}

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}
*/
Expand Down Expand Up @@ -412,6 +423,13 @@ public String toCreateIndexDDL(final String indexName, final String indexType) {
*/
@Override
protected void fromStream() {
serializeFromStream();
}

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

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

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

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

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 {
// @COMPATIBILITY 1.0rc6 new index model was implemented
final Boolean isAutomatic = config.field(OIndexInternal.CONFIG_AUTOMATIC);
OIndexFactory factory = OIndexes.getFactory(type, algorithm);
if (Boolean.TRUE.equals(isAutomatic)) {
final int pos = indexName.lastIndexOf('.');
if (pos < 0)
Expand All @@ -144,15 +145,16 @@ public static IndexMetadata loadMetadataInternal(final ODocument config, final S
if (keyTypeStr == null)
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));
loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType);

loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType, factory.getLastVersion());

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

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

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

indexDefinition = new OSimpleKeyIndexDefinition(type);
indexDefinition = new OSimpleKeyIndexDefinition(indexEngine.getVersion(), type);
updateConfiguration();
}
}
Expand Down
@@ -1,22 +1,22 @@
/*
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
*
* * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * 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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.index;

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

void setNullValuesIgnored(boolean value);

int getVersion();
}

0 comments on commit c8a2e89

Please sign in to comment.