mirror of https://github.com/apache/druid.git
ignore duplicate queries
This commit is contained in:
parent
19fe5867b1
commit
3f507d8648
|
@ -30,12 +30,15 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class QuidemRecorder implements AutoCloseable, DruidHook<String>
|
public class QuidemRecorder implements AutoCloseable, DruidHook<String>
|
||||||
{
|
{
|
||||||
private PrintStream printStream;
|
private PrintStream printStream;
|
||||||
private File file;
|
private File file;
|
||||||
private DruidHookDispatcher hookDispatcher;
|
private DruidHookDispatcher hookDispatcher;
|
||||||
|
private Set<String> queries = new HashSet<>();
|
||||||
|
|
||||||
public QuidemRecorder(URI quidemURI, DruidHookDispatcher hookDispatcher, File file)
|
public QuidemRecorder(URI quidemURI, DruidHookDispatcher hookDispatcher, File file)
|
||||||
{
|
{
|
||||||
|
@ -67,11 +70,16 @@ public class QuidemRecorder implements AutoCloseable, DruidHook<String>
|
||||||
public synchronized void invoke(HookKey<String> key, String query)
|
public synchronized void invoke(HookKey<String> key, String query)
|
||||||
{
|
{
|
||||||
if (DruidHook.SQL.equals(key)) {
|
if (DruidHook.SQL.equals(key)) {
|
||||||
|
if (queries.contains(query)) {
|
||||||
|
// ignore duplicate queries
|
||||||
|
return;
|
||||||
|
}
|
||||||
printStream.println("# " + new Date());
|
printStream.println("# " + new Date());
|
||||||
printStream.print(query);
|
printStream.print(query);
|
||||||
printStream.println(";");
|
printStream.println(";");
|
||||||
printStream.println("!ok");
|
printStream.println("!ok");
|
||||||
printStream.flush();
|
printStream.flush();
|
||||||
|
queries.add(query);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue