Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
1e8fa7e5
Commit
1e8fa7e5
authored
Apr 10, 2020
by
Mandar Ambawane
Committed by
Sarath Subramanian
Apr 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3709 Issues with quick search/suggestions in conjunction with Business Metadata attributes
Signed-off-by:
Sarath Subramanian
<
sarath@apache.org
>
parent
3ff785a8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
55 deletions
+50
-55
ChangedTypeDefs.java
.../main/java/org/apache/atlas/listener/ChangedTypeDefs.java
+1
-1
AtlasTypeRegistry.java
...rc/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+31
-16
GraphBackedSearchIndexer.java
...ache/atlas/repository/graph/GraphBackedSearchIndexer.java
+9
-11
SolrIndexHelper.java
...va/org/apache/atlas/repository/graph/SolrIndexHelper.java
+9
-27
No files found.
intg/src/main/java/org/apache/atlas/listener/ChangedTypeDefs.java
View file @
1e8fa7e5
...
@@ -92,7 +92,7 @@ public class ChangedTypeDefs {
...
@@ -92,7 +92,7 @@ public class ChangedTypeDefs {
}
}
public
boolean
hasBusinessMetadataDef
()
{
public
boolean
hasBusinessMetadataDef
()
{
return
hasBusinessMetadataDef
(
createdTypeDefs
)
||
has
EntityDef
(
updatedTypeDefs
)
||
hasEntity
Def
(
deletedTypeDefs
);
return
hasBusinessMetadataDef
(
createdTypeDefs
)
||
has
BusinessMetadataDef
(
updatedTypeDefs
)
||
hasBusinessMetadata
Def
(
deletedTypeDefs
);
}
}
private
boolean
hasBusinessMetadataDef
(
List
<?
extends
AtlasBaseTypeDef
>
typeDefs
)
{
private
boolean
hasBusinessMetadataDef
(
List
<?
extends
AtlasBaseTypeDef
>
typeDefs
)
{
...
...
intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
View file @
1e8fa7e5
...
@@ -980,22 +980,9 @@ public class AtlasTypeRegistry {
...
@@ -980,22 +980,9 @@ public class AtlasTypeRegistry {
new
Exception
().
fillInStackTrace
());
new
Exception
().
fillInStackTrace
());
}
else
if
(
typeRegistryUpdateLock
.
getHoldCount
()
==
1
)
{
}
else
if
(
typeRegistryUpdateLock
.
getHoldCount
()
==
1
)
{
if
(
ttr
!=
null
&&
commitUpdates
)
{
if
(
ttr
!=
null
&&
commitUpdates
)
{
// copy indexName for entity attributes from current typeRegistry to new one
// copy indexName for attributes from current typeRegistry to new one
for
(
AtlasEntityType
ttrEntityType
:
ttr
.
getAllEntityTypes
())
{
copyIndexNameFromCurrent
(
ttr
.
getAllEntityTypes
());
AtlasEntityType
currEntityType
=
typeRegistry
.
getEntityTypeByName
(
ttrEntityType
.
getTypeName
());
copyIndexNameFromCurrent
(
ttr
.
getAllBusinessMetadataTypes
());
if
(
currEntityType
!=
null
)
{
// ttrEntityType could be a new type introduced
for
(
AtlasAttribute
attribute
:
ttrEntityType
.
getAllAttributes
().
values
())
{
if
(
StringUtils
.
isEmpty
(
attribute
.
getIndexFieldName
()))
{
AtlasAttribute
currAttribute
=
currEntityType
.
getAttribute
(
attribute
.
getName
());
if
(
currAttribute
!=
null
)
{
attribute
.
setIndexFieldName
(
currAttribute
.
getIndexFieldName
());
}
}
}
}
}
typeRegistry
.
registryData
=
ttr
.
registryData
;
typeRegistry
.
registryData
=
ttr
.
registryData
;
}
}
...
@@ -1018,6 +1005,34 @@ public class AtlasTypeRegistry {
...
@@ -1018,6 +1005,34 @@ public class AtlasTypeRegistry {
LOG
.
debug
(
"<== releaseTypeRegistryForUpdate()"
);
LOG
.
debug
(
"<== releaseTypeRegistryForUpdate()"
);
}
}
private
void
copyIndexNameFromCurrent
(
Collection
<?
extends
AtlasStructType
>
ttrTypes
)
{
for
(
AtlasStructType
ttrType
:
ttrTypes
)
{
final
AtlasStructType
currType
;
if
(
ttrType
instanceof
AtlasEntityType
)
{
currType
=
typeRegistry
.
getEntityTypeByName
(
ttrType
.
getTypeName
());
}
else
if
(
ttrType
instanceof
AtlasBusinessMetadataType
)
{
currType
=
typeRegistry
.
getBusinessMetadataTypeByName
(
ttrType
.
getTypeName
());
}
else
{
currType
=
null
;
}
if
(
currType
==
null
)
{
// ttrType could be a new type introduced
continue
;
}
for
(
AtlasAttribute
ttrAttribute
:
ttrType
.
getAllAttributes
().
values
())
{
if
(
StringUtils
.
isEmpty
(
ttrAttribute
.
getIndexFieldName
()))
{
AtlasAttribute
currAttribute
=
currType
.
getAttribute
(
ttrAttribute
.
getName
());
if
(
currAttribute
!=
null
)
{
ttrAttribute
.
setIndexFieldName
(
currAttribute
.
getIndexFieldName
());
}
}
}
}
}
}
}
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
View file @
1e8fa7e5
...
@@ -209,14 +209,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
...
@@ -209,14 +209,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
LOG
.
debug
(
"Type definition load completed. Informing the completion to IndexChangeListeners."
);
LOG
.
debug
(
"Type definition load completed. Informing the completion to IndexChangeListeners."
);
}
}
Collection
<
AtlasEntityDef
>
entityDefs
=
typeRegistry
.
getAllEntityDefs
();
ChangedTypeDefs
changedTypeDefs
=
null
;
ChangedTypeDefs
changedTypeDefs
=
new
ChangedTypeDefs
(
null
,
new
ArrayList
<>(
entityDefs
),
null
);
AtlasGraphManagement
management
=
null
;
AtlasGraphManagement
management
=
null
;
try
{
try
{
management
=
provider
.
get
().
getManagementSystem
();
management
=
provider
.
get
().
getManagementSystem
();
//resolve index fields names for the new entity attributes.
//resolve index fields names for the new entity attributes.
changedTypeDefs
=
new
ChangedTypeDefs
(
null
,
new
ArrayList
<>(
typeRegistry
.
getAllEntityDefs
()),
null
);
resolveIndexFieldNames
(
management
,
changedTypeDefs
);
//resolve index fields names for the new business metadata attributes.
changedTypeDefs
=
new
ChangedTypeDefs
(
null
,
new
ArrayList
<>(
typeRegistry
.
getAllBusinessMetadataDefs
()),
null
);
resolveIndexFieldNames
(
management
,
changedTypeDefs
);
resolveIndexFieldNames
(
management
,
changedTypeDefs
);
//Commit indexes
//Commit indexes
...
@@ -382,19 +386,13 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
...
@@ -382,19 +386,13 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
resolveIndexFieldNames
(
managementSystem
,
businessMetadataType
);
resolveIndexFieldNames
(
managementSystem
,
businessMetadataType
);
}
else
{
}
else
{
LOG
.
debug
(
"Ignoring the non-entity type definition {}"
,
baseTypeDef
.
getName
());
LOG
.
debug
(
"Ignoring type definition {}"
,
baseTypeDef
.
getName
());
}
}
}
}
}
private
void
resolveIndexFieldNames
(
AtlasGraphManagement
managementSystem
,
AtlasEntityType
entityType
)
{
for
(
AtlasAttribute
attribute:
entityType
.
getAllAttributes
().
values
())
{
resolveIndexFieldName
(
managementSystem
,
attribute
);
}
}
}
private
void
resolveIndexFieldNames
(
AtlasGraphManagement
managementSystem
,
Atlas
BusinessMetadataType
businessMetadata
Type
)
{
private
void
resolveIndexFieldNames
(
AtlasGraphManagement
managementSystem
,
Atlas
StructType
struct
Type
)
{
for
(
AtlasAttribute
attribute
:
businessMetadata
Type
.
getAllAttributes
().
values
())
{
for
(
AtlasAttribute
attribute:
struct
Type
.
getAllAttributes
().
values
())
{
resolveIndexFieldName
(
managementSystem
,
attribute
);
resolveIndexFieldName
(
managementSystem
,
attribute
);
}
}
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/graph/SolrIndexHelper.java
View file @
1e8fa7e5
...
@@ -25,6 +25,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
...
@@ -25,6 +25,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraph;
import
org.apache.atlas.repository.graphdb.AtlasGraphIndexClient
;
import
org.apache.atlas.repository.graphdb.AtlasGraphIndexClient
;
import
org.apache.atlas.type.AtlasBusinessMetadataType
;
import
org.apache.atlas.type.AtlasBusinessMetadataType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
...
@@ -119,57 +120,38 @@ public class SolrIndexHelper implements IndexChangeListener {
...
@@ -119,57 +120,38 @@ public class SolrIndexHelper implements IndexChangeListener {
private
Map
<
String
,
Integer
>
geIndexFieldNamesWithSearchWeights
()
{
private
Map
<
String
,
Integer
>
geIndexFieldNamesWithSearchWeights
()
{
Map
<
String
,
Integer
>
ret
=
new
HashMap
<>();
Map
<
String
,
Integer
>
ret
=
new
HashMap
<>();
Collection
<
AtlasEntityType
>
entityTypes
=
typeRegistry
.
getAllEntityTypes
();
Collection
<
AtlasBusinessMetadataType
>
businessMetadataTypes
=
typeRegistry
.
getAllBusinessMetadataTypes
();
//the following properties are specially added manually.
//the following properties are specially added manually.
//as, they don't come in the entity definitions as attributes.
//as, they don't come in the entity definitions as attributes.
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
CLASSIFICATION_TEXT_KEY
),
SEARCHWEIGHT_FOR_CLASSIFICATIONS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
CLASSIFICATION_TEXT_KEY
),
SEARCHWEIGHT_FOR_CLASSIFICATIONS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
LABELS_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_LABELS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
LABELS_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_LABELS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
CUSTOM_ATTRIBUTES_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_CUSTOM_ATTRS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
CUSTOM_ATTRIBUTES_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_CUSTOM_ATTRS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
TYPE_NAME_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_TYPENAME
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
TYPE_NAME_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_TYPENAME
);
if
(!
CollectionUtils
.
isNotEmpty
(
entityTypes
)
&&
CollectionUtils
.
isEmpty
(
businessMetadataTypes
))
{
for
(
AtlasEntityType
entityType
:
typeRegistry
.
getAllEntityTypes
())
{
return
ret
;
}
for
(
AtlasEntityType
entityType
:
entityTypes
)
{
if
(
entityType
.
isInternalType
())
{
if
(
entityType
.
isInternalType
())
{
continue
;
continue
;
}
}
process
Entity
Type
(
ret
,
entityType
);
processType
(
ret
,
entityType
);
}
}
for
(
AtlasBusinessMetadataType
businessMetadataType
:
businessMetadataTypes
)
{
for
(
AtlasBusinessMetadataType
businessMetadataType
:
typeRegistry
.
getAllBusinessMetadataTypes
())
{
process
BusinessMetadata
Type
(
ret
,
businessMetadataType
);
processType
(
ret
,
businessMetadataType
);
}
}
return
ret
;
return
ret
;
}
}
private
void
process
BusinessMetadataType
(
Map
<
String
,
Integer
>
indexFieldNameWithSearchWeights
,
AtlasBusinessMetadataType
businessMetadata
Type
)
{
private
void
process
Type
(
Map
<
String
,
Integer
>
indexFieldNameWithSearchWeights
,
AtlasStructType
struct
Type
)
{
List
<
AtlasAttributeDef
>
attributes
=
businessMetadataType
.
getBusinessMetadata
Def
().
getAttributeDefs
();
List
<
AtlasAttributeDef
>
attributes
=
structType
.
getStruct
Def
().
getAttributeDefs
();
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
for
(
AtlasAttributeDef
attribute
:
attributes
)
{
for
(
AtlasAttributeDef
attribute
:
attributes
)
{
processAttribute
(
indexFieldNameWithSearchWeights
,
businessMetadataType
.
getAttribute
(
attribute
.
getName
()));
processAttribute
(
indexFieldNameWithSearchWeights
,
structType
.
getAttribute
(
attribute
.
getName
()));
}
}
else
{
LOG
.
debug
(
"No attributes are defined for BusinessMetadata {}"
,
businessMetadataType
.
getTypeName
());
}
}
private
void
processEntityType
(
Map
<
String
,
Integer
>
indexFieldNameWithSearchWeights
,
AtlasEntityType
entityType
)
{
List
<
AtlasAttributeDef
>
attributes
=
entityType
.
getEntityDef
().
getAttributeDefs
();
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
for
(
AtlasAttributeDef
attribute
:
attributes
)
{
processAttribute
(
indexFieldNameWithSearchWeights
,
entityType
.
getAttribute
(
attribute
.
getName
()));
}
}
}
else
{
}
else
{
LOG
.
debug
(
"No attributes are defined for
entity {}"
,
entity
Type
.
getTypeName
());
LOG
.
debug
(
"No attributes are defined for
type {}"
,
struct
Type
.
getTypeName
());
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment