This is an automated email from the ASF dual-hosted git repository. sarath pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push: new 37eb276 Revert "ATLAS-3112: Allow Indexing of array attributes (LIST or SET) in indexing store" 37eb276 is described below commit 37eb276563fc69ae532acdc63845d20990e2de3f Author: Sarath Subramanian <ssubraman...@hortonworks.com> AuthorDate: Sun Apr 7 15:02:33 2019 -0700 Revert "ATLAS-3112: Allow Indexing of array attributes (LIST or SET) in indexing store" This reverts commit d234de2d7ef4a935db313a852ce80b8aab126c3b. --- .../repository/graphdb/AtlasGraphManagement.java | 3 +- .../graphdb/janus/AtlasJanusGraphManagement.java | 8 ++---- .../graphdb/janus/AbstractGraphDatabaseTest.java | 2 +- .../repository/graph/GraphBackedSearchIndexer.java | 24 ++++++++-------- .../apache/atlas/repository/graph/GraphHelper.java | 4 +-- .../store/graph/v2/AtlasGraphUtilsV2.java | 27 ++++-------------- .../store/graph/v2/EntityGraphMapper.java | 32 ++++++---------------- .../store/graph/v2/EntityStateChecker.java | 4 +-- 8 files changed, 34 insertions(+), 70 deletions(-) diff --git a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphManagement.java b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphManagement.java index cfa1cb4..b1e2c5d 100644 --- a/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphManagement.java +++ b/graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasGraphManagement.java @@ -155,7 +155,6 @@ public interface AtlasGraphManagement { * * @param vertexIndex * @param propertyKey - * @param propertyClass */ - void addMixedIndex(String vertexIndex, AtlasPropertyKey propertyKey, Class propertyClass); + void addMixedIndex(String vertexIndex, AtlasPropertyKey propertyKey); } diff --git a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java index 7b034ba..4e18432 100644 --- a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java +++ b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphManagement.java @@ -195,15 +195,11 @@ public class AtlasJanusGraphManagement implements AtlasGraphManagement { } @Override - public void addMixedIndex(String indexName, AtlasPropertyKey propertyKey, Class propertyClass) { + public void addMixedIndex(String indexName, AtlasPropertyKey propertyKey) { PropertyKey janusKey = AtlasJanusObjectFactory.createPropertyKey(propertyKey); JanusGraphIndex vertexIndex = management.getGraphIndex(indexName); - if (propertyClass == String.class) { - management.addIndexKey(vertexIndex, janusKey, Mapping.STRING.asParameter()); - } else { - management.addIndexKey(vertexIndex, janusKey); - } + management.addIndexKey(vertexIndex, janusKey); } @Override diff --git a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java index a139d08..f72b412 100644 --- a/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java +++ b/graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AbstractGraphDatabaseTest.java @@ -99,7 +99,7 @@ public abstract class AbstractGraphDatabaseTest { AtlasPropertyKey key = management.makePropertyKey(propertyName, propertyClass, cardinality); try { if (propertyClass != Integer.class) { - management.addMixedIndex(BACKING_INDEX_NAME, key, propertyClass); + management.addMixedIndex(BACKING_INDEX_NAME, key); } } catch(Throwable t) { //ok diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java index 9f75d2a..c57f8e3 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java @@ -271,13 +271,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang createVertexIndex(management, VERTEX_ID_IN_IMPORT_KEY, UniqueKind.NONE, Long.class, SINGLE, true, false); createVertexIndex(management, ENTITY_TYPE_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, true, false); + createVertexIndex(management, SUPER_TYPES_PROPERTY_KEY, UniqueKind.NONE, String.class, SET, true, false); createVertexIndex(management, TIMESTAMP_PROPERTY_KEY, UniqueKind.NONE, Long.class, SINGLE, false, false); createVertexIndex(management, MODIFICATION_TIMESTAMP_PROPERTY_KEY, UniqueKind.NONE, Long.class, SINGLE, false, false); createVertexIndex(management, STATE_PROPERTY_KEY, UniqueKind.NONE, String.class, SINGLE, false, false); createVertexIndex(management, CREATED_BY_KEY, UniqueKind.NONE, String.class, SINGLE, false, false); createVertexIndex(management, MODIFIED_BY_KEY, UniqueKind.NONE, String.class, SINGLE, false, false); - - createVertexIndex(management, SUPER_TYPES_PROPERTY_KEY, UniqueKind.NONE, String.class, SET, true, false); createVertexIndex(management, TRAIT_NAMES_PROPERTY_KEY, UniqueKind.NONE, String.class, SET, true, true); createVertexIndex(management, PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, UniqueKind.NONE, String.class, LIST, true, true); @@ -352,11 +351,10 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang createLabelIfNeeded(management, propertyName, attribTypeName); AtlasArrayType arrayType = (AtlasArrayType) attributeType; - AtlasType elementType = arrayType.getElementType(); - boolean isReference = isReference(elementType); + boolean isReference = isReference(arrayType.getElementType()); if (!isReference) { - createVertexIndex(management, propertyName, UniqueKind.NONE, getPrimitiveClass(elementType.getTypeName()), cardinality, isIndexable, false); + createPropertyKey(management, propertyName, ArrayList.class, SINGLE); } } @@ -510,12 +508,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang if (propertyKey == null) { propertyKey = management.makePropertyKey(propertyName, propertyClass, cardinality); - if (isIndexApplicable(propertyClass)) { + if (isIndexApplicable(propertyClass, cardinality)) { if (LOG.isDebugEnabled()) { LOG.debug("Creating backing index for vertex property {} of type {} ", propertyName, propertyClass.getName()); } - management.addMixedIndex(VERTEX_INDEX, propertyKey, propertyClass); + management.addMixedIndex(VERTEX_INDEX, propertyKey); LOG.info("Created backing index for vertex property {} of type {} ", propertyName, propertyClass.getName()); } @@ -593,12 +591,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang if (propertyKey == null) { propertyKey = management.makePropertyKey(propertyName, propertyClass, cardinality); - if (isIndexApplicable(propertyClass)) { + if (isIndexApplicable(propertyClass, cardinality)) { if (LOG.isDebugEnabled()) { LOG.debug("Creating backing index for edge property {} of type {} ", propertyName, propertyClass.getName()); } - management.addMixedIndex(EDGE_INDEX, propertyKey, propertyClass); + management.addMixedIndex(EDGE_INDEX, propertyKey); LOG.info("Created backing index for edge property {} of type {} ", propertyName, propertyClass.getName()); } @@ -621,12 +619,12 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang if (propertyKey == null) { propertyKey = management.makePropertyKey(propertyName, propertyClass, cardinality); - if (isIndexApplicable(propertyClass)) { + if (isIndexApplicable(propertyClass, cardinality)) { if (LOG.isDebugEnabled()) { LOG.debug("Creating backing index for vertex property {} of type {} ", propertyName, propertyClass.getName()); } - management.addMixedIndex(FULLTEXT_INDEX, propertyKey, propertyClass); + management.addMixedIndex(FULLTEXT_INDEX, propertyKey); LOG.info("Created backing index for vertex property {} of type {} ", propertyName, propertyClass.getName()); } @@ -702,8 +700,8 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang } } - private boolean isIndexApplicable(Class propertyClass) { - return !INDEX_EXCLUSION_CLASSES.contains(propertyClass); + private boolean isIndexApplicable(Class propertyClass, AtlasCardinality cardinality) { + return !(INDEX_EXCLUSION_CLASSES.contains(propertyClass) || cardinality.isMany()); } public void commit(AtlasGraphManagement management) throws IndexException { diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 237389e..449f382 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -199,7 +199,7 @@ public final class GraphHelper { AtlasGraphUtilsV2.setEncodedProperty(ret, MODIFIED_BY_KEY, RequestContext.get().getUser()); for (String superTypeName : superTypeNames) { - AtlasGraphUtilsV2.addToEncodedSetProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); + AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); } return ret; @@ -1545,7 +1545,7 @@ public final class GraphHelper { if (isReference(elementType)) { return (List) getCollectionElementsUsingRelationship(instanceVertex, attribute); } else { - return (List) instanceVertex.getPropertyValues(propertyName, List.class); + return (List) instanceVertex.getListProperty(propertyName); } } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java index 084958f..80141b4 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java @@ -32,7 +32,6 @@ import org.apache.atlas.model.patches.AtlasPatch; import org.apache.atlas.model.patches.AtlasPatch.AtlasPatches; import org.apache.atlas.model.patches.AtlasPatch.PatchStatus; import org.apache.atlas.model.typedef.AtlasBaseTypeDef; -import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality; import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graph.AtlasGraphProvider; import org.apache.atlas.repository.graph.GraphHelper; @@ -65,8 +64,6 @@ import java.util.Map; import java.util.Set; import static org.apache.atlas.model.patches.AtlasPatch.PatchStatus.UNKNOWN; -import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality.LIST; -import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality.SET; import static org.apache.atlas.repository.Constants.CREATED_BY_KEY; import static org.apache.atlas.repository.Constants.ENTITY_TYPE_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.INDEX_SEARCH_VERTEX_PREFIX_DEFAULT; @@ -190,23 +187,15 @@ public class AtlasGraphUtilsV2 { * @param propertyName * @param value */ - public static AtlasVertex addToListProperty(AtlasVertex vertex, String propertyName, Object value) { - return addProperty(vertex, propertyName, LIST, false, value); + public static AtlasVertex addProperty(AtlasVertex vertex, String propertyName, Object value) { + return addProperty(vertex, propertyName, value, false); } - public static AtlasVertex addToSetProperty(AtlasVertex vertex, String propertyName, Object value) { - return addProperty(vertex, propertyName, SET, false, value); + public static AtlasVertex addEncodedProperty(AtlasVertex vertex, String propertyName, Object value) { + return addProperty(vertex, propertyName, value, true); } - public static AtlasVertex addToEncodedListProperty(AtlasVertex vertex, String propertyName, Object value) { - return addProperty(vertex, propertyName, LIST, true, value); - } - - public static AtlasVertex addToEncodedSetProperty(AtlasVertex vertex, String propertyName, Object value) { - return addProperty(vertex, propertyName, SET, true, value); - } - - public static AtlasVertex addProperty(AtlasVertex vertex, String propertyName, Cardinality cardinality, boolean isEncoded, Object value) { + public static AtlasVertex addProperty(AtlasVertex vertex, String propertyName, Object value, boolean isEncoded) { if (LOG.isDebugEnabled()) { LOG.debug("==> addProperty({}, {}, {})", toString(vertex), propertyName, value); } @@ -215,11 +204,7 @@ public class AtlasGraphUtilsV2 { propertyName = encodePropertyKey(propertyName); } - if (cardinality == LIST) { - vertex.addListProperty(propertyName, value); - } else { - vertex.addProperty(propertyName, value); - } + vertex.addProperty(propertyName, value); return vertex; } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 14f67c9..4f93c8f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -78,7 +78,6 @@ import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.CR import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.DELETE; import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.PARTIAL_UPDATE; import static org.apache.atlas.model.instance.EntityMutations.EntityOperation.UPDATE; -import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality.LIST; import static org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef.Cardinality.SET; import static org.apache.atlas.repository.Constants.ATTRIBUTE_KEY_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_ENTITY_GUID; @@ -117,8 +116,6 @@ import static org.apache.atlas.repository.graph.GraphHelper.isPropagationEnabled import static org.apache.atlas.repository.graph.GraphHelper.isRelationshipEdge; import static org.apache.atlas.repository.graph.GraphHelper.string; import static org.apache.atlas.repository.graph.GraphHelper.updateModificationMetadata; -import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.addToListProperty; -import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.addToSetProperty; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex; import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference; import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN; @@ -168,7 +165,7 @@ public class EntityGraphMapper { AtlasVertex ret = createStructVertex(entity); for (String superTypeName : entityType.getAllSuperTypes()) { - AtlasGraphUtilsV2.addToEncodedSetProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); + AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); } AtlasGraphUtilsV2.setEncodedProperty(ret, GUID_PROPERTY_KEY, guid); @@ -313,10 +310,7 @@ public class EntityGraphMapper { AtlasVertex ret = createStructVertex(classification); - for (String superTypeName : classificationType.getAllSuperTypes()) { - AtlasGraphUtilsV2.addToEncodedSetProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); - } - + AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, classificationType.getAllSuperTypes()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_GUID, classification.getEntityGuid()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_STATUS, classification.getEntityStatus().name()); @@ -1086,9 +1080,9 @@ public class EntityGraphMapper { } if (isNewElementsNull) { - setArrayElementsProperty(elementType, isSoftReference, ctx.getReferringVertex(), ctx.getVertexProperty(), null, cardinality); + setArrayElementsProperty(elementType, isSoftReference, ctx.getReferringVertex(), ctx.getVertexProperty(), null); } else { - setArrayElementsProperty(elementType, isSoftReference, ctx.getReferringVertex(), ctx.getVertexProperty(), newElementsCreated, cardinality); + setArrayElementsProperty(elementType, isSoftReference, ctx.getReferringVertex(), ctx.getVertexProperty(), newElementsCreated); } if (LOG.isDebugEnabled()) { @@ -1398,7 +1392,7 @@ public class EntityGraphMapper { return (List)vertex.getListProperty(vertexPropertyName, AtlasEdge.class); } else { - return (List) vertex.getPropertyValues(vertexPropertyName, List.class); + return (List)vertex.getListProperty(vertexPropertyName); } } @@ -1442,17 +1436,9 @@ public class EntityGraphMapper { return Collections.emptyList(); } - - private void setArrayElementsProperty(AtlasType elementType, boolean isSoftReference, AtlasVertex vertex, String propertyName, List<Object> values, Cardinality cardinality) { + private void setArrayElementsProperty(AtlasType elementType, boolean isSoftReference, AtlasVertex vertex, String vertexPropertyName, List<Object> values) { if (!isReference(elementType) || isSoftReference) { - //remove existing array values before setting new values - vertex.removeProperty(propertyName); - - if (cardinality == LIST) { - values.forEach(value -> addToListProperty(vertex, propertyName, value)); - } else { - values.forEach(value -> addToSetProperty(vertex, propertyName, value)); - } + AtlasGraphUtilsV2.setEncodedProperty(vertex, vertexPropertyName, values); } } @@ -1537,7 +1523,7 @@ public class EntityGraphMapper { LOG.debug("Adding classification [{}] to [{}] using edge label: [{}]", classificationName, entityType.getTypeName(), getTraitLabel(classificationName)); } - AtlasGraphUtilsV2.addToEncodedSetProperty(entityVertex, TRAIT_NAMES_PROPERTY_KEY, classificationName); + AtlasGraphUtilsV2.addEncodedProperty(entityVertex, TRAIT_NAMES_PROPERTY_KEY, classificationName); // add a new AtlasVertex for the struct or trait instance AtlasVertex classificationVertex = createClassificationVertex(classification); @@ -1938,7 +1924,7 @@ public class EntityGraphMapper { entityVertex.removeProperty(TRAIT_NAMES_PROPERTY_KEY); for (String traitName : traitNames) { - AtlasGraphUtilsV2.addToEncodedSetProperty(entityVertex, TRAIT_NAMES_PROPERTY_KEY, traitName); + AtlasGraphUtilsV2.addEncodedProperty(entityVertex, TRAIT_NAMES_PROPERTY_KEY, traitName); } } } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityStateChecker.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityStateChecker.java index 07df9de..eb594f2 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityStateChecker.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityStateChecker.java @@ -268,7 +268,7 @@ public final class EntityStateChecker { entityVertex.removeProperty(Constants.TRAIT_NAMES_PROPERTY_KEY); for (String classificationName : traitVertexNames) { - AtlasGraphUtilsV2.addToEncodedSetProperty(entityVertex, Constants.TRAIT_NAMES_PROPERTY_KEY, classificationName); + AtlasGraphUtilsV2.addEncodedProperty(entityVertex, Constants.TRAIT_NAMES_PROPERTY_KEY, classificationName); } } @@ -284,7 +284,7 @@ public final class EntityStateChecker { entityVertex.removeProperty(Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY); for (String classificationName : propagatedTraitVertexNames) { - AtlasGraphUtilsV2.addToEncodedListProperty(entityVertex, Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, classificationName); + AtlasGraphUtilsV2.addEncodedProperty(entityVertex, Constants.PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, classificationName); } }