Skip to content

Commit f6d6241

Browse files
committed
Adapt VectorCommand, VectorBenchScenario, and VectorBenchConfig to support PgVectorBench
1 parent 7c8c924 commit f6d6241

4 files changed

Lines changed: 63 additions & 6 deletions

File tree

src/main/java/org/polypheny/simpleclient/cli/VectorCommand.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public class VectorCommand implements CliRunnable {
4747
private List<String> args;
4848

4949

50+
@Option(name = { "-m", "--mode" }, title = "Mode", arity = 1, description = "Execution mode: polypheny (default) or postgres.")
51+
public String mode = "polypheny";
52+
53+
5054
@Option(name = { "-pdb", "--polyphenydb" }, title = "IP or Hostname", arity = 1, description = "IP or Hostname of the Polypheny-DB server (default: 127.0.0.1).")
5155
public static String polyphenyDbHost = "127.0.0.1";
5256

@@ -78,16 +82,22 @@ public int run() throws SQLException {
7882

7983
ExecutorFactory executorFactory;
8084
executorFactory = new PolyphenyDbJdbcExecutorFactory( polyphenyDbHost, false );
85+
boolean usePostgres = mode.equalsIgnoreCase( "postgres" );
86+
String task = args.getFirst();
8187

8288
try {
83-
if ( args.getFirst().equalsIgnoreCase( "data" ) ) {
84-
VectorBenchScenario.data( executorFactory, multiplier, true );
85-
} else if ( args.getFirst().equalsIgnoreCase( "workload" ) ) {
86-
VectorBenchScenario.workload( executorFactory, multiplier, true, writeCsv, dumpQueryList );
89+
if ( task.equalsIgnoreCase( "data" ) ) {
90+
if ( usePostgres ) VectorBenchScenario.pgData( multiplier, true );
91+
else VectorBenchScenario.data( executorFactory, multiplier, true );
92+
} else if ( task.equalsIgnoreCase( "workload" ) ) {
93+
if ( usePostgres ) VectorBenchScenario.pgWorkload( multiplier, true, writeCsv, dumpQueryList );
94+
else VectorBenchScenario.workload( executorFactory, multiplier, true, writeCsv, dumpQueryList );
8795
} else if ( args.getFirst().equalsIgnoreCase( "schema" ) ) {
88-
VectorBenchScenario.schema( executorFactory, true );
96+
if ( usePostgres ) VectorBenchScenario.pgSchema( true );
97+
else VectorBenchScenario.schema( executorFactory, true );
8998
} else if ( args.getFirst().equalsIgnoreCase( "warmup" ) ) {
90-
VectorBenchScenario.warmup( executorFactory, multiplier, true, dumpQueryList );
99+
if ( usePostgres ) VectorBenchScenario.pgWarmup( multiplier, true, dumpQueryList );
100+
else VectorBenchScenario.warmup( executorFactory, multiplier, true, dumpQueryList );
91101
} else {
92102
System.err.println( "Unknown task: " + args.getFirst() );
93103
}

src/main/java/org/polypheny/simpleclient/main/VectorBenchScenario.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import lombok.extern.slf4j.Slf4j;
2828
import org.polypheny.simpleclient.executor.Executor.ExecutorFactory;
29+
import org.polypheny.simpleclient.executor.PostgresExecutor.PostgresExecutorFactory;
30+
import org.polypheny.simpleclient.scenario.vectorbench.PgVectorBench;
2931
import org.polypheny.simpleclient.scenario.vectorbench.VectorBench;
3032
import org.polypheny.simpleclient.scenario.vectorbench.VectorBenchConfig;
3133
import java.io.File;
@@ -43,6 +45,14 @@ public static void schema( ExecutorFactory executorFactory, boolean commitAfterE
4345
}
4446

4547

48+
public static void pgSchema( boolean commitAfterEveryQuery ) {
49+
VectorBenchConfig config = new VectorBenchConfig( getProperties(), 1 );
50+
ExecutorFactory factory = new PostgresExecutorFactory( config.postgresHost, false );
51+
PgVectorBench vectorBench = new PgVectorBench( factory, config, commitAfterEveryQuery, false );
52+
vectorBench.createSchema( null, true );
53+
}
54+
55+
4656
public static void data( ExecutorFactory executorFactory, int multiplier, boolean commitAfterEveryQuery ) {
4757
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
4858
VectorBench vectorBench = new VectorBench( executorFactory, config, commitAfterEveryQuery, false );
@@ -52,6 +62,15 @@ public static void data( ExecutorFactory executorFactory, int multiplier, boolea
5262
}
5363

5464

65+
public static void pgData( int multiplier, boolean commitAfterEveryQuery ) {
66+
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
67+
ExecutorFactory factory = new PostgresExecutorFactory( config.postgresHost, false );
68+
PgVectorBench bench = new PgVectorBench( factory, config, commitAfterEveryQuery, false );
69+
ProgressReporter progressReporter = new ProgressBar( config.numberOfThreads, config.progressReportBase );
70+
bench.generateData( null, progressReporter );
71+
}
72+
73+
5574
public static void workload( ExecutorFactory executorFactory, int multiplier, boolean commitAfterEveryQuery, boolean writeCsv, boolean dumpQueryList ) {
5675
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
5776
VectorBench vectorBench = new VectorBench( executorFactory, config, commitAfterEveryQuery, dumpQueryList );
@@ -68,6 +87,17 @@ public static void workload( ExecutorFactory executorFactory, int multiplier, bo
6887
}
6988

7089

90+
public static void pgWorkload( int multiplier, boolean commitAfterEveryQuery, boolean writeCsv, boolean dumpQueryList ) {
91+
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
92+
ExecutorFactory factory = new PostgresExecutorFactory( config.postgresHost, false );
93+
PgVectorBench bench = new PgVectorBench( factory, config, commitAfterEveryQuery, dumpQueryList );
94+
CsvWriter csvWriter = writeCsv ? new CsvWriter( "results-pg.csv" ) : null;
95+
ProgressReporter progressReporter = new ProgressBar( config.numberOfThreads, config.progressReportBase );
96+
bench.execute( progressReporter, csvWriter, new File( "." ), config.numberOfThreads );
97+
}
98+
99+
100+
71101
public static void warmup( ExecutorFactory executorFactory, int multiplier, boolean commitAfterEveryQuery, boolean dumpQueryList ) {
72102
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
73103
VectorBench vectorBench = new VectorBench( executorFactory, config, commitAfterEveryQuery, dumpQueryList );
@@ -77,6 +107,16 @@ public static void warmup( ExecutorFactory executorFactory, int multiplier, bool
77107
}
78108

79109

110+
public static void pgWarmup( int multiplier, boolean commitAfterEveryQuery, boolean dumpQueryList ) {
111+
VectorBenchConfig config = new VectorBenchConfig( getProperties(), multiplier );
112+
ExecutorFactory factory = new PostgresExecutorFactory( config.postgresHost, false );
113+
PgVectorBench bench = new PgVectorBench( factory, config, commitAfterEveryQuery, dumpQueryList );
114+
ProgressReporter progressReporter = new ProgressBar( config.numberOfThreads, config.progressReportBase );
115+
bench.warmUp( progressReporter );
116+
}
117+
118+
119+
80120
private static Properties getProperties() {
81121
Properties props = new Properties();
82122
try {

src/main/java/org/polypheny/simpleclient/scenario/vectorbench/VectorBenchConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class VectorBenchConfig extends AbstractConfig {
3838
public String dataStoreFeature;
3939
public String dataStoreMetadata;
4040

41+
public String postgresHost;
42+
4143
public long randomSeedInsert;
4244
public long randomSeedQuery;
4345

@@ -80,6 +82,8 @@ public VectorBenchConfig(Properties properties, int multiplier ) {
8082
}
8183
//dataStores.add( "cottontail" );
8284

85+
postgresHost = getStringProperty( properties, "postgresHost" );
86+
8387
if ( getBooleanProperty( properties, "useRandomSeeds" ) ) {
8488
Random tempRand = new Random();
8589
randomSeedInsert = tempRand.nextLong();

src/main/resources/org/polypheny/simpleclient/scenario/vectorbench/vector.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ scenario = "vectorBench"
33
dataStoreFeature = postgresql1
44
dataStoreMeta = hsqldb
55

6+
# PostgreSQL direct connect settings
7+
postgresHost = 127.0.0.1
8+
69
numberOfThreads = 4
710
progressReportBase = 100
811
numberOfWarmUpIterations = 4

0 commit comments

Comments
 (0)