|
12 | 12 | import static java.util.concurrent.TimeUnit.MINUTES; |
13 | 13 |
|
14 | 14 | import java.util.Collections; |
15 | | -import java.util.LinkedHashMap; |
16 | 15 | import java.util.List; |
17 | | -import java.util.Map; |
18 | 16 | import java.util.Optional; |
19 | 17 | import java.util.Set; |
20 | 18 | import java.util.stream.Collectors; |
21 | 19 |
|
22 | 20 | import com.google.common.cache.CacheBuilder; |
23 | 21 | import com.google.common.cache.CacheLoader; |
24 | 22 | import com.google.common.cache.LoadingCache; |
| 23 | +import com.google.common.collect.ImmutableList; |
25 | 24 | import com.google.common.collect.ImmutableSet; |
26 | 25 | import com.google.common.util.concurrent.UncheckedExecutionException; |
27 | 26 | import com.redis.lettucemod.RedisModulesUtils; |
|
30 | 29 | import com.redis.lettucemod.search.AggregateWithCursorResults; |
31 | 30 | import com.redis.lettucemod.search.CreateOptions; |
32 | 31 | import com.redis.lettucemod.search.CursorOptions; |
33 | | -import com.redis.lettucemod.search.Document; |
34 | 32 | import com.redis.lettucemod.search.Field; |
35 | 33 | import com.redis.lettucemod.search.Group; |
36 | 34 | import com.redis.lettucemod.search.IndexInfo; |
@@ -165,23 +163,13 @@ private RediSearchTable loadTableSchema(SchemaTableName schemaTableName) { |
165 | 163 | if (indexInfo.isEmpty()) { |
166 | 164 | throw new TableNotFoundException(schemaTableName, format("Index '%s' not found", index), null); |
167 | 165 | } |
168 | | - Map<String, RediSearchColumnHandle> columns = new LinkedHashMap<>(); |
| 166 | + ImmutableList.Builder<RediSearchColumnHandle> columnHandles = ImmutableList.builder(); |
169 | 167 | for (Field columnMetadata : indexInfo.get().getFields()) { |
170 | | - RediSearchColumnHandle columnHandle = buildColumnHandle(columnMetadata); |
171 | | - columns.put(columnHandle.getName(), columnHandle); |
172 | | - } |
173 | | - |
174 | | - SearchResults<String, String> results = connection.sync().search(index, "*"); |
175 | | - for (Document<String, String> doc : results) { |
176 | | - Set<String> fields = doc.keySet(); |
177 | | - fields.removeAll(columns.keySet()); |
178 | | - for (String field : fields) { |
179 | | - columns.put(field, new RediSearchColumnHandle(field, VarcharType.VARCHAR, false)); |
180 | | - } |
| 168 | + columnHandles.add(buildColumnHandle(columnMetadata)); |
181 | 169 | } |
182 | 170 | RediSearchTableHandle tableHandle = new RediSearchTableHandle(RediSearchTableHandle.Type.SEARCH, |
183 | 171 | schemaTableName); |
184 | | - return new RediSearchTable(tableHandle, columns.values()); |
| 172 | + return new RediSearchTable(tableHandle, columnHandles.build()); |
185 | 173 | } |
186 | 174 |
|
187 | 175 | private Optional<IndexInfo> indexInfo(String index) { |
|
0 commit comments