/** * There are many places where "duplicate" Read/WriteEnity objects are added. The way this was * initially implemented, the duplicate just replaced the previous object. * (work.getOutputs() is a Set and WriteEntity#equals() relies on name) * This may be benign for ReadEntity and perhaps was benign for WriteEntity before WriteType was * added. Now that WriteEntity has a WriteType it replaces it with one with possibly different * {@link org.apache.hadoop.hive.ql.hooks.WriteEntity.WriteType}. It's hard to imagine * how this is desirable. * * As of HIVE-14993, WriteEntity with different WriteType must be considered different. * So WriteEntity created in DDLTask cause extra output in golden files, but only because * DDLTask sets a different WriteType for the same Entity. * * In the spirit of bug-for-bug compatibility, this method ensures we only add new * WriteEntity if it's really new. * * @return {@code true} if item was added */ static boolean addIfAbsentByName(WriteEntity newWriteEntity, Set<WriteEntity> outputs) { for(WriteEntity writeEntity : outputs) { if(writeEntity.getName().equalsIgnoreCase(newWriteEntity.getName())) { LOG.debug("Ignoring request to add {} because {} is present", newWriteEntity.toStringDetail(), writeEntity.toStringDetail()); return false; } } outputs.add(newWriteEntity); return true; } private boolean addIfAbsentByName(WriteEntity newWriteEntity) {
/** * There are many places where "duplicate" Read/WriteEnity objects are added. The way this was * initially implemented, the duplicate just replaced the previous object. * (work.getOutputs() is a Set and WriteEntity#equals() relies on name) * This may be benign for ReadEntity and perhaps was benign for WriteEntity before WriteType was * added. Now that WriteEntity has a WriteType it replaces it with one with possibly different * {@link org.apache.hadoop.hive.ql.hooks.WriteEntity.WriteType}. It's hard to imagine * how this is desirable. * * As of HIVE-14993, WriteEntity with different WriteType must be considered different. * So WriteEntity create in DDLTask cause extra output in golden files, but only because * DDLTask sets a different WriteType for the same Entity. * * In the spirit of bug-for-bug compatibility, this method ensures we only add new * WriteEntity if it's really new. * * @return {@code true} if item was added */ static boolean addIfAbsentByName(WriteEntity newWriteEntity, Set<WriteEntity> outputs) { for(WriteEntity writeEntity : outputs) { if(writeEntity.getName().equalsIgnoreCase(newWriteEntity.getName())) { LOG.debug("Ignoring request to add " + newWriteEntity.toStringDetail() + " because " + writeEntity.toStringDetail() + " is present"); return false; } } outputs.add(newWriteEntity); return true; } private boolean addIfAbsentByName(WriteEntity newWriteEntity) {