-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from cirnoooo123/main
init spatialTestBench
- Loading branch information
Showing
15 changed files
with
3,437 additions
and
188 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
benchmark/src/main/java/com/hufudb/openhufu/benchmark/enums/SpatialTableName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.hufudb.openhufu.benchmark.enums; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author yang.song | ||
* @date 2/15/23 1:45 AM | ||
*/ | ||
public enum SpatialTableName { | ||
SPATIAL("spatial"); | ||
SpatialTableName(String name) { | ||
this.name = name; | ||
} | ||
private final String name; | ||
private static final Set<SpatialTableName> tableNameSet; | ||
|
||
static { | ||
tableNameSet = new HashSet<>(); | ||
tableNameSet.add(SPATIAL); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Set<SpatialTableName> getSpatialTableNames() { | ||
return tableNameSet; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
benchmark/src/test/java/com/hufudb/openhufu/benchmark/OpenHuFuSpatialBenchmarkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.hufudb.openhufu.benchmark; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.reflect.TypeToken; | ||
import com.google.gson.Gson; | ||
import com.hufudb.openhufu.benchmark.enums.SpatialTableName; | ||
import com.hufudb.openhufu.benchmark.enums.TPCHTableName; | ||
import com.hufudb.openhufu.core.table.GlobalTableConfig; | ||
import com.hufudb.openhufu.data.schema.Schema; | ||
import com.hufudb.openhufu.data.storage.DataSet; | ||
import com.hufudb.openhufu.data.storage.DataSetIterator; | ||
import com.hufudb.openhufu.expression.AggFuncType; | ||
import com.hufudb.openhufu.expression.ExpressionFactory; | ||
import com.hufudb.openhufu.owner.user.OpenHuFuUser; | ||
import com.hufudb.openhufu.plan.BinaryPlan; | ||
import com.hufudb.openhufu.plan.LeafPlan; | ||
import com.hufudb.openhufu.proto.OpenHuFuData.ColumnType; | ||
import com.hufudb.openhufu.proto.OpenHuFuData.Modifier; | ||
import com.hufudb.openhufu.proto.OpenHuFuPlan; | ||
import com.hufudb.openhufu.proto.OpenHuFuPlan.Collation; | ||
import com.hufudb.openhufu.proto.OpenHuFuPlan.JoinCondition; | ||
import com.hufudb.openhufu.proto.OpenHuFuPlan.JoinType; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class OpenHuFuSpatialBenchmarkTest { | ||
private static final Logger LOG = LoggerFactory.getLogger(OpenHuFuBenchmark.class); | ||
private static final OpenHuFuUser user = new OpenHuFuUser(); | ||
|
||
@BeforeClass | ||
public static void setUp() throws IOException { | ||
|
||
List<String> endpoints = | ||
new Gson().fromJson(Files.newBufferedReader( | ||
Path.of(OpenHuFuBenchmark.class.getClassLoader().getResource("spatialEndpoints.json") | ||
.getPath())), | ||
new TypeToken<ArrayList<String>>() { | ||
}.getType()); | ||
List<GlobalTableConfig> globalTableConfigs = | ||
new Gson().fromJson(Files.newBufferedReader( | ||
Path.of(OpenHuFuBenchmark.class.getClassLoader().getResource("spatialTables.json") | ||
.getPath())), | ||
new TypeToken<ArrayList<GlobalTableConfig>>() { | ||
}.getType()); | ||
LOG.info("Init benchmark of OpenHuFuSpatial..."); | ||
for (String endpoint : endpoints) { | ||
user.addOwner(endpoint, null); | ||
} | ||
|
||
for (GlobalTableConfig config : globalTableConfigs) { | ||
user.createOpenHuFuTable(config); | ||
} | ||
LOG.info("Init finish"); | ||
} | ||
|
||
@Test | ||
public void testSelect() { | ||
String tableName = SpatialTableName.SPATIAL.getName(); | ||
LeafPlan plan = new LeafPlan(); | ||
plan.setTableName(tableName); | ||
plan.setSelectExps(ExpressionFactory | ||
.createInputRef(user.getOpenHuFuTableSchema(tableName).getSchema())); | ||
DataSet dataset = user.executeQuery(plan); | ||
DataSetIterator it = dataset.getIterator(); | ||
long count = 0; | ||
while (it.next()) { | ||
for (int i = 0; i < it.size(); i++) { | ||
System.out.print(it.get(i) + "|"); | ||
} | ||
System.out.println(); | ||
++count; | ||
} | ||
assertEquals(3000, count); | ||
dataset.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"localhost:12345", | ||
"localhost:12346", | ||
"localhost:12347" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"tableName": "spatial", | ||
"localTables": [ | ||
{ | ||
"endpoint": "localhost:12345", | ||
"localName": "spatial" | ||
}, | ||
{ | ||
"endpoint": "localhost:12346", | ||
"localName": "spatial" | ||
}, | ||
{ | ||
"endpoint": "localhost:12347", | ||
"localName": "spatial" | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.