ignite-950: preparing for handover
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/76309bb8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/76309bb8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/76309bb8 Branch: refs/heads/ignite-950 Commit: 76309bb8cb50b05296d242104f0a92068b105ef9 Parents: 8929cb4 Author: Denis Magda <dma...@gridgain.com> Authored: Wed Jul 1 08:24:04 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Wed Jul 1 08:24:04 2015 +0300 ---------------------------------------------------------------------- .../cache/CacheIndexedObjectImpl.java | 26 +---- .../cacheobject/IgniteCacheObjectProcessor.java | 8 +- .../IgniteCacheObjectProcessorImpl.java | 27 ++--- .../processors/query/GridQueryProcessor.java | 105 +++++-------------- 4 files changed, 43 insertions(+), 123 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76309bb8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIndexedObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIndexedObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIndexedObjectImpl.java index 66631ec..8993039 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIndexedObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIndexedObjectImpl.java @@ -165,21 +165,10 @@ public class CacheIndexedObjectImpl extends CacheObjectAdapter { * * @param fieldName Field name. * @param marsh Marshaller. - * @param field Field instance to get access through reflection. * @return {@code true} if has. * @throws IgniteCheckedException In case of error. */ - public boolean hasField(String fieldName, OptimizedMarshaller marsh, Field field) throws IgniteCheckedException { - if (field != null && val != null) { - try { - field.get(val); - return true; - } - catch (Exception e) { - return false; - } - } - + public boolean hasField(String fieldName, OptimizedMarshaller marsh) throws IgniteCheckedException { assert valBytes != null; return marsh.hasField(fieldName, valBytes, start, len); @@ -190,22 +179,11 @@ public class CacheIndexedObjectImpl extends CacheObjectAdapter { * * @param fieldName Field name. * @param marsh Marshaller. - * @param field Field instance to get access through reflection. * @return Field. * @throws IgniteFieldNotFoundException In case if there is no such a field. * @throws IgniteCheckedException In case of error. */ - public Object field(String fieldName, OptimizedMarshaller marsh, Field field) throws IgniteCheckedException { - if (field != null && val != null) { - try { - return field.get(val); - } - catch (Exception e) { - throw new IgniteFieldNotFoundException("Object doesn't have the field [obj=" + val + ", field=" - + fieldName + "]", e); - } - } - + public Object field(String fieldName, OptimizedMarshaller marsh) throws IgniteCheckedException { assert valBytes != null; return marsh.readField(fieldName, valBytes, start, len, val != null ? val.getClass().getClassLoader() : null); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76309bb8/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java index aa5a550..164d666 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java @@ -88,21 +88,19 @@ public interface IgniteCacheObjectProcessor extends GridProcessor { * * @param obj Object to get field from. * @param fieldName Field name. - * @param field Field instance to get access through reflection. * @throws IgniteFieldNotFoundException In case if there is no such a field. * @return Field value. */ - public Object field(Object obj, String fieldName, @Nullable Field field) throws IgniteFieldNotFoundException; + public Object field(Object obj, String fieldName) throws IgniteFieldNotFoundException; /** * Checks whether field is set in the object. Object should be an instance of {@link CacheObject}. * * @param obj Object. * @param fieldName Field name. - * @param field Field instance to get access through reflection. * @return {@code true} if field is set. */ - public boolean hasField(Object obj, String fieldName, @Nullable Field field); + public boolean hasField(Object obj, String fieldName); /** * Checks whether this functionality is globally supported. @@ -116,7 +114,7 @@ public interface IgniteCacheObjectProcessor extends GridProcessor { * Footer contains information about fields location in the serialized form, thus enabling fast queries without * a need to deserialize the object. * - * Indexing is enabled with {@link OptimizedMarshallerExt#enableFieldsIndexing(Class)}. + * Indexing is enabled with {@link OptimizedMarshallerIndexingHandler#enableFieldsIndexingForClass(Class)}. * * @param cls Class. * @return {@code true} if the footer is enabled. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76309bb8/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java index bba6966..689c4f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java @@ -340,31 +340,32 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme } /** {@inheritDoc} */ - @Override public Object field(Object obj, String fieldName, Field field) throws IgniteFieldNotFoundException { + @Override public Object field(Object obj, String fieldName) throws IgniteFieldNotFoundException { assert indexingMgr != null; - try { - return ((CacheIndexedObjectImpl)obj).field(fieldName, optMarsh, field); - } - catch (IgniteFieldNotFoundException e) { - throw e; - } - catch (IgniteCheckedException e) { - throw new IgniteException(e); + if (obj instanceof CacheIndexedObjectImpl) { + try { + return ((CacheIndexedObjectImpl)obj).field(fieldName, optMarsh); + } + catch (IgniteFieldNotFoundException e) { + throw e; + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } } - catch (ClassCastException e) { + else throw new IgniteFieldNotFoundException("Object doesn't have field [obj=" + obj + ", field=" + fieldName + "]"); - } } /** {@inheritDoc} */ - @Override public boolean hasField(Object obj, String fieldName, Field field) { + @Override public boolean hasField(Object obj, String fieldName) { if (obj instanceof CacheIndexedObjectImpl) { assert indexingMgr != null; try { - return ((CacheIndexedObjectImpl)obj).hasField(fieldName, optMarsh, null); + return ((CacheIndexedObjectImpl)obj).hasField(fieldName, optMarsh); } catch (IgniteCheckedException e) { throw new IgniteException(e); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/76309bb8/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index e00acbd..f2710b3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -141,12 +141,12 @@ public class GridQueryProcessor extends GridProcessorAdapter { TypeId typeId; if (valCls == null || ctx.cacheObjects().isPortableEnabled()) { - processCacheTypeMeta(meta, desc, PORTABLE_PROPERTY, keyCls, valCls); + processCacheTypeMeta(meta, desc, PORTABLE_PROPERTY); typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType())); } else if (ctx.cacheObjects().enableFieldsIndexing(valCls)) { - processCacheTypeMeta(meta, desc, INDEXED_FIELDS_PROPERTY, keyCls, valCls); + processCacheTypeMeta(meta, desc, INDEXED_FIELDS_PROPERTY); typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(valCls.getName())); } @@ -1239,18 +1239,16 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @param meta Declared metadata. * @param d Type descriptor. * @param propType PropertyType. - * @param keyCls Key class. - * @param valCls Value class. * @throws IgniteCheckedException If failed. */ - private void processCacheTypeMeta(CacheTypeMetadata meta, TypeDescriptor d, PropertyType propType, - @Nullable Class<?> keyCls, @Nullable Class<?> valCls) throws IgniteCheckedException { + private void processCacheTypeMeta(CacheTypeMetadata meta, TypeDescriptor d, PropertyType propType) + throws IgniteCheckedException { assert propType != CLASS_PROPERTY; for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet()) { Property prop = propType == PORTABLE_PROPERTY ? buildPortableProperty(entry.getKey(), entry.getValue()) : - buildIndexedFieldsProperty(entry.getKey(), entry.getValue(), keyCls, valCls); + buildIndexedFieldsProperty(entry.getKey(), entry.getValue()); d.addProperty(prop, false); @@ -1264,7 +1262,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { for (Map.Entry<String, Class<?>> entry : meta.getDescendingFields().entrySet()) { Property prop = propType == PORTABLE_PROPERTY ? buildPortableProperty(entry.getKey(), entry.getValue()) : - buildIndexedFieldsProperty(entry.getKey(), entry.getValue(), keyCls, valCls); + buildIndexedFieldsProperty(entry.getKey(), entry.getValue()); d.addProperty(prop, false); @@ -1278,7 +1276,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { for (String txtIdx : meta.getTextFields()) { Property prop = propType == PORTABLE_PROPERTY ? buildPortableProperty(txtIdx, String.class) : - buildIndexedFieldsProperty(txtIdx, String.class, keyCls, valCls); + buildIndexedFieldsProperty(txtIdx, String.class); d.addProperty(prop, false); @@ -1298,7 +1296,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> idxField : idxFields.entrySet()) { Property prop = propType == PORTABLE_PROPERTY ? buildPortableProperty(idxField.getKey(), idxField.getValue().get1()) : - buildIndexedFieldsProperty(idxField.getKey(), idxField.getValue().get1(), keyCls, valCls); + buildIndexedFieldsProperty(idxField.getKey(), idxField.getValue().get1()); d.addProperty(prop, false); @@ -1314,7 +1312,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet()) { Property prop = propType == PORTABLE_PROPERTY ? buildPortableProperty(entry.getKey(), entry.getValue()) : - buildIndexedFieldsProperty(entry.getKey(), entry.getValue(), keyCls, valCls); + buildIndexedFieldsProperty(entry.getKey(), entry.getValue()); if (!d.props.containsKey(prop.name())) d.addProperty(prop, false); @@ -1421,18 +1419,15 @@ public class GridQueryProcessor extends GridProcessorAdapter { * @param pathStr String representing path to the property. May contains dots '.' to identify * nested fields. * @param resType Result type. - * @param keyCls Key class. - * @param valCls Value class. * @return Portable property. */ - private IndexedFieldsProperty buildIndexedFieldsProperty(String pathStr, Class<?> resType, - @Nullable Class<?> keyCls, @Nullable Class<?> valCls) { + private IndexedFieldsProperty buildIndexedFieldsProperty(String pathStr, Class<?> resType) { String[] path = pathStr.split("\\."); IndexedFieldsProperty res = null; for (String prop : path) - res = new IndexedFieldsProperty(prop, res, resType, keyCls, valCls); + res = new IndexedFieldsProperty(prop, res, resType); return res; } @@ -1702,9 +1697,9 @@ public class GridQueryProcessor extends GridProcessorAdapter { if (isKeyProp0 == 0) { // Key is allowed to be a non-portable object here. // We check key before value consistently with ClassProperty. - if (ctx.cacheObjects().isPortableObject(key) && ctx.cacheObjects().hasField(key, propName, null)) + if (ctx.cacheObjects().isPortableObject(key) && ctx.cacheObjects().hasField(key, propName)) isKeyProp = isKeyProp0 = 1; - else if (ctx.cacheObjects().hasField(val, propName, null)) + else if (ctx.cacheObjects().hasField(val, propName)) isKeyProp = isKeyProp0 = -1; else { U.warn(log, "Neither key nor value have property " + @@ -1717,7 +1712,7 @@ public class GridQueryProcessor extends GridProcessorAdapter { obj = isKeyProp0 == 1 ? key : val; } - return ctx.cacheObjects().field(obj, propName, null); + return ctx.cacheObjects().field(obj, propName); } /** {@inheritDoc} */ @@ -1744,49 +1739,17 @@ public class GridQueryProcessor extends GridProcessorAdapter { /** Result class. */ private Class<?> type; - /** Key field */ - private Field keyField; - - /** Value field */ - private Field valueField; - /** * Constructor. * * @param propName Property name. * @param parent Parent property. * @param type Result type. - * @param keyCls Key class. - * @param valCls Value class. */ - private IndexedFieldsProperty(String propName, IndexedFieldsProperty parent, Class<?> type, - @Nullable Class<?> keyCls, @Nullable Class<?> valCls) { + private IndexedFieldsProperty(String propName, IndexedFieldsProperty parent, Class<?> type) { this.propName = propName; this.parent = parent; this.type = type; - - /*if (keyCls != null) { - try { - keyField = keyCls.getDeclaredField(propName); - - keyField.setAccessible(true); - } catch (NoSuchFieldException e) { - // No-op - } - } - else if (valCls != null && keyField == null) { - try { - valueField = valCls.getDeclaredField(propName); - - valueField.setAccessible(true); - } catch (NoSuchFieldException e) { - // No-op - } - } - - if ((keyCls != null || valCls != null) && keyField == null && valueField == null) - U.warn(log, "Neither key nor value class has field " + - "[fieldName=" + propName + ", key=" + keyCls + ", val=" + valCls + "]");*/ } /** {@inheritDoc} */ @@ -1803,42 +1766,22 @@ public class GridQueryProcessor extends GridProcessorAdapter { throw new IgniteCheckedException("Non-indexed object received as a result of property extraction " + "[parent=" + parent + ", propName=" + propName + ", obj=" + obj + ']'); - return ctx.cacheObjects().field(obj, propName, keyField != null ? keyField : valueField); + return ctx.cacheObjects().field(obj, propName); } else { - if (key instanceof CacheIndexedObjectImpl) { - try { + try { - return ctx.cacheObjects().field(key, propName, keyField); - } - catch (IgniteFieldNotFoundException e) { - // Ignore - } + return ctx.cacheObjects().field(key, propName); } - else if (keyField != null) { - try { - return keyField.get(key); - } - catch (Exception e) { - throw new IgniteCheckedException(e); - } + catch (IgniteFieldNotFoundException e) { + // Ignore } - if (val instanceof CacheIndexedObjectImpl) { - try { - return ctx.cacheObjects().field(val, propName, valueField); - } - catch (IgniteFieldNotFoundException e) { - // Ignore - } + try { + return ctx.cacheObjects().field(val, propName); } - else if (valueField != null) { - try { - return valueField.get(val); - } - catch (Exception e) { - throw new IgniteCheckedException(e); - } + catch (IgniteFieldNotFoundException e) { + // Ignore } U.warn(log, "Neither key nor value has property " +