Skip to content

Commit

Permalink
setTmpFetchSize(25100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser committed Apr 17, 2023
1 parent 9fdc65b commit d0dea57
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
6 changes: 1 addition & 5 deletions src/main/engine/net/sf/jailer/JailerVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class JailerVersion {
/**
* The Jailer version.
*/
public static final String VERSION = "14.5.0.2";
public static final String VERSION = "14.6";

/**
* The Jailer working tables version.
Expand All @@ -45,7 +45,3 @@ public static void main(String[] args) {
}

}


// TODO
// TODO engine release pending (14.6). See DBMS#getLimitedFetchSize()
26 changes: 21 additions & 5 deletions src/main/engine/net/sf/jailer/configuration/DBMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -1381,17 +1381,33 @@ public boolean equals(Object obj) {
return true;
}

private static final ThreadLocal<Integer> tmpFetchSize = new ThreadLocal<>();

public static void setTmpFetchSize(Integer tmpFetchSize) {
DBMS.tmpFetchSize.set(tmpFetchSize);
}

public int getLimitedFetchSize(long limit) {
final int DEFAULT_FETCH_SIZE = 20010;
Integer fSize = getFetchSize();
if (fSize != null) {
if (limit > 0 && limit <= DEFAULT_FETCH_SIZE) {
return (int) (limit + 1 + 1);
} else {
if (fSize < 0) {
return fSize;
}
}

final int DEFAULT_FETCH_SIZE = 5010;
if (fSize == null) {
fSize = DEFAULT_FETCH_SIZE;
}

Integer dfs = tmpFetchSize.get();
if (dfs == null) {
dfs = fSize;
}
if (limit > 0 && limit <= dfs) {
return (int) (limit + 1 + 1);
} else {
return DEFAULT_FETCH_SIZE;
return dfs;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.fife.ui.rtextarea.SmartHighlightPainter;

import net.sf.jailer.ExecutionContext;
import net.sf.jailer.configuration.DBMS;
import net.sf.jailer.database.InlineViewStyle;
import net.sf.jailer.database.Session;
import net.sf.jailer.database.Session.AbstractResultSetReader;
Expand Down Expand Up @@ -2293,19 +2294,24 @@ public void readCurrentRow(ResultSet resultSet) throws SQLException {
}
}
};
if (orderBy) {
Map<String, Integer> prev = new HashMap<String, Integer>(result);
try {
session.executeQuery(sqlQuery + " order by " + (inSQLConsole()? "val" : columnName), reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} catch (SQLException e) {
result.clear();
result.putAll(prev);
// try without ordering
DBMS.setTmpFetchSize(25100);
try {
if (orderBy) {
Map<String, Integer> prev = new HashMap<String, Integer>(result);
try {
session.executeQuery(sqlQuery + " order by " + (inSQLConsole()? "val" : columnName), reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} catch (SQLException e) {
result.clear();
result.putAll(prev);
// try without ordering
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
sortValues(result, columnIndex);
}
} else {
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
sortValues(result, columnIndex);
}
} else {
session.executeQuery(sqlQuery, reader, null, cancellationContext, MAX_NUM_DISTINCTEXISTINGVALUES + 2);
} finally {
DBMS.setTmpFetchSize(null);
}
}

Expand Down Expand Up @@ -2633,7 +2639,3 @@ public void close() {

}

// TODO
// TODO Abteilung1.ObjektId wird auf 62 nicht gecached?!


0 comments on commit d0dea57

Please sign in to comment.