<commit_before>/*
 * This file or a portion of this file is licensed under the terms of
 * the Globus Toolkit Public License, found in file GTPL, or at
 * http://www.globus.org/toolkit/download/license.html. This notice must
 * appear in redistributions of this file, with or without modification.
 *
 * Redistributions of this Software, with or without modification, must
 * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
 * some other similar material which is provided with the Software (if
 * any).
 *
 * Copyright 1999-2004 University of Chicago and The University of
 * Southern California. All rights reserved.
 */
package org.griphyn.cPlanner.classes;


import org.griphyn.common.catalog.ReplicaCatalogEntry;

import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
import java.util.List;

/**
 * A Replica Store that allows us to store the entries from a replica catalog.
 * The store map is indexed by LFN's and values stored are ReplicaLocation
 * objects.
 *
 * @author <NAME>
 * @author <NAME>
 *
 * @version $Revision$
 *
 * @see org.griphyn.common.catalog.ReplicaCatalogEntry
 */
public class ReplicaStore
       extends Data
       implements Cloneable{

    /**
     * The replica store.
     */
    private Map mStore;


    /**
     * Default constructor.
     */
    public ReplicaStore(){
        mStore = new HashMap();
    }

    /**
     * Overloaded constructor.
     * Intializes the member variables to the values passed.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public ReplicaStore( Map rces ){
        mStore = new HashMap( rces.size() );
        store( rces );
    }


    /**
     * Stores replica catalog entries into the store. It overwrites any
     * existing entries with the same LFN's. The <code>ReplicaCatlogEntry</code>
     * ends up being stored as a <code>ReplicaLocation</code> object.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public void store( Map rces ){
        String lfn;
        Map.Entry entry;
        Collection values;

        //traverse through all the entries and render them into
        //ReplicaLocation objects before storing in the store
        for( Iterator it = rces.entrySet().iterator(); it.hasNext(); ){
            entry = ( Map.Entry )it.next();
            lfn = ( String )entry.getKey();
            values = ( Collection )entry.getValue();
            put( lfn, new ReplicaLocation(lfn, values) );
        }
    }


    /**
     * Adds ReplicaCatalogEntries into the store. Any existing
     * mapping of the same LFN and PFN will be replaced, including all its
     * attributes. The <code>ReplicaCatlogEntry</code>
     * ends up being stored as a <code>ReplicaLocation</code> object.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public void add( Map rces ){
        String lfn;
        Map.Entry entry;
        Collection values;
        ReplicaLocation rl;


        //traverse through all the entries and render them into
        //ReplicaLocation objects before storing in the store
        for( Iterator it = rces.entrySet().iterator(); it.hasNext(); ){
            entry = ( Map.Entry )it.next();
            lfn = ( String )entry.getKey();
            values = ( Collection )entry.getValue();<commit_msg>While storing the results in the ReplicaStore, a check is made for empty collection of pfn's being returned, as is case of SimpleFile.<commit_after>/*
 * This file or a portion of this file is licensed under the terms of
 * the Globus Toolkit Public License, found in file GTPL, or at
 * http://www.globus.org/toolkit/download/license.html. This notice must
 * appear in redistributions of this file, with or without modification.
 *
 * Redistributions of this Software, with or without modification, must
 * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
 * some other similar material which is provided with the Software (if
 * any).
 *
 * Copyright 1999-2004 University of Chicago and The University of
 * Southern California. All rights reserved.
 */
package org.griphyn.cPlanner.classes;


import org.griphyn.common.catalog.ReplicaCatalogEntry;

import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
import java.util.List;

/**
 * A Replica Store that allows us to store the entries from a replica catalog.
 * The store map is indexed by LFN's and values stored are ReplicaLocation
 * objects.
 *
 * @author <NAME>
 * @author <NAME>
 *
 * @version $Revision$
 *
 * @see org.griphyn.common.catalog.ReplicaCatalogEntry
 */
public class ReplicaStore
       extends Data
       implements Cloneable{

    /**
     * The replica store.
     */
    private Map mStore;


    /**
     * Default constructor.
     */
    public ReplicaStore(){
        mStore = new HashMap();
    }

    /**
     * Overloaded constructor.
     * Intializes the member variables to the values passed.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public ReplicaStore( Map rces ){
        mStore = new HashMap( rces.size() );
        store( rces );
    }


    /**
     * Stores replica catalog entries into the store. It overwrites any
     * existing entries with the same LFN's. The <code>ReplicaCatlogEntry</code>
     * ends up being stored as a <code>ReplicaLocation</code> object.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public void store( Map rces ){
        String lfn;
        Map.Entry entry;
        Collection values;

        //traverse through all the entries and render them into
        //ReplicaLocation objects before storing in the store
        for( Iterator it = rces.entrySet().iterator(); it.hasNext(); ){
            entry = ( Map.Entry )it.next();
            lfn = ( String )entry.getKey();
            values = ( Collection )entry.getValue();
            //only put in if the values are not empty
            if( !values.isEmpty() ){
                put(lfn, new ReplicaLocation(lfn, values));
            }
        }
    }


    /**
     * Adds ReplicaCatalogEntries into the store. Any existing
     * mapping of the same LFN and PFN will be replaced, including all its
     * attributes. The <code>ReplicaCatlogEntry</code>
     * ends up being stored as a <code>ReplicaLocation</code> object.
     *
     * @param rces  map indexed by LFN's and each value is a collection
     *                of replica catalog entries for the LFN.
     */
    public void add( Map rces ){
        String lfn;
        Map.Entry entry;
        Collection values;
        ReplicaLocation rl;


        //traverse through all the entries and render them into
        //ReplicaLocation objects before storing in the store
        for( Iterator it = rces.entrySet().iterator(); it.hasNext(); ){
            entry = ( Map.Entry )it.next();
            lfn = ( String )entry.getKey();
            values = ( Collection )entry.getValue();
{'fraction_non_alphanumeric': 0.08850973073846974, 'fraction_numerical': 0.002665955745134631, 'mean_word_length': 2.413557779799818, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3515530', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2062, 'n_words': 797}