|
29 | 29 | import jsinterop.annotations.JsType; |
30 | 30 | import jsinterop.base.Js; |
31 | 31 |
|
32 | | -import java.util.ArrayList; |
33 | | -import java.util.HashMap; |
34 | | -import java.util.List; |
35 | | -import java.util.Map; |
| 32 | +import java.util.*; |
36 | 33 |
|
37 | 34 | /** |
38 | 35 | * Represents a set of Tables each corresponding to some key. The keys are available locally, but a call must be made to |
@@ -95,19 +92,25 @@ public Promise<JsPartitionedTable> refetch() { |
95 | 92 | WebBarrageUtils.readSchemaMessage(descriptor.getConstituentDefinitionSchema_asU8())); |
96 | 93 | ColumnDefinition[] columnDefinitions = tableDefinition.getColumns(); |
97 | 94 | Column[] columns = new Column[0]; |
98 | | - Column[] keyColumns = new Column[0]; |
99 | 95 | for (int i = 0; i < columnDefinitions.length; i++) { |
100 | 96 | ColumnDefinition columnDefinition = columnDefinitions[i]; |
101 | 97 | Column column = columnDefinition.makeJsColumn(columns.length, tableDefinition.getColumnsByName()); |
102 | 98 | columns[columns.length] = column; |
103 | | - if (descriptor.getKeyColumnNamesList().indexOf(columnDefinition.getName()) != -1) { |
104 | | - keyColumnTypes.add(columnDefinition.getType()); |
105 | | - keyColumns[keyColumns.length] = column; |
| 99 | + } |
| 100 | + Column[] keyColumns = new Column[0]; |
| 101 | + JsArray<String> keyColumnNames = descriptor.getKeyColumnNamesList(); |
| 102 | + for (int i = 0; i < keyColumnNames.length; i++) { |
| 103 | + String name = keyColumnNames.getAt(i); |
| 104 | + ColumnDefinition columnDefinition = tableDefinition.getColumnsByName().get(false).get(name); |
| 105 | + int index = 0; |
| 106 | + while (!columns[index].getName().equals(name)) { |
| 107 | + index++; |
106 | 108 | } |
| 109 | + keyColumnTypes.add(columnDefinition.getType()); |
| 110 | + keyColumns[keyColumns.length] = columns[index]; |
107 | 111 | } |
108 | 112 | this.columns = JsObject.freeze(columns); |
109 | 113 | this.keyColumns = JsObject.freeze(keyColumns); |
110 | | - |
111 | 114 | return w.getExportedObjects()[0].fetch(); |
112 | 115 | }).then(result -> { |
113 | 116 | keys = (JsTable) result; |
|
0 commit comments