Skip to content

Commit 71d4377

Browse files
authored
Merge pull request #117 from cirnoooo123/main
init spatialTestBench
2 parents 4f6f108 + 5dec0ed commit 71d4377

File tree

15 files changed

+3437
-188
lines changed

15 files changed

+3437
-188
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.hufudb.openhufu.benchmark.enums;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
/**
7+
* @author yang.song
8+
* @date 2/15/23 1:45 AM
9+
*/
10+
public enum SpatialTableName {
11+
SPATIAL("spatial");
12+
SpatialTableName(String name) {
13+
this.name = name;
14+
}
15+
private final String name;
16+
private static final Set<SpatialTableName> tableNameSet;
17+
18+
static {
19+
tableNameSet = new HashSet<>();
20+
tableNameSet.add(SPATIAL);
21+
}
22+
23+
public String getName() {
24+
return name;
25+
}
26+
27+
public Set<SpatialTableName> getSpatialTableNames() {
28+
return tableNameSet;
29+
}
30+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.hufudb.openhufu.benchmark;
2+
3+
import com.google.common.collect.ImmutableList;
4+
import com.google.common.reflect.TypeToken;
5+
import com.google.gson.Gson;
6+
import com.hufudb.openhufu.benchmark.enums.SpatialTableName;
7+
import com.hufudb.openhufu.benchmark.enums.TPCHTableName;
8+
import com.hufudb.openhufu.core.table.GlobalTableConfig;
9+
import com.hufudb.openhufu.data.schema.Schema;
10+
import com.hufudb.openhufu.data.storage.DataSet;
11+
import com.hufudb.openhufu.data.storage.DataSetIterator;
12+
import com.hufudb.openhufu.expression.AggFuncType;
13+
import com.hufudb.openhufu.expression.ExpressionFactory;
14+
import com.hufudb.openhufu.owner.user.OpenHuFuUser;
15+
import com.hufudb.openhufu.plan.BinaryPlan;
16+
import com.hufudb.openhufu.plan.LeafPlan;
17+
import com.hufudb.openhufu.proto.OpenHuFuData.ColumnType;
18+
import com.hufudb.openhufu.proto.OpenHuFuData.Modifier;
19+
import com.hufudb.openhufu.proto.OpenHuFuPlan;
20+
import com.hufudb.openhufu.proto.OpenHuFuPlan.Collation;
21+
import com.hufudb.openhufu.proto.OpenHuFuPlan.JoinCondition;
22+
import com.hufudb.openhufu.proto.OpenHuFuPlan.JoinType;
23+
import org.junit.BeforeClass;
24+
import org.junit.Test;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
28+
import java.io.IOException;
29+
import java.nio.file.Files;
30+
import java.nio.file.Path;
31+
import java.util.ArrayList;
32+
import java.util.List;
33+
34+
import static org.junit.Assert.assertEquals;
35+
36+
public class OpenHuFuSpatialBenchmarkTest {
37+
private static final Logger LOG = LoggerFactory.getLogger(OpenHuFuBenchmark.class);
38+
private static final OpenHuFuUser user = new OpenHuFuUser();
39+
40+
@BeforeClass
41+
public static void setUp() throws IOException {
42+
43+
List<String> endpoints =
44+
new Gson().fromJson(Files.newBufferedReader(
45+
Path.of(OpenHuFuBenchmark.class.getClassLoader().getResource("spatialEndpoints.json")
46+
.getPath())),
47+
new TypeToken<ArrayList<String>>() {
48+
}.getType());
49+
List<GlobalTableConfig> globalTableConfigs =
50+
new Gson().fromJson(Files.newBufferedReader(
51+
Path.of(OpenHuFuBenchmark.class.getClassLoader().getResource("spatialTables.json")
52+
.getPath())),
53+
new TypeToken<ArrayList<GlobalTableConfig>>() {
54+
}.getType());
55+
LOG.info("Init benchmark of OpenHuFuSpatial...");
56+
for (String endpoint : endpoints) {
57+
user.addOwner(endpoint, null);
58+
}
59+
60+
for (GlobalTableConfig config : globalTableConfigs) {
61+
user.createOpenHuFuTable(config);
62+
}
63+
LOG.info("Init finish");
64+
}
65+
66+
@Test
67+
public void testSelect() {
68+
String tableName = SpatialTableName.SPATIAL.getName();
69+
LeafPlan plan = new LeafPlan();
70+
plan.setTableName(tableName);
71+
plan.setSelectExps(ExpressionFactory
72+
.createInputRef(user.getOpenHuFuTableSchema(tableName).getSchema()));
73+
DataSet dataset = user.executeQuery(plan);
74+
DataSetIterator it = dataset.getIterator();
75+
long count = 0;
76+
while (it.next()) {
77+
for (int i = 0; i < it.size(); i++) {
78+
System.out.print(it.get(i) + "|");
79+
}
80+
System.out.println();
81+
++count;
82+
}
83+
assertEquals(3000, count);
84+
dataset.close();
85+
}
86+
87+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
"localhost:12345",
3+
"localhost:12346",
4+
"localhost:12347"
5+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"tableName": "spatial",
4+
"localTables": [
5+
{
6+
"endpoint": "localhost:12345",
7+
"localName": "spatial"
8+
},
9+
{
10+
"endpoint": "localhost:12346",
11+
"localName": "spatial"
12+
},
13+
{
14+
"endpoint": "localhost:12347",
15+
"localName": "spatial"
16+
}
17+
]
18+
}
19+
]

0 commit comments

Comments
 (0)