Example usage for com.google.common.collect Multimap putAll

List of usage examples for com.google.common.collect Multimap putAll

Introduction

In this page you can find the example usage for com.google.common.collect Multimap putAll.

Prototype

boolean putAll(@Nullable K key, Iterable<? extends V> values);

Source Link

Document

Stores a key-value pair in this multimap for each of values , all using the same key, key .

Usage

From source file:com.sam.moca.web.console.ConsoleModel.java

/**
 * Get the list of cluster hosts and URLs.
 * //  www.jav  a  2  s  .  c  om
 * @param Map<String,String[]> parameters The parameters passed on the
 *            request.
 * @return
 */
public WebResults<?> getClusterRoles(Map<String, String[]> parameters) {
    WebResults<Multimap<InstanceUrl, RoleDefinition>> results = new WebResults<Multimap<InstanceUrl, RoleDefinition>>();

    ClusterRoleManager manager = ServerUtils.globalAttribute(ClusterRoleManager.class);

    Multimap<Node, RoleDefinition> multiMap = manager.getClusterRoles();
    Map<Node, InstanceUrl> urls = _clusterAdmin.getKnownNodes();

    Multimap<InstanceUrl, RoleDefinition> urlRoleMap = HashMultimap.create();

    for (Entry<Node, Collection<RoleDefinition>> entry : multiMap.asMap().entrySet()) {
        urlRoleMap.putAll(urls.get(entry.getKey()), entry.getValue());
    }

    results.add(urlRoleMap);
    return results;
}

From source file:org.eclipse.xtext.serializer.analysis.ContextPDAProvider.java

@Override
public SerializationContextMap<Pda<ISerState, RuleCall>> getContextPDAs(Grammar grammar) {
    Builder<Pda<ISerState, RuleCall>> result = SerializationContextMap.<Pda<ISerState, RuleCall>>builder();
    SerializationContextMap<Pda<ISerState, RuleCall>> grammarPDAs = grammarPdaProvider.getGrammarPDAs(grammar);
    Multimap<Action, SerializerPDA> actionPdas = ArrayListMultimap.create();
    Multimap<Action, ISerializationContext> actionContexts = LinkedHashMultimap.create();
    Map<ParserRule, Integer> indexedRules = indexRules(grammar);
    for (SerializationContextMap.Entry<Pda<ISerState, RuleCall>> e : grammarPDAs.values()) {
        List<ISerializationContext> contexts = e.getContexts();
        Pda<ISerState, RuleCall> pda = e.getValue();
        List<ISerState> actions = Lists.newArrayList();
        for (ISerState state : nfaUtil.collect(pda)) {
            if (GrammarUtil.isAssignedAction(state.getGrammarElement())) {
                actions.add(state);//from  w ww . ja v  a  2  s.c om
            }
        }
        if (actions.isEmpty()) {
            Pda<ISerState, RuleCall> filtered = filterUnneededUnassignedRuleCalls(pda, indexedRules);
            result.put(contexts, filtered);
        } else {
            try {
                SerializerPDA rulePda = extract(pda.getStop());
                Pda<ISerState, RuleCall> filtered = filterUnneededUnassignedRuleCalls(rulePda, indexedRules);
                result.put(contexts, filtered);
                for (ISerState state : actions) {
                    Action action = (Action) state.getGrammarElement();
                    SerializerPDA actionPda = extract(state);
                    actionPdas.put(action, actionPda);
                    actionContexts.putAll(action, contexts);
                }
            } catch (Exception x) {
                LOG.error("Error extracting PDA for action in context '" + contexts + "': " + x.getMessage(),
                        x);
            }
        }
    }
    for (Map.Entry<Action, Collection<SerializerPDA>> action : actionPdas.asMap().entrySet()) {
        SerializerPDA merged = merge(new ActionContext(null, action.getKey()), action.getValue());
        Set<Set<Parameter>> parameterPermutations = Sets.newLinkedHashSet();
        for (ISerializationContext container : actionContexts.get(action.getKey())) {
            parameterPermutations.add(container.getEnabledBooleanParameters());
        }
        // for (IContext container : actionContexts.get(action.getKey())) {
        for (Set<Parameter> parameters : parameterPermutations) {
            ISerializationContext context = new ActionContext( /* container */ null, action.getKey());
            if (!parameters.isEmpty())
                context = new SerializationContext.ParameterValueContext(context, parameters);
            Pda<ISerState, RuleCall> filtered = filterUnneededUnassignedRuleCalls(merged, indexedRules);
            result.put(context, filtered);
        }
        // }
    }
    return result.create();
}

From source file:org.crypto.sse.EMM2Lev.java

public static RH2Lev constructEMMPar(final byte[] key, final Multimap<String, String> lookup,
        final int bigBlock, final int smallBlock, final int dataSize)
        throws InterruptedException, ExecutionException, IOException {

    final Multimap<String, byte[]> dictionary = ArrayListMultimap.create();

    for (int i = 0; i < dataSize; i++) {
        free.add(i);//from   w w w  .  j av a  2  s .  c  o m
    }
    random.setSeed(CryptoPrimitives.randomSeed(16));

    List<String> listOfKeyword = new ArrayList<String>(lookup.keySet());
    int threads = 0;
    if (Runtime.getRuntime().availableProcessors() > listOfKeyword.size()) {
        threads = listOfKeyword.size();
    } else {
        threads = Runtime.getRuntime().availableProcessors();
    }

    ExecutorService service = Executors.newFixedThreadPool(threads);
    ArrayList<String[]> inputs = new ArrayList<String[]>(threads);

    final Map<Integer, String> concurrentMap = new ConcurrentHashMap<Integer, String>();
    for (int i = 0; i < listOfKeyword.size(); i++) {
        concurrentMap.put(i, listOfKeyword.get(i));
    }

    for (int j = 0; j < threads; j++) {
        service.execute(new Runnable() {
            @SuppressWarnings("unused")
            @Override
            public void run() {

                while (concurrentMap.keySet().size() > 0) {
                    Set<Integer> possibleValues = concurrentMap.keySet();

                    Random rand = new Random();

                    int temp = rand.nextInt(possibleValues.size());

                    List<Integer> listOfPossibleKeywords = new ArrayList<Integer>(possibleValues);

                    // set the input as randomly selected from the remaining
                    // possible keys
                    String[] input = { concurrentMap.get(listOfPossibleKeywords.get(temp)) };

                    // remove the key
                    concurrentMap.remove(listOfPossibleKeywords.get(temp));

                    try {

                        Multimap<String, byte[]> output = setup(key, input, lookup, bigBlock, smallBlock,
                                dataSize);
                        Set<String> keys = output.keySet();

                        for (String k : keys) {
                            dictionary.putAll(k, output.get(k));
                        }
                    } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
                            | NoSuchPaddingException | IOException | InvalidAlgorithmParameterException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    service.shutdown();

    // Blocks until all tasks have completed execution after a shutdown
    // request
    service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);

    return new RH2Lev(dictionary, array);
}

From source file:uk.ac.ebi.metabolomes.webservices.EUtilsWebServiceConnection.java

/**
 * Uses ESummary to submit a list of uk.ac.ebi.metabolomes.webservices.pubchem substance ids, for which cross references will be retrieved (taken from
 * actual cross references in uk.ac.ebi.metabolomes.webservices.pubchem + synonyms that comply with certain regexps).
 * /*from www .jav  a 2  s .  co  m*/
 * @param pubchemSubstanceIds
 * @return multimap that links substance ids to crossreferences. 
 */
public Multimap<String, CrossReference> getExternalIdentifiersForPubChemSubstances(
        Collection<String> pubchemSubstanceIds) throws WebServiceException {
    checkNumberOfSubmittedEntries(pubchemSubstanceIds);
    WebResource epostWebRes = client.resource(baseURL + "epost.fcgi");
    MultivaluedMap queryParamsEPost = new MultivaluedMapImpl();
    queryParamsEPost.add("db", "pcsubstance");
    /*for (String subsId : pubchemSubstanceIds) {
    queryParamsEPost.add("id", subsId);
    }*/
    queryParamsEPost.add("id", StringUtils.join(pubchemSubstanceIds, ","));
    ClientResponse respEpost = submitPost(epostWebRes, queryParamsEPost);

    if (respEpost.getStatus() != 200) {
        throw new RuntimeException(
                "Failed : HTTP error code : " + respEpost.getStatus() + " : " + respEpost.toString());
    }

    /**
     * #parse WebEnv and QueryKey
     *  $web = $1 if ($output =~ /<WebEnv>(\S+)<\/WebEnv>/);
     *  $key = $1 if ($output =~ /<QueryKey>(\d+)<\/QueryKey>/);
     */

    Multimap<String, CrossReference> res = HashMultimap.create();

    EPostResult epostRes;
    try {
        epostRes = parseEpostOutput(respEpost.getEntityInputStream());
    } catch (IOException e) {
        LOGGER.error("Could not parse Epost output ", e);
        return res;
    }
    WebResource webRes = client.resource(baseURL + "esummary.fcgi");
    MultivaluedMap queryParams = new MultivaluedMapImpl();
    queryParams.add("db", "pcsubstance");
    queryParams.add("query_key", epostRes.getQueryKey());
    queryParams.add("WebEnv", epostRes.getWebEnv());
    //for (String id : pubchemSubstanceIds) {

    //}

    ClientResponse resp = submitPost(webRes, queryParams);

    LOGGER.info("Resp: " + resp.toString());

    if (resp.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + resp.getStatus() + " : " + resp.toString());
    }

    PubChemSubstanceXMLResponseParser parser = new PubChemSubstanceXMLResponseParser();
    try {
        List<PubChemSubstanceESummaryResult> resultsParse = parser
                .parseESummaryResult(resp.getEntityInputStream());
        for (PubChemSubstanceESummaryResult pubChemSubstanceESummaryResult : resultsParse) {
            res.putAll(pubChemSubstanceESummaryResult.getId(),
                    pubChemSubstanceESummaryResult.getCrossReferences());
        }
    } catch (XMLStreamException ex) {
        LOGGER.warn("Could not parse output XML adequately... returning empty result", ex);
    }
    return res;

}

From source file:org.crypto.sse.RR2Lev.java

public static RR2Lev constructEMMPar(final byte[] key, final Multimap<String, String> lookup,
        final int bigBlock, final int smallBlock, final int dataSize)
        throws InterruptedException, ExecutionException, IOException {

    final Multimap<String, byte[]> dictionary = ArrayListMultimap.create();

    random.setSeed(CryptoPrimitives.randomSeed(16));

    for (int i = 0; i < dataSize; i++) {
        // initialize all buckets with random values
        free.add(i);//from  ww  w .  j  a  va  2  s. co  m
    }

    List<String> listOfKeyword = new ArrayList<String>(lookup.keySet());
    int threads = 0;
    if (Runtime.getRuntime().availableProcessors() > listOfKeyword.size()) {
        threads = listOfKeyword.size();
    } else {
        threads = Runtime.getRuntime().availableProcessors();
    }

    ExecutorService service = Executors.newFixedThreadPool(threads);
    ArrayList<String[]> inputs = new ArrayList<String[]>(threads);

    final Map<Integer, String> concurrentMap = new ConcurrentHashMap<Integer, String>();
    for (int i = 0; i < listOfKeyword.size(); i++) {
        concurrentMap.put(i, listOfKeyword.get(i));
    }

    for (int j = 0; j < threads; j++) {
        service.execute(new Runnable() {
            @SuppressWarnings("unused")
            @Override
            public void run() {

                while (concurrentMap.keySet().size() > 0) {
                    // write code
                    Set<Integer> possibleValues = concurrentMap.keySet();

                    Random rand = new Random();

                    int temp = rand.nextInt(possibleValues.size());

                    List<Integer> listOfPossibleKeywords = new ArrayList<Integer>(possibleValues);

                    // set the input as randomly selected from the remaining
                    // possible keys
                    String[] input = { concurrentMap.get(listOfPossibleKeywords.get(temp)) };

                    // remove the key
                    concurrentMap.remove(listOfPossibleKeywords.get(temp));

                    try {

                        Multimap<String, byte[]> output = setup(key, input, lookup, bigBlock, smallBlock,
                                dataSize);
                        Set<String> keys = output.keySet();

                        for (String k : keys) {
                            dictionary.putAll(k, output.get(k));
                        }
                    } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
                            | NoSuchPaddingException | IOException | InvalidAlgorithmParameterException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    // Make sure executor stops
    service.shutdown();

    // Blocks until all tasks have completed execution after a shutdown
    // request
    service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);

    return new RR2Lev(dictionary, array);
}

From source file:org.artifactory.bintray.BintrayServiceImpl.java

private Multimap<String, String> getMapFromUploadInfoMultiSet(Set<Map<String, Collection<String>>> elements) {
    Multimap<String, String> elementsMap = HashMultimap.create();
    if (CollectionUtils.isNullOrEmpty(elements)) {
        return elementsMap;
    }/*from  ww  w  .j a v a 2 s  .  c  o  m*/
    for (Map<String, Collection<String>> element : elements) {
        String key = element.keySet().iterator().next();
        Collection<String> values = element.get(key);
        elementsMap.putAll(key, values);
    }
    return elementsMap;
}

From source file:com.ning.metrics.collector.processing.db.InMemoryCounterCacheProcessor.java

@Inject
public InMemoryCounterCacheProcessor(final CollectorConfig config, final CounterStorage counterStorage) {

    this.executorShutdownTimeOut = config.getSpoolWriterExecutorShutdownTime();
    this.counterEventDBFlushTime = config.getCounterEventMemoryFlushTime();

    this.executorService = new LoggingExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS,
            new ArrayBlockingQueue<Runnable>(2), new NamedThreadFactory("CounterEvents-Storage-Threads"),
            new ThreadPoolExecutor.CallerRunsPolicy());

    this.counterEventsBySubscriptionId = CacheBuilder.newBuilder()
            .expireAfterAccess(counterEventDBFlushTime.getPeriod(), counterEventDBFlushTime.getUnit())
            .maximumWeight(config.getMaxCounterEventFlushCacheCount())
            .weigher(new Weigher<String, Queue<CounterEventData>>() {
                @Override//w  w  w. j av  a  2 s.  c o  m
                public int weigh(String key, Queue<CounterEventData> value) {
                    return value.size();
                }
            }).removalListener(
                    RemovalListeners.asynchronous(new RemovalListener<String, Queue<CounterEventData>>() {

                        @Override
                        public void onRemoval(
                                RemovalNotification<String, Queue<CounterEventData>> removalNotification) {
                            if (!Objects.equal(removalNotification.getCause(), RemovalCause.REPLACED)
                                    && !Objects.equal(null, removalNotification.getValue())
                                    && !removalNotification.getValue().isEmpty()) {
                                Multimap<String, CounterEventData> multimap = ArrayListMultimap.create();
                                List<CounterEventData> counterEventDataList = Lists
                                        .newArrayList(removalNotification.getValue());
                                removalNotification.getValue().clear();
                                Map<String, CounterEventData> groupMap = new ConcurrentHashMap<String, CounterEventData>();

                                for (CounterEventData counterEventData : counterEventDataList) {
                                    CounterEventData groupedData = groupMap
                                            .get(counterEventData.getUniqueIdentifier()
                                                    + counterEventData.getFormattedDate());

                                    if (Objects.equal(null, groupedData)) {
                                        groupMap.put(
                                                counterEventData.getUniqueIdentifier()
                                                        + counterEventData.getFormattedDate(),
                                                counterEventData);
                                        continue;
                                    }

                                    groupedData.mergeCounters(counterEventData.getCounters());
                                    groupMap.put(counterEventData.getUniqueIdentifier()
                                            + counterEventData.getFormattedDate(), groupedData);
                                }

                                multimap.putAll(removalNotification.getKey(), groupMap.values());
                                counterStorage.bufferMetrics(multimap);
                            }
                        }
                    }, this.executorService))
            .recordStats().build();

}

From source file:org.crypto.sse.RH2Lev.java

public static RH2Lev constructEMMPar(final byte[] key, final Multimap<String, String> lookup,
        final int bigBlock, final int smallBlock, final int dataSize)
        throws InterruptedException, ExecutionException, IOException {

    final Multimap<String, byte[]> dictionary = ArrayListMultimap.create();

    for (int i = 0; i < dataSize; i++) {
        free.add(i);/*from   w  w w . j  a  v a 2s  . c  o  m*/
    }
    random.setSeed(CryptoPrimitives.randomSeed(16));

    List<String> listOfKeyword = new ArrayList<String>(lookup.keySet());
    int threads = 0;
    if (Runtime.getRuntime().availableProcessors() > listOfKeyword.size()) {
        threads = listOfKeyword.size();
    } else {
        threads = Runtime.getRuntime().availableProcessors();
    }

    ExecutorService service = Executors.newFixedThreadPool(threads);
    ArrayList<String[]> inputs = new ArrayList<String[]>(threads);

    final Map<Integer, String> concurrentMap = new ConcurrentHashMap<Integer, String>();
    for (int i = 0; i < listOfKeyword.size(); i++) {
        concurrentMap.put(i, listOfKeyword.get(i));
    }

    for (int j = 0; j < threads; j++) {
        service.execute(new Runnable() {
            @SuppressWarnings("unused")
            @Override
            public void run() {

                while (concurrentMap.keySet().size() > 0) {

                    Random rand = new Random();
                    String[] input = { "" };
                    synchronized (concurrentMap) {
                        Set<Integer> possibleValues = concurrentMap.keySet();
                        int temp = rand.nextInt(possibleValues.size());
                        List<Integer> listOfPossibleKeywords = new ArrayList<Integer>(possibleValues);
                        // set the input as randomly selected from the remaining
                        // possible keys
                        input[0] = concurrentMap.get(listOfPossibleKeywords.get(temp));
                        // remove the key
                        concurrentMap.remove(listOfPossibleKeywords.get(temp));
                    }

                    try {

                        Multimap<String, byte[]> output = setup(key, input, lookup, bigBlock, smallBlock,
                                dataSize);
                        Set<String> keys = output.keySet();

                        for (String k : keys) {
                            dictionary.putAll(k, output.get(k));
                        }
                    } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
                            | NoSuchPaddingException | IOException | InvalidAlgorithmParameterException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    service.shutdown();

    // Blocks until all tasks have completed execution after a shutdown
    // request
    service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);

    return new RH2Lev(dictionary, array);
}

From source file:org.corpus_tools.peppermodules.paula.Salt2PAULAMapper.java

/**
 * Maps audio data as data source. When audio data are connected to tokens,
 * a span for each connection is created and annotated with an audio
 * annotation referencing the audio file. When no Token is connected to the
 * audio source, a span is created for all tokens and an audio annotation is
 * added to that span./*  w  w  w.  j  a v a  2s  . c o  m*/
 */
public void mapSMedialDS() {
    Multimap<SMedialDS, SToken> map = LinkedHashMultimap.create();
    if ((getDocument().getDocumentGraph().getMedialRelations() != null)
            && (getDocument().getDocumentGraph().getMedialRelations().size() > 0)) {
        /**
         * Create a markable file which addresses all tokens, which have
         * references to the SAudioDS
         */
        for (SMedialRelation rel : getDocument().getDocumentGraph().getMedialRelations()) {
            map.put(rel.getTarget(), rel.getSource());
        }
    } else {
        if ((getDocument().getDocumentGraph().getMedialDSs() != null)
                && (getDocument().getDocumentGraph().getMedialDSs().size() > 0))
            for (SMedialDS audioDS : getDocument().getDocumentGraph().getMedialDSs()) {
                map.putAll(audioDS, getDocument().getDocumentGraph().getTokens());
            }
    }
    if (map.size() > 0) {
        StringBuffer fileName = new StringBuffer();
        fileName.append(getResourceURI().toFileString());
        if (!fileName.toString().endsWith("/")) {
            fileName.append("/");
        }
        fileName.append(getDocument().getName());
        fileName.append(".");
        fileName.append(PAULA_TYPE.MARK.getFileInfix());
        fileName.append(".");
        fileName.append("audio");
        fileName.append(".");
        fileName.append(PepperModule.ENDING_XML);
        File audioMarkFile = new File(fileName.toString());

        PAULAPrinter printer = getPAULAPrinter(audioMarkFile);

        if (!printer.hasPreamble) {
            printer.printPreambel(PAULA_TYPE.MARK, "audio",
                    generateFileName(getDocument().getDocumentGraph().getTokens().get(0)));
        }

        for (SMedialDS audio : map.keySet()) {
            try {
                printer.xml.writeEmptyElement(TAG_MARK_MARK);
                if (audio.getPath().fragment() != null) {
                    printer.xml.writeAttribute(ATT_ID, checkId(audio.getPath().fragment()));
                } else {
                    printer.xml.writeAttribute(ATT_ID, audio.getId());
                }
                printer.xml.writeAttribute(ATT_HREF,
                        generateXPointer(new ArrayList<SToken>(map.get(audio)), printer.base));
            } catch (XMLStreamException e) {
                throw new PepperModuleException(Salt2PAULAMapper.this, "Cannot write in file '"
                        + audioMarkFile.getAbsolutePath() + "', because of a nested exception. ", e);
            }
        }

        /**
         * Create a feature file which addresses all tokens, which addresses
         * the audio markable file
         */
        // copy referenced files
        File audioFeatFile = new File(audioMarkFile.getAbsolutePath().replace("." + PepperModule.ENDING_XML,
                "_feat." + PepperModule.ENDING_XML));
        printer = getPAULAPrinter(audioFeatFile);
        printer.printPreambel(PAULA_TYPE.FEAT, KW_AUDIO, audioMarkFile);

        for (SMedialDS audio : getDocument().getDocumentGraph().getMedialDSs()) {
            /**
             * Copy audio file and
             */
            String target = audioMarkFile.getAbsoluteFile().getParent();
            if (!target.endsWith("/")) {
                target = target + "/";
            }
            target = target + audio.getMediaReference().lastSegment();
            File audioFile = new File(target);
            try {
                String source = audio.getMediaReference().toFileString();
                if (source == null) {
                    source = audio.getMediaReference().toString();
                }
                Files.copy(new File(source).toPath(), audioFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            } catch (IOException e) {
                throw new PepperModuleException(Salt2PAULAMapper.this,
                        "Cannot copy audio file '" + audio.getMediaReference() + "', to +'" + target + "'. ",
                        e);
            }
            /**
             * Create a feature file which addresses all tokens, which
             * addresses the audio markable file
             */
            try {
                printer.xml.writeEmptyElement(TAG_FEAT_FEAT);
                printer.xml.writeAttribute(ATT_HREF, "#" + audio.getPath().fragment());
                printer.xml.writeAttribute(ATT_FEAT_FEAT_VAL, audioFile.getName());
            } catch (XMLStreamException e) {
                throw new PepperModuleException(Salt2PAULAMapper.this, "Cannot write in file '"
                        + audioFeatFile.getAbsolutePath() + "', because of a nested exception. ", e);
            }

        }
    }
}

From source file:org.crypto.sse.RR2Lev.java

public static RR2Lev constructEMMParGMM(final byte[] key, final Multimap<String, String> lookup,
        final int bigBlock, final int smallBlock, final int dataSize)
        throws InterruptedException, ExecutionException, IOException {

    final Multimap<String, byte[]> dictionary = ArrayListMultimap.create();

    random.setSeed(CryptoPrimitives.randomSeed(16));

    for (int i = 0; i < dataSize; i++) {
        // initialize all buckets with random values
        free.add(i);//  w ww.j ava  2  s .c om
    }

    List<String> listOfKeyword = new ArrayList<String>(lookup.keySet());
    int threads = 0;
    if (Runtime.getRuntime().availableProcessors() > listOfKeyword.size()) {
        threads = listOfKeyword.size();
    } else {
        threads = Runtime.getRuntime().availableProcessors();
    }

    ExecutorService service = Executors.newFixedThreadPool(threads);
    ArrayList<String[]> inputs = new ArrayList<String[]>(threads);

    for (int i = 0; i < threads; i++) {
        String[] tmp;
        if (i == threads - 1) {
            tmp = new String[listOfKeyword.size() / threads + listOfKeyword.size() % threads];
            for (int j = 0; j < listOfKeyword.size() / threads + listOfKeyword.size() % threads; j++) {
                tmp[j] = listOfKeyword.get((listOfKeyword.size() / threads) * i + j);
            }
        } else {
            tmp = new String[listOfKeyword.size() / threads];
            for (int j = 0; j < listOfKeyword.size() / threads; j++) {

                tmp[j] = listOfKeyword.get((listOfKeyword.size() / threads) * i + j);
            }
        }
        inputs.add(i, tmp);
    }

    Printer.debugln("End of Partitionning  \n");

    List<Future<Multimap<String, byte[]>>> futures = new ArrayList<Future<Multimap<String, byte[]>>>();
    for (final String[] input : inputs) {
        Callable<Multimap<String, byte[]>> callable = new Callable<Multimap<String, byte[]>>() {
            public Multimap<String, byte[]> call() throws Exception {

                Multimap<String, byte[]> output = setup(key, input, lookup, bigBlock, smallBlock, dataSize);
                return output;
            }
        };
        futures.add(service.submit(callable));
    }

    service.shutdown();

    for (Future<Multimap<String, byte[]>> future : futures) {
        Set<String> keys = future.get().keySet();

        for (String k : keys) {
            dictionary.putAll(k, future.get().get(k));
        }

    }

    return new RR2Lev(dictionary, array);
}