private List<HiveLockObj> getLockObjects(QueryPlan plan, Database db,
                                           Table t, Partition p,
                                           HiveLockMode mode)
      throws LockException {
    List<HiveLockObj> locks = new LinkedList<HiveLockObj>();

    HiveLockObject.HiveLockObjectData lockData =
      new HiveLockObject.HiveLockObjectData(plan.getQueryId(),
                             String.valueOf(System.currentTimeMillis()),
                             "IMPLICIT",
                             plan.getQueryStr(),
                             conf);

    if (db != null) {
      locks.add(new HiveLockObj(new HiveLockObject(db.getName(), lockData),
          mode));
      return locks;
    }

    if (t != null) {
      locks.add(new HiveLockObj(new HiveLockObject(t, lockData), mode));
      mode = HiveLockMode.SHARED;
      locks.add(new HiveLockObj(new HiveLockObject(t.getDbName(), lockData), mode));
      return locks;
    }

    if (p != null) {
      if (!(p instanceof DummyPartition)) {
        locks.add(new HiveLockObj(new HiveLockObject(p, lockData), mode));
      }

      // All the parents are locked in shared mode
      mode = HiveLockMode.SHARED;

      // For dummy partitions, only partition name is needed
      String name = p.getName();

      if (p instanceof DummyPartition) {
        name = p.getName().split("@")[2];
      }

      StringBuilder partialName = new StringBuilder();
      String[] partns = name.split("/");
      int len = p instanceof DummyPartition ? partns.length : partns.length - 1;
      Map<String, String> partialSpec = new LinkedHashMap<String, String>();
      for (int idx = 0; idx < len; idx++) {
        String partn = partns[idx];
        partialName.append(partn);
        String[] nameValue = partn.split("=");
        assert(nameValue.length == 2);
        partialSpec.put(nameValue[0], nameValue[1]);
        DummyPartition par = new DummyPartition(p.getTable(), 
          p.getTable().getDbName() 
            + "/" + FileUtils.escapePathName(p.getTable().getTableName()).toLowerCase() 
            + "/" + partialName,
          partialSpec);
        locks.add(new HiveLockObj(new HiveLockObject(par, lockData), mode));
        partialName.append("/");
      }

      locks.add(new HiveLockObj(new HiveLockObject(p.getTable(), lockData), mode));
      locks.add(new HiveLockObj(new HiveLockObject(p.getTable().getDbName(), lockData), mode));
    }
    return locks;
  }
Dedup the list of lock objects so that there is only one lock per table/partition.
If there is both a shared and exclusive lock for the same object, this will deduped
to just a single exclusive lock.  Package level so that the unit tests
can access it.  Not intended for use outside this class.
@param lockObjects
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java