Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
Value Set Search Performance test [KLO, 092013]
Browse files Browse the repository at this point in the history
  • Loading branch information
kimong committed Sep 20, 2013
1 parent b4c9914 commit ac13406
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 27 deletions.
Binary file modified software/ncitbrowser/lib/lexbig.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2933,6 +2933,10 @@ public static String valueSetSearchAction(HttpServletRequest request) {
java.lang.String valueSetDefinitionRevisionId = null;
String msg = null;


long ms = System.currentTimeMillis();


String selectValueSetSearchOption = HTTPUtils.cleanXSS((String) request.getParameter("selectValueSetSearchOption"));

if (DataUtils.isNull(selectValueSetSearchOption)) {
Expand Down Expand Up @@ -2977,9 +2981,18 @@ public static String valueSetSearchAction(HttpServletRequest request) {
searchOption = SimpleSearchUtils.BY_NAME;
}

System.out.println(checked_vocabularies);

System.out.println("AjaxServlet valueSetSearchAction involking ValueSetSearchUtils -- " + matchText + ", " + algorithm);
_logger.debug("AjaxServlet valueSetSearchAction involking ValueSetSearchUtils -- " + matchText + ", " + algorithm);

ResolvedConceptReferencesIteratorWrapper wrapper = new ValueSetSearchUtils().searchResolvedValueSetCodingSchemes(checked_vocabularies,
matchText, searchOption, algorithm);

System.out.println("Run time (ms): " + (System.currentTimeMillis() - ms));
_logger.debug("Run time (ms): " + (System.currentTimeMillis() - ms));


if (wrapper == null) {
msg = "No match found.";
if (searchOption == SimpleSearchUtils.BY_CODE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public class DataUtils {

private static HashMap _listOfCodingSchemeVersionsUsedInResolutionHashMap = null;

private static HashMap _RVSCSFormalName2VersionHashMap = null;


// ==================================================================================

Expand Down Expand Up @@ -473,6 +475,12 @@ public static AbsoluteCodingSchemeVersionReferenceList getListOfCodingSchemeVers
return null;
}

public static Vector getRVSCSVersionsByFormalName(String RVSCS_formalname) {
if (!_RVSCSFormalName2VersionHashMap.containsKey(RVSCS_formalname)) return null;
return (Vector) _RVSCSFormalName2VersionHashMap.get(RVSCS_formalname);
}


private static void setCodingSchemeMap() {
//LexEVSResolvedValueSetServiceImpl lexEVSResolvedValueSetService = new LexEVSResolvedValueSetServiceImpl();

Expand Down Expand Up @@ -504,6 +512,7 @@ private static void setCodingSchemeMap() {
_formalName2VersionsHashMap = new HashMap();
_versionReleaseDateHashMap = new HashMap();
_listOfCodingSchemeVersionsUsedInResolutionHashMap = new HashMap();
_RVSCSFormalName2VersionHashMap = new HashMap();

Vector nv_vec = new Vector();
boolean includeInactive = false;
Expand Down Expand Up @@ -578,11 +587,24 @@ private static void setCodingSchemeMap() {
}

try {

CodingScheme cs = lbSvc.resolveCodingScheme(formalname, vt);
if (isResolvedValueSetCodingScheme(cs)) {
String cs_uri = cs.getCodingSchemeURI();
String cs_name = cs.getCodingSchemeName();

String cs_version = cs.getRepresentsVersion();

String cs_formalname = cs.getFormalName();
Vector w = (Vector) _RVSCSFormalName2VersionHashMap.get(cs_formalname);
if (w == null) {
w = new Vector();
}
w.add(cs_version);
System.out.println("(*) " + cs_formalname + " -> " + cs_version);

_RVSCSFormalName2VersionHashMap.put(cs_formalname, w);

HashMap hmap = new HashMap();
AbsoluteCodingSchemeVersionReferenceList acsvr = getListOfCodingSchemeVersionsUsedInResolution(cs_name);
if (acsvr != null) {
Expand All @@ -594,8 +616,6 @@ private static void setCodingSchemeMap() {
_listOfCodingSchemeVersionsUsedInResolutionHashMap.put(cs_name, hmap);
}



} else {

Vector prop_quals = getSupportedPropertyQualifier(cs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,25 @@ public ResolvedConceptReferencesIteratorWrapper search(
return search(schemes, versions, matchText, searchOption, algorithm);
}


private void printNumberOfMatches(ResolvedConceptReferencesIterator iterator) {
if (iterator == null) {
System.out.println("Iterator is null");
return;
}
try {
int numRemaining = iterator.numberRemaining();
System.out.println("Number of matches: " + numRemaining);
} catch (Exception ex) {
ex.printStackTrace();
}
}


public ResolvedConceptReferencesIteratorWrapper search(
Vector<String> schemes, Vector<String> versions, String matchText, int searchOption, String algorithm) throws LBException {
System.out.println("search by " + matchText + ", algorithm: " + algorithm);

if (schemes == null|| versions == null) return null;
if (schemes.size() != versions.size()) return null;
if (schemes.size() == 0) return null;
Expand All @@ -232,6 +249,7 @@ public ResolvedConceptReferencesIteratorWrapper search(
for (int i=0; i<schemes.size(); i++) {
String scheme = (String) schemes.elementAt(i);
String version = (String) versions.elementAt(i);
System.out.println("\t" + scheme + " (" + version + ")");
CodingSchemeReference ref = new CodingSchemeReference();
ref.setCodingScheme(scheme);

Expand All @@ -241,15 +259,12 @@ public ResolvedConceptReferencesIteratorWrapper search(
}
includes.add(ref);
}
/*
if (searchOption == BY_CODE) {
matchText = "code:" + matchText;
}
*/

ResolvedConceptReferencesIterator iterator = null;
try {
iterator = searchExtension.search(matchText, includes, converToMatchAlgorithm(searchOption, algorithm));
printNumberOfMatches(iterator);

} catch (Exception ex) {
ex.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ public static boolean containsConceptInCodingScheme(String vsd_uri, String codin
}


public static Vector getCodingSchemeVersionsByURN(String RVSCS_formalname) {
if (RVSCS_formalname == null) return null;
return DataUtils.getRVSCSVersionsByFormalName(RVSCS_formalname);
}



/*
public static Vector getCodingSchemeVersionsByURN(String urn) {
try {
Vector v = new Vector();
Expand Down Expand Up @@ -546,8 +554,9 @@ public static Vector getCodingSchemeVersionsByURN(String urn) {
if (isActive != null && isActive.equals(Boolean.TRUE)) {
String uri = css.getCodingSchemeURI();
String formalName = css.getFormalName();
String localName = css.getLocalName();
if (uri.compareTo(urn) == 0 || urn.compareTo(formalName) == 0) {
if (urn.compareTo(formalName) == 0 || urn.compareTo(localName) == 0 || urn.compareTo(uri) == 0 ) {
String representsVersion = css.getRepresentsVersion();
v.add(representsVersion);
}
Expand All @@ -559,24 +568,27 @@ public static Vector getCodingSchemeVersionsByURN(String urn) {
}
return null;
}

*/

public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSchemes(String checked_vocabularies,
String matchText, String matchAlgorithm) {

return searchResolvedValueSetCodingSchemes(checked_vocabularies, matchText, SimpleSearchUtils.BY_NAME, matchAlgorithm);
}


public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSchemes(String checked_vocabularies,
String matchText, int searchOption, String matchAlgorithm) {
ResolvedConceptReferencesIteratorWrapper wrapper = null;

long ms = System.currentTimeMillis();

if (checked_vocabularies == null) return null;
Vector selected_vocabularies = DataUtils.parseData(checked_vocabularies, ",");

// find versions
Vector schemes = new Vector();
Vector versions = new Vector();
for (int i=0; i<selected_vocabularies.size(); i++) {
int k = i+1;
String selected_vocabulary = (String) selected_vocabularies.elementAt(i);
Vector u = getCodingSchemeVersionsByURN(selected_vocabulary);
if (u != null) {
Expand All @@ -586,9 +598,13 @@ public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSche
versions.add(version);
}
} else {
System.out.println("\tgetCodingSchemeVersionsByURN returns null???");
//System.out.println("\tgetCodingSchemeVersionsByURN returns null ??? " + selected_vocabulary);
}
}

_logger.debug("\tComponent run time (ms) of searching for all resovled value set coding scheme versions: " + (System.currentTimeMillis() - ms));
System.out.println("\tComponent run time (ms) of searching for all resovled value set coding scheme versions: " + (System.currentTimeMillis() - ms));

/*
// performs search
ResolvedConceptReferencesIteratorWrapper wrapper = null;
Expand Down Expand Up @@ -616,19 +632,29 @@ public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSche
}
return wrapper;
*/
ResolvedConceptReferencesIteratorWrapper wrapper = null;


if (searchOption == SimpleSearchUtils.BY_NAME) {
if (SimpleSearchUtils.isSimpleSearchSupported(matchAlgorithm, SimpleSearchUtils.NAMES)) {
try {

_logger.debug("searchResolvedValueSetCodingSchemes by name using search extension -- " + matchText + ", " + matchAlgorithm);
System.out.println("searchResolvedValueSetCodingSchemes by name using search extension -- " + matchText + ", " + matchAlgorithm);

wrapper = new SimpleSearchUtils().search(schemes, versions, matchText, searchOption, matchAlgorithm);


} catch (Exception ex) {
ex.printStackTrace();
}
} else {
String source = "ALL";
boolean ranking = false;
int maxToReturn = -1;

_logger.debug("searchResolvedValueSetCodingSchemes by name using regular search API -- " + matchText + ", " + matchAlgorithm);
System.out.println("searchResolvedValueSetCodingSchemes by name using regular search API -- " + matchText + ", " + matchAlgorithm);

wrapper = new SearchUtils().searchByNameOrCode(
schemes, versions, matchText,
source, matchAlgorithm, ranking, maxToReturn, SearchUtils.SEARCH_BY_NAME_ONLY);
Expand All @@ -637,6 +663,10 @@ public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSche
} else if (searchOption == SimpleSearchUtils.BY_CODE) {
if (SimpleSearchUtils.isSimpleSearchSupported(matchAlgorithm, SimpleSearchUtils.CODES)) {
try {

_logger.debug("searchResolvedValueSetCodingSchemes by code using search extension -- " + matchText + ", " + matchAlgorithm);
System.out.println("searchResolvedValueSetCodingSchemes by code using search extension -- " + matchText + ", " + matchAlgorithm);

wrapper = new SimpleSearchUtils().search(schemes, versions, matchText, searchOption, matchAlgorithm);

} catch (Exception ex) {
Expand All @@ -646,26 +676,23 @@ public ResolvedConceptReferencesIteratorWrapper searchResolvedValueSetCodingSche
String source = "ALL";
boolean ranking = false;
int maxToReturn = -1;

_logger.debug("searchResolvedValueSetCodingSchemes by name using regular search API -- " + matchText + ", " + matchAlgorithm);
System.out.println("searchResolvedValueSetCodingSchemes by name using regular search API -- " + matchText + ", " + matchAlgorithm);

wrapper = new SearchUtils().searchByNameOrCode(
schemes, versions, matchText,
source, matchAlgorithm, ranking, maxToReturn, SearchUtils.SEARCH_BY_CODE_ONLY);

}
}
return wrapper;
}


/*
public static void main(String[] args) {
try {
AbsoluteCodingSchemeVersionReferenceList list1 = getEntireAbsoluteCodingSchemeVersionReferenceList();
if (list1 != null) {
System.out.println("Count: " + list1.getAbsoluteCodingSchemeVersionReferenceCount());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
*/
_logger.debug("Run time (ms): " + (System.currentTimeMillis() - ms));
System.out.println("Run time (ms): " + (System.currentTimeMillis() - ms));


return wrapper;
}
}

0 comments on commit ac13406

Please sign in to comment.