bug fixed for the smart smapling (with table col2oct2010-> scientific_names). Corrections in computeSmartSampleWithThreshold method.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-access/DatabasesResourcesManager@99565 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5af78b2871
commit
b72e647ea8
|
@ -172,12 +172,15 @@ public class Sampler {
|
|||
if (DBType.equals(POSTGRES)) {
|
||||
|
||||
// attribute = "CAST(" + listColumns.get(i) + " as text), ";
|
||||
attribute = "CAST(" + listColumns.get(i) + " as character varying(255)), ";
|
||||
attribute = "CAST(" + listColumns.get(i)
|
||||
+ " as character varying(255)), ";
|
||||
|
||||
if (i == (listColumns.size() - 1)) {
|
||||
|
||||
// attribute = "CAST(" + listColumns.get(i) + " as text)";
|
||||
attribute = "CAST(" + listColumns.get(i) + " as character varying(255))";
|
||||
// attribute = "CAST(" + listColumns.get(i) +
|
||||
// " as text)";
|
||||
attribute = "CAST(" + listColumns.get(i)
|
||||
+ " as character varying(255))";
|
||||
|
||||
}
|
||||
|
||||
|
@ -208,14 +211,17 @@ public class Sampler {
|
|||
// attribute = "CONVERT(" + listColumns.get(i) +
|
||||
// ", BINARY)";
|
||||
|
||||
attribute = "CAST(" + "`" +listColumns.get(i)+ "`"
|
||||
+ " as CHAR(255) CHARACTER SET utf8)";
|
||||
attribute = "CAST(" + "`" + listColumns.get(i)
|
||||
+ "`" + " as CHAR(255) CHARACTER SET utf8)";
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
attribute = "CAST(CAST(" + "`" +listColumns.get(i)+ "`"
|
||||
attribute = "CAST(CAST("
|
||||
+ "`"
|
||||
+ listColumns.get(i)
|
||||
+ "`"
|
||||
+ " as BINARY) as CHAR(255) CHARACTER SET utf8), ";
|
||||
|
||||
if (i == (listColumns.size() - 1)) {
|
||||
|
@ -226,7 +232,10 @@ public class Sampler {
|
|||
// attribute = "CONVERT(" + listColumns.get(i) +
|
||||
// ", BINARY)";
|
||||
|
||||
attribute = "CAST(CAST(" + "`" +listColumns.get(i)+ "`"
|
||||
attribute = "CAST(CAST("
|
||||
+ "`"
|
||||
+ listColumns.get(i)
|
||||
+ "`"
|
||||
+ " as BINARY) as CHAR(255) CHARACTER SET utf8)";
|
||||
|
||||
}
|
||||
|
@ -560,7 +569,7 @@ public class Sampler {
|
|||
// extract 200 rows randomly for each iteration
|
||||
extractionRows: for (int i = 0; i < NIterations; i++) {
|
||||
|
||||
System.out.println("index iteration: " + i);
|
||||
// System.out.println("index iteration: " + i);
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"Sampler->executing the query: " + query);
|
||||
|
@ -746,7 +755,8 @@ public class Sampler {
|
|||
|
||||
// //check rows added in the final result
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "Sampler->adding row with index: " + i + " " + listRows.get(i).getRow());
|
||||
// "Sampler->adding row with index: " + i + " " +
|
||||
// listRows.get(i).getRow());
|
||||
|
||||
rows.add(listRows.get(i).getRow());
|
||||
}
|
||||
|
@ -915,7 +925,8 @@ public class Sampler {
|
|||
if (DBType.equals(POSTGRES)) {
|
||||
|
||||
// the full name equal to "schemaname.tablename"
|
||||
tablename = schemaName + "." + "\"" + tablename + "\"";
|
||||
String tableName = "";
|
||||
tableName = schemaName + "." + "\"" + tablename + "\"";
|
||||
|
||||
query = String.format(
|
||||
queryForSmartSampleWithThresholdOnTablePostgres,
|
||||
|
@ -924,9 +935,9 @@ public class Sampler {
|
|||
|
||||
// build the query for database mysql
|
||||
if (DBType.equals(MYSQL)) {
|
||||
|
||||
// the full name equal to "dbname.tablename"
|
||||
tablename = schemaName + "." + tablename;
|
||||
String tableName = "";
|
||||
tableName = schemaName + "." + tablename;
|
||||
|
||||
query = String.format(
|
||||
queryForSmartSampleWithThresholdOnTableMysql,
|
||||
|
@ -999,18 +1010,20 @@ public class Sampler {
|
|||
|
||||
// if (value == columnArray.length) {
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"Sampler-> column array dimension: "
|
||||
+ columnArray.length);
|
||||
// print check
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "Sampler-> column array dimension: "
|
||||
// + columnArray.length);
|
||||
|
||||
double thresholdRank = ((columnArray.length) * 80);
|
||||
thresholdRank = thresholdRank / 100;
|
||||
|
||||
double valCeil = Math.round(thresholdRank);
|
||||
|
||||
AnalysisLogger.getLogger().debug(
|
||||
"Sampler-> threshold: " + thresholdRank
|
||||
+ " rounded value: " + valCeil);
|
||||
// print check
|
||||
// AnalysisLogger.getLogger().debug(
|
||||
// "Sampler-> threshold: " + thresholdRank
|
||||
// + " rounded value: " + valCeil);
|
||||
|
||||
if (value >= (int) valCeil) {
|
||||
|
||||
|
@ -1326,8 +1339,6 @@ public class Sampler {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (DBType.equals(MYSQL)) { // MySQL
|
||||
|
||||
// the full name equal to "dbname.tablename"
|
||||
|
|
Loading…
Reference in New Issue