org.elasticsearch.plugin.nlpcn.HashJoinComparisonStructure Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-sql Show documentation
Show all versions of elasticsearch-sql Show documentation
Query elasticsearch using SQL
The newest version!
package org.elasticsearch.plugin.nlpcn;
import org.elasticsearch.search.SearchHit;
import org.nlpcn.es4sql.domain.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Created by Eliran on 2/11/2015.
*/
public class HashJoinComparisonStructure {
private HashMap>> comparisonIDtoComparisonFields;
private HashMap> comparisonIDtoComparisonHash;
public HashJoinComparisonStructure(List>> t1ToT2FieldsComparisons) {
comparisonIDtoComparisonFields = new HashMap<>();
comparisonIDtoComparisonHash = new HashMap<>();
if(t1ToT2FieldsComparisons == null || t1ToT2FieldsComparisons.size() == 0){
String comparisonId = UUID.randomUUID().toString();
this.comparisonIDtoComparisonFields.put(comparisonId,new ArrayList>());
this.comparisonIDtoComparisonHash.put(comparisonId,new HashMap());
}
for (List> comparisonFields : t1ToT2FieldsComparisons){
String comparisonId = UUID.randomUUID().toString();
//maby from field to List ?
this.comparisonIDtoComparisonFields.put(comparisonId,comparisonFields);
this.comparisonIDtoComparisonHash.put(comparisonId, new HashMap());
}
}
public HashMap>> getComparisons() {
return comparisonIDtoComparisonFields;
}
public void insertIntoComparisonHash(String comparisonID,String comparisonKey,SearchHit hit){
HashMap comparisonHash = this.comparisonIDtoComparisonHash.get(comparisonID);
SearchHitsResult currentSearchHitsResult = comparisonHash.get(comparisonKey);
if(currentSearchHitsResult == null) {
currentSearchHitsResult = new SearchHitsResult(new ArrayList(),false);
comparisonHash.put(comparisonKey, currentSearchHitsResult);
}
currentSearchHitsResult.getSearchHits().add(hit);
}
public SearchHitsResult searchForMatchingSearchHits(String comparisonID,String comparisonKey){
HashMap comparisonHash = this.comparisonIDtoComparisonHash.get(comparisonID);
return comparisonHash.get(comparisonKey);
}
public List getAllSearchHits(){
List allSearchHits = new ArrayList<>();
for(HashMap comparisonHash : this.comparisonIDtoComparisonHash.values())
allSearchHits.addAll(comparisonHash.values());
return allSearchHits;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy