Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #12603: [6.2.x] optimizing directory performances by improving performances of the Domain Driver Manager #1167

Merged
merged 2 commits into from Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -38,9 +38,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toMap;
import static org.silverpeas.core.persistence.jdbc.sql.JdbcSqlExecutorProvider.getJdbcSqlExecutor;

/**
Expand Down Expand Up @@ -702,6 +706,39 @@ public static <I, T> Map<I, List<T>> executeBySplittingOn(final Collection<I> di
return result;
}

/**
* Split executor.
* @param <I> the type of list of discriminant data.
* @param <T> the type of the entity into result.
* @param discriminantData a discriminant list of data.
* @return a stream between given discriminant identifiers and the corresponding data.
* @throws java.sql.SQLException on SQL error.
*/
public static <I, T> Stream<T> streamBySplittingOn(final Collection<I> discriminantData,
final SplitListProcess<I, List<T>> process) throws SQLException {
Stream<T> result = Stream.empty();
for (Collection<I> d : CollectionUtil.split(discriminantData, SPLIT_BATCH)) {
result = Stream.concat(result, process.execute(d).stream());
}
return result;
}

/**
* Split executor giving a result sorted exactly like the discriminantData parameter is sorted.
* @param <I> the type of list of discriminant data.
* @param <T> the type of the entity into result.
* @param discriminantData a discriminant list of data.
* @param idGetter permits to get the id from T entity in order to sort the result.
* @return a stream between given discriminant identifiers and the corresponding data.
* @throws java.sql.SQLException on SQL error.
*/
public static <I, T> Stream<T> streamBySplittingOn(final Collection<I> discriminantData,
final SplitListProcess<I, List<T>> process, Function<T, I> idGetter) throws SQLException {
final Map<I, T> indexedResult = streamBySplittingOn(discriminantData, process)
.collect(toMap(idGetter, r -> r));
return discriminantData.stream().map(indexedResult::get).filter(Objects::nonNull);
}

/**
* Select executor.
* @param <R> the type of the items in the list.
Expand Down
Expand Up @@ -38,9 +38,9 @@ public interface SplitExecuteProcess<D, T> {

/**
* Processes on a slice of entire list of discriminant data.
* @param discriminantSlice a slice of discriminant data.
* @param result the result which has to be be filled.
* @param idBatch a slice of discriminant data.
* @param result the result which has to be filled.
* @throws SQLException on SQL errors.
*/
void execute(final Collection<D> discriminantSlice, final Map<D, List<T>> result) throws SQLException;
void execute(final Collection<D> idBatch, final Map<D, List<T>> result) throws SQLException;
}
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2000 - 2021 Silverpeas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* As a special exception to the terms and conditions of version 3.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* Open Source Software ("FLOSS") applications as described in Silverpeas's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* "https://www.silverpeas.org/legal/floss_exception.html"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.silverpeas.core.persistence.jdbc.sql;

import java.sql.SQLException;
import java.util.Collection;

/**
* Split Processor on discriminant data used for list queries.
* @param <D> the type of list of discriminant data.
* @param <T> the type of the entity into result.
*/
@FunctionalInterface
public interface SplitListProcess<D, T> {

/**
* Processes on a slice of entire list of discriminant data.
* @param idBatch a slice of discriminant data.
* @throws SQLException on SQL errors.
*/
T execute(final Collection<D> idBatch) throws SQLException;
}
Expand Up @@ -571,6 +571,11 @@ public UserFull getUserFull(final String domainId, final String specificId) {
return null;
}

@Override
public List<UserFull> getUserFulls(final Collection<String> userIds) throws AdminException {
return null;
}

@Override
public String addUser(final UserDetail userDetail) {
return null;
Expand Down
Expand Up @@ -179,6 +179,11 @@ public UserFull getUserFull(final String sUserId) {
return null;
}

@Override
public List<UserFull> getUserFulls(final Collection<String> userIds) {
return null;
}

@Override
public UserDetail getUserDetail(final String sUserId) {
UserDetail user = new UserDetail();
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.silverpeas.core.admin.user.model.UserFull;
import org.silverpeas.core.util.SettingBundle;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -226,15 +227,35 @@ private ActionConstants() {

void updateUserDetail(UserDetail user) throws AdminException;

/**
* Retrieves common user information from database.
* @param specificId The user id as stored in the database.
* @return The full User object that contain ALL user information.
*/
UserDetail getUser(String specificId) throws AdminException;

/**
* Retrieve user information from database
* @param specificId The user id as stored in the database
* @return The full User object that contain ALL user informations
* Retrieves the common user information from database against the given identifiers.
* @param specificIds The user ids as stored in the database.
* @return a list of common User object.
*/
List<UserDetail> listUsers(Collection<String> specificIds) throws AdminException;

/**
* Retrieves common user information from database with the additional data.
* @param specificId The user id as stored in the database.
* @return The full User object that contain ALL user information.
*/
UserFull getUserFull(String specificId) throws AdminException;

/**
* Retrieves common user information with the additional data from database against the given
* identifiers.
* @param specificIds The user ids as stored in the database.
* @return a list of full User object.
*/
List<UserFull> listUserFulls(Collection<String> specificIds) throws AdminException;

String[] getUserMemberGroupIds(String specificId) throws AdminException;

UserDetail[] getAllUsers() throws AdminException;
Expand Down