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
4 years ago
by
Mandar Ambawane
Committed by
Sarath Subramanian
4 years ago
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
57 deletions
+52
-57
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
+10
-12
SolrIndexHelper.java
...va/org/apache/atlas/repository/graph/SolrIndexHelper.java
+10
-28
No files found.
intg/src/main/java/org/apache/atlas/listener/ChangedTypeDefs.java
View file @
1e8fa7e5
...
...
@@ -92,7 +92,7 @@ public class ChangedTypeDefs {
}
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
)
{
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
View file @
1e8fa7e5
...
...
@@ -980,22 +980,9 @@ public class AtlasTypeRegistry {
new
Exception
().
fillInStackTrace
());
}
else
if
(
typeRegistryUpdateLock
.
getHoldCount
()
==
1
)
{
if
(
ttr
!=
null
&&
commitUpdates
)
{
// copy indexName for entity attributes from current typeRegistry to new one
for
(
AtlasEntityType
ttrEntityType
:
ttr
.
getAllEntityTypes
())
{
AtlasEntityType
currEntityType
=
typeRegistry
.
getEntityTypeByName
(
ttrEntityType
.
getTypeName
());
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
());
}
}
}
}
}
// copy indexName for attributes from current typeRegistry to new one
copyIndexNameFromCurrent
(
ttr
.
getAllEntityTypes
());
copyIndexNameFromCurrent
(
ttr
.
getAllBusinessMetadataTypes
());
typeRegistry
.
registryData
=
ttr
.
registryData
;
}
...
...
@@ -1018,6 +1005,34 @@ public class AtlasTypeRegistry {
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
());
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java
View file @
1e8fa7e5
...
...
@@ -209,14 +209,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
LOG
.
debug
(
"Type definition load completed. Informing the completion to IndexChangeListeners."
);
}
Collection
<
AtlasEntityDef
>
entityDefs
=
typeRegistry
.
getAllEntityDefs
();
ChangedTypeDefs
changedTypeDefs
=
new
ChangedTypeDefs
(
null
,
new
ArrayList
<>(
entityDefs
),
null
);
AtlasGraphManagement
management
=
null
;
ChangedTypeDefs
changedTypeDefs
=
null
;
AtlasGraphManagement
management
=
null
;
try
{
management
=
provider
.
get
().
getManagementSystem
();
//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
);
//Commit indexes
...
...
@@ -382,19 +386,13 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
resolveIndexFieldNames
(
managementSystem
,
businessMetadataType
);
}
else
{
LOG
.
debug
(
"Ignoring t
he non-entity t
ype 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
,
AtlasBusinessMetadataType
businessMetadataType
)
{
for
(
AtlasAttribute
attribute
:
businessMetadataType
.
getAllAttributes
().
values
())
{
private
void
resolveIndexFieldNames
(
AtlasGraphManagement
managementSystem
,
AtlasStructType
structType
)
{
for
(
AtlasAttribute
attribute:
structType
.
getAllAttributes
().
values
())
{
resolveIndexFieldName
(
managementSystem
,
attribute
);
}
}
...
...
This diff is collapsed.
Click to expand it.
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;
import
org.apache.atlas.repository.graphdb.AtlasGraphIndexClient
;
import
org.apache.atlas.type.AtlasBusinessMetadataType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
...
...
@@ -118,58 +119,39 @@ public class SolrIndexHelper implements IndexChangeListener {
}
private
Map
<
String
,
Integer
>
geIndexFieldNamesWithSearchWeights
()
{
Map
<
String
,
Integer
>
ret
=
new
HashMap
<>();
Collection
<
AtlasEntityType
>
entityTypes
=
typeRegistry
.
getAllEntityTypes
();
Collection
<
AtlasBusinessMetadataType
>
businessMetadataTypes
=
typeRegistry
.
getAllBusinessMetadataTypes
();
Map
<
String
,
Integer
>
ret
=
new
HashMap
<>();
//the following properties are specially added manually.
//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
(
LABELS_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_LABELS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
CUSTOM_ATTRIBUTES_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_CUSTOM_ATTRS
);
ret
.
put
(
typeRegistry
.
getIndexFieldName
(
TYPE_NAME_PROPERTY_KEY
),
SEARCHWEIGHT_FOR_TYPENAME
);
if
(!
CollectionUtils
.
isNotEmpty
(
entityTypes
)
&&
CollectionUtils
.
isEmpty
(
businessMetadataTypes
))
{
return
ret
;
}
for
(
AtlasEntityType
entityType
:
entityTypes
)
{
for
(
AtlasEntityType
entityType
:
typeRegistry
.
getAllEntityTypes
())
{
if
(
entityType
.
isInternalType
())
{
continue
;
}
process
Entity
Type
(
ret
,
entityType
);
processType
(
ret
,
entityType
);
}
for
(
AtlasBusinessMetadataType
businessMetadataType
:
businessMetadataTypes
)
{
process
BusinessMetadata
Type
(
ret
,
businessMetadataType
);
for
(
AtlasBusinessMetadataType
businessMetadataType
:
typeRegistry
.
getAllBusinessMetadataTypes
())
{
processType
(
ret
,
businessMetadataType
);
}
return
ret
;
}
private
void
process
BusinessMetadataType
(
Map
<
String
,
Integer
>
indexFieldNameWithSearchWeights
,
AtlasBusinessMetadataType
businessMetadata
Type
)
{
List
<
AtlasAttributeDef
>
attributes
=
businessMetadataType
.
getBusinessMetadata
Def
().
getAttributeDefs
();
private
void
process
Type
(
Map
<
String
,
Integer
>
indexFieldNameWithSearchWeights
,
AtlasStructType
struct
Type
)
{
List
<
AtlasAttributeDef
>
attributes
=
structType
.
getStruct
Def
().
getAttributeDefs
();
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
for
(
AtlasAttributeDef
attribute
:
attributes
)
{
processAttribute
(
indexFieldNameWithSearchWeights
,
businessMetadata
Type
.
getAttribute
(
attribute
.
getName
()));
processAttribute
(
indexFieldNameWithSearchWeights
,
struct
Type
.
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
{
LOG
.
debug
(
"No attributes are defined for entity {}"
,
entityType
.
getTypeName
());
LOG
.
debug
(
"No attributes are defined for type {}"
,
structType
.
getTypeName
());
}
}
...
...
This diff is collapsed.
Click to expand it.
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