> On Sept. 13, 2017, 8:48 p.m., Vamsee Yarlagadda wrote: > > sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java > > Lines 1798-1801 (original), 1816-1819 (patched) > > <https://reviews.apache.org/r/62261/diff/3/?file=1820454#file1820454line1831> > > > > Asking for all groups at once could save multiple hops to the database. > > > > ```bash > > private Set<String> getRoleNamesForGroupsCore(PersistenceManager pm, > > Set<String> groups) { > > Query query = pm.newQuery(MSentryGroup.class); > > query.setFilter(":p1.contains(this.groupName)"); > > List<MSentryGroup> sentryGroups = (List) > > query.execute(groups.toArray()); > > if (sentryGroups.isEmpty()) { > > return Collections.emptySet(); > > } > > Set<String> result = new HashSet<>(); > > for (MSentryGroup sentryGroup : sentryGroups) { > > for (MSentryRole role : sentryGroup.getRoles()) { > > result.add(role.getRoleName()); > > } > > } > > return result; > > } > > ```
I tried this approach and don't see any benefit - in fact it is slightly worse. More over it breaks the semantics where exception is thrown where group isn't found. - Alexander ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/62261/#review185339 ----------------------------------------------------------- On Sept. 13, 2017, 3:49 a.m., Alexander Kolbasov wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/62261/ > ----------------------------------------------------------- > > (Updated Sept. 13, 2017, 3:49 a.m.) > > > Review request for sentry, Arjun Mishra, Brian Towles, Misha Dmitriev, Na Li, > Sergio Pena, and Vamsee Yarlagadda. > > > Bugs: SENTRY-1937 > https://issues.apache.org/jira/browse/SENTRY-1937 > > > Repository: sentry > > > Description > ------- > > SENTRY-1937 Optimize performance for listing sentry roles by group name > > > Diffs > ----- > > > sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java > 01a7c830f548d41062fb3bbd0a81f71514585aa5 > > > Diff: https://reviews.apache.org/r/62261/diff/3/ > > > Testing > ------- > > > Thanks, > > Alexander Kolbasov > >
