/// <exception cref="Java.Sql.SQLException"/> public static IList <Pair <string, long> > GetCounts(ICollection <string> strs) { Connect(); IList <Pair <string, long> > counts = new List <Pair <string, long> >(); string query = string.Empty; foreach (string str in strs) { str = str.Trim(); int ngram = str.Split("\\s+").Length; string table = tablenamePrefix + ngram; if (!ExistsTable(table)) { counts.Add(new Pair(str, (long)-1)); continue; } string phrase = EscapeString(str); query += "select count from " + table + " where phrase='" + phrase + "';"; } if (query.IsEmpty()) { return(counts); } IPreparedStatement stmt = connection.PrepareStatement(query); bool isresult = stmt.Execute(); IResultSet rs; IEnumerator <string> iter = strs.GetEnumerator(); do { rs = stmt.GetResultSet(); string ph = iter.Current; if (rs.Next()) { counts.Add(new Pair(ph, rs.GetLong("count"))); } else { counts.Add(new Pair(ph, (long)-1)); } isresult = stmt.GetMoreResults(); }while (isresult); System.Diagnostics.Debug.Assert((counts.Count == strs.Count)); return(counts); }