1 | /* | |
2 | * | |
3 | * * Copyright OpenSearch Contributors | |
4 | * * SPDX-License-Identifier: Apache-2.0 | |
5 | * | |
6 | */ | |
7 | ||
8 | package org.opensearch.sql.planner.physical.catalog; | |
9 | ||
10 | import com.google.common.collect.ImmutableMap; | |
11 | import java.util.ArrayList; | |
12 | import java.util.Collections; | |
13 | import java.util.Iterator; | |
14 | import java.util.LinkedHashMap; | |
15 | import java.util.List; | |
16 | import java.util.Set; | |
17 | import org.opensearch.sql.catalog.CatalogService; | |
18 | import org.opensearch.sql.catalog.model.Catalog; | |
19 | import org.opensearch.sql.data.model.ExprTupleValue; | |
20 | import org.opensearch.sql.data.model.ExprValue; | |
21 | import org.opensearch.sql.data.model.ExprValueUtils; | |
22 | import org.opensearch.sql.storage.TableScanOperator; | |
23 | ||
24 | /** | |
25 | * This class handles table scan of catalog table. | |
26 | * Right now these are derived from catalogService thorough static fields. | |
27 | * In future this might scan data from underlying datastore if we start | |
28 | * persisting catalog info somewhere. | |
29 | * | |
30 | */ | |
31 | public class CatalogTableScan extends TableScanOperator { | |
32 | ||
33 | private final CatalogService catalogService; | |
34 | ||
35 | private Iterator<ExprValue> iterator; | |
36 | ||
37 | public CatalogTableScan(CatalogService catalogService) { | |
38 | this.catalogService = catalogService; | |
39 | this.iterator = Collections.emptyIterator(); | |
40 | } | |
41 | ||
42 | @Override | |
43 | public String explain() { | |
44 |
1
1. explain : replaced return value with "" for org/opensearch/sql/planner/physical/catalog/CatalogTableScan::explain → KILLED |
return "GetCatalogRequestRequest{}"; |
45 | } | |
46 | ||
47 | @Override | |
48 | public void open() { | |
49 | List<ExprValue> exprValues = new ArrayList<>(); | |
50 | Set<Catalog> catalogs = catalogService.getCatalogs(); | |
51 | for (Catalog catalog : catalogs) { | |
52 | exprValues.add( | |
53 | new ExprTupleValue(new LinkedHashMap<>(ImmutableMap.of( | |
54 | "DATASOURCE_NAME", ExprValueUtils.stringValue(catalog.getName()), | |
55 | "CONNECTOR_TYPE", ExprValueUtils.stringValue(catalog.getConnectorType().name()))))); | |
56 | } | |
57 | iterator = exprValues.iterator(); | |
58 | } | |
59 | ||
60 | @Override | |
61 | public boolean hasNext() { | |
62 |
2
1. hasNext : replaced boolean return with false for org/opensearch/sql/planner/physical/catalog/CatalogTableScan::hasNext → KILLED 2. hasNext : replaced boolean return with true for org/opensearch/sql/planner/physical/catalog/CatalogTableScan::hasNext → KILLED |
return iterator.hasNext(); |
63 | } | |
64 | ||
65 | @Override | |
66 | public ExprValue next() { | |
67 |
1
1. next : replaced return value with null for org/opensearch/sql/planner/physical/catalog/CatalogTableScan::next → KILLED |
return iterator.next(); |
68 | } | |
69 | ||
70 | } | |
Mutations | ||
44 |
1.1 |
|
62 |
1.1 2.2 |
|
67 |
1.1 |