<commit_before>/*
 * Copyright (C) 2014 Dell, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dell.doradus.olap.aggregate.mr;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.dell.doradus.search.aggregate.AggregationGroup;

public class AggregationIncludeExclude {
	private List<Set<String>> m_exclude = new ArrayList<Set<String>>();
	private List<Set<String>> m_include = new ArrayList<Set<String>>();
	
	public AggregationIncludeExclude(List<AggregationGroup> groups) {
		for(int i = 0; i < groups.size(); i++) {
			List<String> exclude = groups.get(i).exclude;
			if(exclude == null) m_exclude.add(null);
			else {
				for(int j = 0; j < exclude.size(); j++) exclude.set(j, exclude.get(j).toLowerCase());
				m_exclude.add(new HashSet<String>(exclude));
			}
			
			List<String> include = groups.get(i).include;
			if(include == null) m_include.add(null);
			else {
				for(int j = 0; j < include.size(); j++) include.set(j, include.get(j).toLowerCase());
				m_include.add(new HashSet<String>(include));
			}
		}
	}
	
	public boolean accept(MGName name, int level) {
		Set<String> excl = m_exclude.get(level);
		if(excl != null && name.name != null && excl.contains(name.name.toLowerCase())) return false;
		Set<String> incl = m_include.get(level);
		if(incl != null && (name.name == null || !incl.contains(name.name.toLowerCase()))) return false;
		return true;
	}
	
}
<commit_msg>Support NULL keyword in OLAP aggregate<commit_after>/*
 * Copyright (C) 2014 Dell, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dell.doradus.olap.aggregate.mr;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.dell.doradus.search.aggregate.AggregationGroup;

public class AggregationIncludeExclude {
	private List<Set<String>> m_exclude = new ArrayList<Set<String>>();
	private List<Set<String>> m_include = new ArrayList<Set<String>>();
	
	public AggregationIncludeExclude(List<AggregationGroup> groups) {
		for(int i = 0; i < groups.size(); i++) {
			List<String> exclude = groups.get(i).exclude;
			if(exclude == null) m_exclude.add(null);
			else {
				HashSet<String> hs = new HashSet<String>(exclude.size());
				for(String str: exclude) hs.add(str == null ? null : str.toLowerCase());
				m_exclude.add(hs);
			}
			
			List<String> include = groups.get(i).include;
			if(include == null) m_include.add(null);
			else {
				HashSet<String> hs = new HashSet<String>(include.size());
				for(String str: include) hs.add(str == null ? null : str.toLowerCase());
				m_include.add(hs);
			}
		}
	}
	
	public boolean accept(MGName name, int level) {
		String text = name.name == null ? null : name.name.toLowerCase();
		Set<String> excl = m_exclude.get(level);
		if(excl != null && excl.contains(text)) return false;
		Set<String> incl = m_include.get(level);
		if(incl != null && (!incl.contains(text))) return false;
		return true;
	}
	
}

{'fraction_non_alphanumeric': 0.13384653588279116, 'fraction_numerical': 0.004966476285075739, 'mean_word_length': 4.118170266836087, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5664352', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1257, 'n_words': 371}