[ 
https://issues.apache.org/jira/browse/HIVE-19041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16470664#comment-16470664
 ] 

Vihang Karajgaonkar edited comment on HIVE-19041 at 5/10/18 4:31 PM:
---------------------------------------------------------------------

Hi [~mi...@cloudera.com] Thanks for the review. The M* classes are used to map 
the database results into java objects. These are relatively short lived. I am 
not sure how much of an advantage would there be to intern these fields since 
they generally go out of scope very soon. Here is one example. You can see 
these objects get created and destroyed within the scope of one method.
{noformat}
List<Object> toPersist = new ArrayList<>();
      for (Partition part : parts) {
        if (!part.getTableName().equals(tblName) || 
!part.getDbName().equals(dbName)) {
          throw new MetaException("Partition does not belong to target table "
              + dbName + "." + tblName + ": " + part);
        }
        MPartition mpart = convertToMPart(part, true);
        toPersist.add(mpart);
        int now = (int)(System.currentTimeMillis()/1000);
        if (tabGrants != null) {
          for (MTablePrivilege tab: tabGrants) {
            toPersist.add(new MPartitionPrivilege(tab.getPrincipalName(),
                tab.getPrincipalType(), mpart, tab.getPrivilege(), now,
                tab.getGrantor(), tab.getGrantorType(), tab.getGrantOption()));
          }
        }

        if (tabColumnGrants != null) {
          for (MTableColumnPrivilege col : tabColumnGrants) {
            toPersist.add(new MPartitionColumnPrivilege(col.getPrincipalName(),
                col.getPrincipalType(), mpart, col.getColumnName(), 
col.getPrivilege(),
                now, col.getGrantor(), col.getGrantorType(), 
col.getGrantOption()));
          }
        }
      }
      if (CollectionUtils.isNotEmpty(toPersist)) {
        pm.makePersistentAll(toPersist);
        pm.flush();
      }

      success = commitTransaction();
{noformat}


was (Author: vihangk1):
Hi [~mi...@cloudera.com] Thanks for the review. The M* classes are used to map 
the database results into java objects. These are relatively short lived. I am 
not sure how much of an advantage would there be to intern these fields since 
they generally go out of scope very soon. Here is one example. You can see 
these objects get created and destroyed with the function of one method.

{noformat}
List<Object> toPersist = new ArrayList<>();
      for (Partition part : parts) {
        if (!part.getTableName().equals(tblName) || 
!part.getDbName().equals(dbName)) {
          throw new MetaException("Partition does not belong to target table "
              + dbName + "." + tblName + ": " + part);
        }
        MPartition mpart = convertToMPart(part, true);
        toPersist.add(mpart);
        int now = (int)(System.currentTimeMillis()/1000);
        if (tabGrants != null) {
          for (MTablePrivilege tab: tabGrants) {
            toPersist.add(new MPartitionPrivilege(tab.getPrincipalName(),
                tab.getPrincipalType(), mpart, tab.getPrivilege(), now,
                tab.getGrantor(), tab.getGrantorType(), tab.getGrantOption()));
          }
        }

        if (tabColumnGrants != null) {
          for (MTableColumnPrivilege col : tabColumnGrants) {
            toPersist.add(new MPartitionColumnPrivilege(col.getPrincipalName(),
                col.getPrincipalType(), mpart, col.getColumnName(), 
col.getPrivilege(),
                now, col.getGrantor(), col.getGrantorType(), 
col.getGrantOption()));
          }
        }
      }
      if (CollectionUtils.isNotEmpty(toPersist)) {
        pm.makePersistentAll(toPersist);
        pm.flush();
      }

      success = commitTransaction();
{noformat}

> Thrift deserialization of Partition objects should intern fields
> ----------------------------------------------------------------
>
>                 Key: HIVE-19041
>                 URL: https://issues.apache.org/jira/browse/HIVE-19041
>             Project: Hive
>          Issue Type: Improvement
>          Components: Metastore
>    Affects Versions: 3.0.0, 2.3.2
>            Reporter: Vihang Karajgaonkar
>            Assignee: Vihang Karajgaonkar
>            Priority: Major
>         Attachments: HIVE-19041.01.patch, HIVE-19041.02.patch, 
> HIVE-19041.03.patch, HIVE-19041.04.patch
>
>
> When a client is creating large number of partitions, the thrift objects are 
> deserialized into Partition objects. The read method of these objects does 
> not intern the inputformat, location, outputformat which cause large number 
> of duplicate Strings in the HMS memory. We should intern these objects while 
> deserialization to reduce memory pressure. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to