Skip to content

Commit

Permalink
Fixed issue #3339
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Jan 6, 2015
1 parent 7363835 commit f38f31e
Showing 1 changed file with 37 additions and 38 deletions.
@@ -1,8 +1,5 @@
package com.orientechnologies.orient.core.metadata.schema; package com.orientechnologies.orient.core.metadata.schema;


import java.io.IOException;
import java.util.*;

import com.orientechnologies.common.listener.OProgressListener; import com.orientechnologies.common.listener.OProgressListener;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
Expand All @@ -11,38 +8,44 @@
import com.orientechnologies.orient.core.metadata.schema.clusterselection.OClusterSelectionStrategy; import com.orientechnologies.orient.core.metadata.schema.clusterselection.OClusterSelectionStrategy;
import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.record.impl.ODocument;


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/** /**
* @author Andrey Lomakin (a.lomakin-at-orientechnologies.com) * @author Andrey Lomakin (a.lomakin-at-orientechnologies.com)
* @since 10/21/14 * @since 10/21/14
*/ */
public class OImmutableClass implements OClass { public class OImmutableClass implements OClass {
private final boolean isAbstract; private final boolean isAbstract;
private final boolean strictMode; private final boolean strictMode;


private final String superClassName; private final String superClassName;
private final String name;
private final String streamAbleName;
private final Map<String, OProperty> properties;
private final Class<?> javaClass;
private final OClusterSelectionStrategy clusterSelection;
private final int defaultClusterId;
private final int[] clusterIds;
private final int[] polymorphicClusterIds;
private final Collection<String> baseClassesNames;
private final float overSize;
private final float classOverSize;
private final String shortName;
private final Map<String, String> customFields;
private final OImmutableSchema schema;
// do not do it volatile it is already SAFE TO USE IT in MT mode. // do not do it volatile it is already SAFE TO USE IT in MT mode.
private OImmutableClass superClass; private OImmutableClass superClass;

private final String name;
private final String streamAbleName;
private final Map<String, OProperty> properties;

private final Class<?> javaClass;
private final OClusterSelectionStrategy clusterSelection;
private final int defaultClusterId;
private final int[] clusterIds;
private final int[] polymorphicClusterIds;

private final Collection<String> baseClassesNames;
// do not do it volatile it is already SAFE TO USE IT in MT mode. // do not do it volatile it is already SAFE TO USE IT in MT mode.
private Collection<OImmutableClass> baseClasses; private Collection<OImmutableClass> baseClasses;

private final float overSize;
private final float classOverSize;

private final String shortName;
private final Map<String, String> customFields;
private final OImmutableSchema schema;


public OImmutableClass(OClass oClass, OImmutableSchema schema) { public OImmutableClass(OClass oClass, OImmutableSchema schema) {
isAbstract = oClass.isAbstract(); isAbstract = oClass.isAbstract();
Expand Down Expand Up @@ -71,9 +74,8 @@ public OImmutableClass(OClass oClass, OImmutableSchema schema) {
javaClass = oClass.getJavaClass(); javaClass = oClass.getJavaClass();


properties = new HashMap<String, OProperty>(); properties = new HashMap<String, OProperty>();
Map<String, OProperty> propertyMap = oClass.propertiesMap(); for (OProperty p : oClass.declaredProperties())
for (Map.Entry<String, OProperty> propertyEntry : propertyMap.entrySet()) properties.put(p.getName().toLowerCase(), new OImmutableProperty(p));
properties.put(propertyEntry.getKey().toLowerCase(), new OImmutableProperty(propertyEntry.getValue()));


customFields = new HashMap<String, String>(); customFields = new HashMap<String, String>();
for (String key : oClass.getCustomKeys()) for (String key : oClass.getCustomKeys())
Expand Down Expand Up @@ -198,8 +200,7 @@ public Collection<OProperty> getIndexedProperties() {


} while (currentClass != null); } while (currentClass != null);


return (Collection<OProperty>) (indexedProps != null ? Collections.unmodifiableCollection(indexedProps) : Collections return (Collection<OProperty>) (indexedProps != null ? Collections.unmodifiableCollection(indexedProps) : Collections.emptyList());
.emptyList());
} }


@Override @Override
Expand Down Expand Up @@ -481,14 +482,12 @@ public OIndex<?> createIndex(String iName, INDEX_TYPE iType, OProgressListener i
} }


@Override @Override
public OIndex<?> createIndex(String iName, String iType, OProgressListener iProgressListener, ODocument metadata, public OIndex<?> createIndex(String iName, String iType, OProgressListener iProgressListener, ODocument metadata, String algorithm, String... fields) {
String algorithm, String... fields) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }


@Override @Override
public OIndex<?> createIndex(String iName, String iType, OProgressListener iProgressListener, ODocument metadata, public OIndex<?> createIndex(String iName, String iType, OProgressListener iProgressListener, ODocument metadata, String... fields) {
String... fields) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }


Expand Down Expand Up @@ -620,7 +619,7 @@ public Set<String> getCustomKeys() {


@Override @Override
public boolean hasClusterId(int clusterId) { public boolean hasClusterId(int clusterId) {
return Arrays.binarySearch(clusterIds, clusterId) >= 0; return Arrays.binarySearch(clusterIds, clusterId)>=0;
} }


@Override @Override
Expand Down

0 comments on commit f38f31e

Please sign in to comment.