提交 642c24e5 编写于 作者: S serge-rider

QMDB: history reading

上级 7956fca3
......@@ -39,6 +39,14 @@ public final class IOUtils {
}
}
public static void close(AutoCloseable closeable) {
try {
closeable.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void fastCopy(final InputStream src, final OutputStream dest) throws IOException {
fastCopy(src, dest, DEFAULT_BUFFER_SIZE);
}
......
......@@ -621,9 +621,10 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
QMEventBrowser eventBrowser = QMUtils.getEventBrowser();
if (eventBrowser != null) {
String searchPattern = CommonUtils.isEmptyTrimmed(searchString) ? null : searchString.trim();
QMEventCursor cursor = eventBrowser.getQueryHistoryCursor(monitor, null, null, searchPattern);
while (events.size() < this.entriesPerPage && cursor.hasNextEvent(monitor)) {
events.add(cursor.nextEvent(monitor));
try (QMEventCursor cursor = eventBrowser.getQueryHistoryCursor(monitor, null, null, searchPattern)) {
while (events.size() < this.entriesPerPage && cursor.hasNextEvent(monitor)) {
events.add(cursor.nextEvent(monitor));
}
}
}
} catch (DBException e) {
......
......@@ -17,26 +17,21 @@
package org.jkiss.dbeaver.model.qm;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose;
import org.jkiss.dbeaver.model.qm.meta.QMMStatementExecuteInfo;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import java.util.Date;
import java.util.List;
/**
* Event cursor
*/
public interface QMEventCursor {
public interface QMEventCursor extends AutoCloseable {
long getTotalSize();
void scroll(long position, DBRProgressMonitor monitor) throws DBException;
void scroll(int position, DBRProgressMonitor monitor) throws DBException;
boolean hasNextEvent(DBRProgressMonitor monitor) throws DBException;
QMMetaEvent nextEvent(DBRProgressMonitor monitor) throws DBException;
void close();
}
......@@ -162,7 +162,7 @@ public class QMUtils {
}
@Override
public void scroll(long position, DBRProgressMonitor monitor) throws DBException {
public void scroll(int position, DBRProgressMonitor monitor) throws DBException {
if (position < 0 || position >= events.size()) {
throw new DBException("Position is out of range (" + getTotalSize() + ")");
}
......@@ -180,6 +180,11 @@ public class QMUtils {
return event;
}
@Override
public void close() {
}
}
public static class EmptyCursorImpl implements QMEventCursor {
......@@ -190,7 +195,7 @@ public class QMUtils {
}
@Override
public void scroll(long position, DBRProgressMonitor monitor) throws DBException {
public void scroll(int position, DBRProgressMonitor monitor) throws DBException {
throw new DBException("Empty cursor");
}
......@@ -204,6 +209,11 @@ public class QMUtils {
throw new DBException("Empty cursor");
}
@Override
public void close() {
}
}
}
......@@ -16,6 +16,7 @@
*/
package org.jkiss.dbeaver.model.qm.meta;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.sql.SQLDataSource;
......@@ -29,8 +30,10 @@ public class QMMSessionInfo extends QMMObject {
private final String containerId;
private final String containerName;
private final String driverId;
@Nullable
private final DBPConnectionConfiguration connectionConfiguration;
private final String contextName;
@Nullable
private SQLDialect sqlDialect;
private boolean transactional;
......@@ -53,7 +56,15 @@ public class QMMSessionInfo extends QMMObject {
if (transactional) {
this.transaction = new QMMTransactionInfo(this, null);
}
//stack = new RuntimeException();
}
public QMMSessionInfo(String containerId, String containerName, String driverId, DBPConnectionConfiguration connectionConfiguration, String contextName, boolean transactional) {
this.containerId = containerId;
this.containerName = containerName;
this.driverId = driverId;
this.connectionConfiguration = connectionConfiguration;
this.contextName = contextName;
this.transactional = transactional;
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册