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
0e53c3ee
Commit
0e53c3ee
authored
4 years ago
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3778: Improve performance during classification delete
parent
1c07f93b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
44 deletions
+78
-44
AtlasElement.java
...ava/org/apache/atlas/repository/graphdb/AtlasElement.java
+10
-0
AtlasJanusElement.java
...che/atlas/repository/graphdb/janus/AtlasJanusElement.java
+30
-0
DeleteHandlerV1.java
...ache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+21
-24
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+17
-20
No files found.
graphdb/api/src/main/java/org/apache/atlas/repository/graphdb/AtlasElement.java
View file @
0e53c3ee
...
...
@@ -111,6 +111,16 @@ public interface AtlasElement {
void
removeProperty
(
String
propertyName
);
/**
* Removes a property with given property value from the vertex.
*/
void
removePropertyValue
(
String
propertyName
,
Object
propertyValue
);
/**
* Removes a property with given property value from the vertex.
*/
void
removeAllPropertyValue
(
String
propertyName
,
Object
propertyValue
);
/**
* Sets a single-valued property to the given value. For
* properties defined as multiplicty many in the graph schema, the value is added instead
* (following set semantics)
...
...
This diff is collapsed.
Click to expand it.
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusElement.java
View file @
0e53c3ee
...
...
@@ -22,6 +22,7 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
...
...
@@ -107,6 +108,35 @@ public class AtlasJanusElement<T extends Element> implements AtlasElement {
}
@Override
public
void
removePropertyValue
(
String
propertyName
,
Object
propertyValue
)
{
Iterator
<?
extends
Property
<
Object
>>
it
=
getWrappedElement
().
properties
(
propertyName
);
while
(
it
.
hasNext
())
{
Property
currentProperty
=
it
.
next
();
Object
currentPropertyValue
=
currentProperty
.
value
();
if
(
Objects
.
equals
(
currentPropertyValue
,
propertyValue
))
{
currentProperty
.
remove
();
break
;
}
}
}
@Override
public
void
removeAllPropertyValue
(
String
propertyName
,
Object
propertyValue
)
{
Iterator
<?
extends
Property
<
Object
>>
it
=
getWrappedElement
().
properties
(
propertyName
);
while
(
it
.
hasNext
())
{
Property
currentProperty
=
it
.
next
();
Object
currentPropertyValue
=
currentProperty
.
value
();
if
(
Objects
.
equals
(
currentPropertyValue
,
propertyValue
))
{
currentProperty
.
remove
();
}
}
}
@Override
public
void
setProperty
(
String
propertyName
,
Object
value
)
{
try
{
if
(
value
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
View file @
0e53c3ee
...
...
@@ -993,42 +993,39 @@ public abstract class DeleteHandlerV1 {
}
entityVertex
.
addListProperty
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
String
propClsNames
=
entityVertex
.
getProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
String
.
class
);
propClsNames
=
StringUtils
.
isEmpty
(
propClsNames
)
?
CLASSIFICATION_NAME_DELIMITER
+
classificationName
:
(
propClsNames
+
classificationName
);
propClsNames
=
propClsNames
+
CLASSIFICATION_NAME_DELIMITER
;
entityVertex
.
setProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
propClsNames
);
entityVertex
.
setProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
getDelimitedPropagatedClassificationNames
(
entityVertex
,
classificationName
));
}
p
rivate
void
removeFromPropagatedClassificationNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
p
ublic
void
removeFromPropagatedClassificationNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
if
(
entityVertex
!=
null
&&
StringUtils
.
isNotEmpty
(
classificationName
))
{
List
<
String
>
propagatedTraitNames
=
getTraitNames
(
entityVertex
,
true
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Removing from property: {} value: {} in vertex: {}"
,
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
,
string
(
entityVertex
));
}
propagatedTraitNames
.
remove
(
classificationName
);
entityVertex
.
removePropertyValue
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
setPropagatedClassificationNames
(
entityVertex
,
propagatedTraitNames
);
}
}
List
<
String
>
propagatedTraitNames
=
getPropagatedTraitNames
(
entityVertex
);
private
void
setPropagatedClassificationNames
(
AtlasVertex
entityVertex
,
List
<
String
>
classificationNames
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Adding property {} = \"{}\" to vertex {}"
,
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationNames
,
string
(
entityVertex
));
}
if
(
CollectionUtils
.
isNotEmpty
(
propagatedTraitNames
))
{
propagatedTraitNames
.
remove
(
classificationName
);
entityVertex
.
removeProperty
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
);
entityVertex
.
removeProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
);
String
propClsName
=
CLASSIFICATION_NAME_DELIMITER
+
StringUtils
.
join
(
propagatedTraitNames
,
CLASSIFICATION_NAME_DELIMITER
)
+
CLASSIFICATION_NAME_DELIMITER
;
if
(
CollectionUtils
.
isNotEmpty
(
classificationNames
))
{
for
(
String
classificationName
:
classificationNames
)
{
entityVertex
.
addListProperty
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
entityVertex
.
setProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
propClsName
);
}
}
}
String
propClsName
=
CLASSIFICATION_NAME_DELIMITER
+
StringUtils
.
join
(
classificationNames
,
CLASSIFICATION_NAME_DELIMITER
)
+
CLASSIFICATION_NAME_DELIMITER
;
private
String
getDelimitedPropagatedClassificationNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
String
ret
=
entityVertex
.
getProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
String
.
class
);
entityVertex
.
setProperty
(
PROPAGATED_CLASSIFICATION_NAMES_KEY
,
propClsName
);
if
(
StringUtils
.
isEmpty
(
ret
))
{
ret
=
CLASSIFICATION_NAME_DELIMITER
+
classificationName
+
CLASSIFICATION_NAME_DELIMITER
;
}
else
{
ret
=
ret
+
classificationName
+
CLASSIFICATION_NAME_DELIMITER
;
}
return
ret
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
0e53c3ee
...
...
@@ -2086,7 +2086,13 @@ public class EntityGraphMapper {
traitNames
.
remove
(
classificationName
);
setClassificationNames
(
entityVertex
,
traitNames
);
// update 'TRAIT_NAMES_PROPERTY_KEY' property
entityVertex
.
removePropertyValue
(
TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
// update 'CLASSIFICATION_NAMES_KEY' property
entityVertex
.
removeProperty
(
CLASSIFICATION_NAMES_KEY
);
entityVertex
.
setProperty
(
CLASSIFICATION_NAMES_KEY
,
getClassificationNamesString
(
traitNames
));
updateModificationMetadata
(
entityVertex
);
...
...
@@ -2140,30 +2146,21 @@ public class EntityGraphMapper {
private
void
addToClassificationNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
AtlasGraphUtilsV2
.
addEncodedProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
String
clsNames
=
entityVertex
.
getProperty
(
CLASSIFICATION_NAMES_KEY
,
String
.
class
);
clsNames
=
StringUtils
.
isEmpty
(
clsNames
)
?
CLASSIFICATION_NAME_DELIMITER
+
classificationName
:
clsNames
+
classificationName
;
String
delimitedClassificationNames
=
entityVertex
.
getProperty
(
CLASSIFICATION_NAMES_KEY
,
String
.
class
);
clsNames
=
clsNames
+
CLASSIFICATION_NAME_DELIMITER
;
if
(
StringUtils
.
isEmpty
(
delimitedClassificationNames
))
{
delimitedClassificationNames
=
CLASSIFICATION_NAME_DELIMITER
+
classificationName
+
CLASSIFICATION_NAME_DELIMITER
;
}
else
{
delimitedClassificationNames
=
delimitedClassificationNames
+
classificationName
+
CLASSIFICATION_NAME_DELIMITER
;
}
entityVertex
.
setProperty
(
CLASSIFICATION_NAMES_KEY
,
cls
Names
);
entityVertex
.
setProperty
(
CLASSIFICATION_NAMES_KEY
,
delimitedClassification
Names
);
}
private
void
setClassificationNames
(
AtlasVertex
entityVertex
,
List
<
String
>
traitNames
)
{
if
(
entityVertex
!=
null
)
{
entityVertex
.
removeProperty
(
TRAIT_NAMES_PROPERTY_KEY
);
entityVertex
.
removeProperty
(
CLASSIFICATION_NAMES_KEY
);
private
String
getClassificationNamesString
(
List
<
String
>
traitNames
)
{
String
ret
=
StringUtils
.
join
(
traitNames
,
CLASSIFICATION_NAME_DELIMITER
);
for
(
String
traitName
:
traitNames
)
{
AtlasGraphUtilsV2
.
addEncodedProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
traitName
);
}
String
clsNames
=
StringUtils
.
join
(
traitNames
,
CLASSIFICATION_NAME_DELIMITER
);
clsNames
=
StringUtils
.
isEmpty
(
clsNames
)
?
clsNames
:
CLASSIFICATION_NAME_DELIMITER
+
clsNames
+
CLASSIFICATION_NAME_DELIMITER
;
entityVertex
.
setProperty
(
CLASSIFICATION_NAMES_KEY
,
clsNames
);
}
return
StringUtils
.
isEmpty
(
ret
)
?
ret
:
CLASSIFICATION_NAME_DELIMITER
+
ret
+
CLASSIFICATION_NAME_DELIMITER
;
}
public
void
updateClassifications
(
EntityMutationContext
context
,
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasBaseException
{
...
...
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