atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1443: attributes with null value are not included in Atlas API response
Date Thu, 12 Jan 2017 02:34:43 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/0.7-incubating 2f4ca5549 -> 123b64803


ATLAS-1443: attributes with null value are not included in Atlas API response

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/123b6480
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/123b6480
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/123b6480

Branch: refs/heads/0.7-incubating
Commit: 123b64803724172b43caa532f9b6f7dbe3070800
Parents: 2f4ca55
Author: Sarath Subramanian <ssubramanian@hortonworks.com>
Authored: Wed Jan 11 11:24:05 2017 -0800
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Wed Jan 11 18:21:36 2017 -0800

----------------------------------------------------------------------
 .../repository/graph/TypedInstanceToGraphMapper.java    |  2 +-
 .../org/apache/atlas/typesystem/ITypedInstance.java     |  4 +++-
 .../org/apache/atlas/typesystem/persistence/Id.java     |  4 ++++
 .../typesystem/persistence/ReferenceableInstance.java   |  4 ++--
 .../atlas/typesystem/persistence/StructInstance.java    | 12 +++++++++---
 5 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/123b6480/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
index 93fd69f..92817d2 100644
--- a/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
+++ b/repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
@@ -195,7 +195,7 @@ public final class TypedInstanceToGraphMapper {
                               AttributeInfo attributeInfo, Operation operation) throws AtlasException
{
 
         final Map<String, Object> valuesMap = typedInstance.getValuesMap();
-        if ( valuesMap.containsKey(attributeInfo.name) || operation == Operation.CREATE )
{
+        if ( typedInstance.isValueSet(attributeInfo.name) || operation == Operation.CREATE
) {
 
             Object attrValue = typedInstance.get(attributeInfo.name);
             LOG.debug("Mapping attribute {} = {}", attributeInfo.name, attrValue);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/123b6480/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
index d7f4cb7..c24eb8e 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/ITypedInstance.java
@@ -83,4 +83,6 @@ public interface ITypedInstance extends IInstance {
     void setString(String attrName, String val) throws AtlasException;
 
     String getSignatureHash(MessageDigest digester) throws AtlasException;
-}
+
+    boolean isValueSet(String attrName) throws AtlasException;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/123b6480/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
index 42280d0..389b4a5 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java
@@ -289,6 +289,10 @@ public class Id implements ITypedReferenceableInstance {
         throw new AtlasException("Get/Set not supported on an Id object");
     }
 
+    public boolean isValueSet(String attrName) throws AtlasException {
+        throw new AtlasException("Attributes not set on an Id object");
+    }
+
     @Override
     public String getSignatureHash(MessageDigest digester) throws AtlasException {
         digester.update(id.getBytes(Charset.forName("UTF-8")));

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/123b6480/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
index 4e21410..328f0d7 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java
@@ -48,11 +48,11 @@ public class ReferenceableInstance extends StructInstance implements ITypedRefer
 
 
     public ReferenceableInstance(Id id, String dataTypeName, FieldMapping fieldMapping, boolean[]
nullFlags,
-            boolean[] explicitNullFlags, boolean[] bools, byte[] bytes, short[] shorts, int[]
ints, long[] longs, float[] floats, double[] doubles,
+            boolean[] explicitSets, boolean[] bools, byte[] bytes, short[] shorts, int[]
ints, long[] longs, float[] floats, double[] doubles,
             BigDecimal[] bigDecimals, BigInteger[] bigIntegers, Date[] dates, String[] strings,
             ImmutableList<Object>[] arrays, ImmutableMap<Object, Object>[] maps,
StructInstance[] structs,
             ReferenceableInstance[] referenceableInstances, Id[] ids, ImmutableMap<String,
ITypedStruct> traits) {
-        super(dataTypeName, fieldMapping, nullFlags, explicitNullFlags, bools, bytes, shorts,
ints, longs, floats, doubles, bigDecimals,
+        super(dataTypeName, fieldMapping, nullFlags, explicitSets, bools, bytes, shorts,
ints, longs, floats, doubles, bigDecimals,
                 bigIntegers, dates, strings, arrays, maps, structs, referenceableInstances,
ids);
         this.id = id;
         this.traits = traits;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/123b6480/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
index cdfaad0..9ac591a 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java
@@ -279,10 +279,10 @@ public class StructInstance implements ITypedStruct {
     public Map<String, Object> getValuesMap() throws AtlasException {
         Map<String, Object> m = new HashMap<>();
         for (String attr : fieldMapping.fields.keySet()) {
-            int pos = fieldMapping.fieldNullPos.get(attr);
-            if (  explicitSets[pos] ) {
+//            int pos = fieldMapping.fieldNullPos.get(attr);
+//            if (  explicitSets[pos] ) {
                 m.put(attr, get(attr));
-            }
+//            }
         }
         return m;
     }
@@ -774,6 +774,12 @@ public class StructInstance implements ITypedStruct {
     }
 
     @Override
+    public boolean isValueSet(final String attrName) throws AtlasException {
+        int nullPos = fieldMapping.fieldNullPos.get(attrName);
+        return explicitSets[nullPos];
+    }
+
+    @Override
     public String toShortString() {
         return String.format("struct[type=%s]", dataTypeName);
     }


Mime
View raw message