|
46 | 46 | import java.io.IOException; |
47 | 47 | import java.util.ArrayList; |
48 | 48 | import java.util.Arrays; |
| 49 | +import java.util.Collection; |
49 | 50 | import java.util.Collections; |
50 | 51 | import java.util.Comparator; |
51 | 52 | import java.util.HashMap; |
@@ -1761,15 +1762,118 @@ static SortedMap<String, IndexAbstraction> buildIndicesLookup( |
1761 | 1762 | if (indices.isEmpty()) { |
1762 | 1763 | return Collections.emptySortedMap(); |
1763 | 1764 | } |
1764 | | - SortedMap<String, IndexAbstraction> indicesLookup = new TreeMap<>(); |
| 1765 | + Map<String, IndexAbstraction> indicesLookup = new HashMap<>(); |
1765 | 1766 | Map<String, DataStream> indexToDataStreamLookup = new HashMap<>(); |
1766 | 1767 | collectDataStreams(dataStreamMetadata, indicesLookup, indexToDataStreamLookup); |
1767 | 1768 |
|
1768 | 1769 | Map<String, List<IndexMetadata>> aliasToIndices = new HashMap<>(); |
1769 | 1770 | collectIndices(indices, indexToDataStreamLookup, indicesLookup, aliasToIndices); |
1770 | 1771 | collectAliases(aliasToIndices, indicesLookup); |
1771 | 1772 |
|
1772 | | - return Collections.unmodifiableSortedMap(indicesLookup); |
| 1773 | + return new SortedMap<>() { |
| 1774 | + |
| 1775 | + private final SortedMap<String, IndexAbstraction> map = new TreeMap<>(indicesLookup); |
| 1776 | + |
| 1777 | + @Override |
| 1778 | + public Comparator<? super String> comparator() { |
| 1779 | + return map.comparator(); |
| 1780 | + } |
| 1781 | + |
| 1782 | + @Override |
| 1783 | + public SortedMap<String, IndexAbstraction> subMap(String fromKey, String toKey) { |
| 1784 | + return Collections.unmodifiableSortedMap(map.subMap(fromKey, toKey)); |
| 1785 | + } |
| 1786 | + |
| 1787 | + @Override |
| 1788 | + public SortedMap<String, IndexAbstraction> headMap(String toKey) { |
| 1789 | + return Collections.unmodifiableSortedMap(map.headMap(toKey)); |
| 1790 | + } |
| 1791 | + |
| 1792 | + @Override |
| 1793 | + public SortedMap<String, IndexAbstraction> tailMap(String fromKey) { |
| 1794 | + return Collections.unmodifiableSortedMap(map.tailMap(fromKey)); |
| 1795 | + } |
| 1796 | + |
| 1797 | + @Override |
| 1798 | + public String firstKey() { |
| 1799 | + return map.firstKey(); |
| 1800 | + } |
| 1801 | + |
| 1802 | + @Override |
| 1803 | + public String lastKey() { |
| 1804 | + return map.lastKey(); |
| 1805 | + } |
| 1806 | + |
| 1807 | + @Override |
| 1808 | + public Set<String> keySet() { |
| 1809 | + return Collections.unmodifiableSet(map.keySet()); |
| 1810 | + } |
| 1811 | + |
| 1812 | + @Override |
| 1813 | + public Collection<IndexAbstraction> values() { |
| 1814 | + return Collections.unmodifiableCollection(map.values()); |
| 1815 | + } |
| 1816 | + |
| 1817 | + @Override |
| 1818 | + public Set<Entry<String, IndexAbstraction>> entrySet() { |
| 1819 | + return Collections.unmodifiableSet(map.entrySet()); |
| 1820 | + } |
| 1821 | + |
| 1822 | + @Override |
| 1823 | + public int size() { |
| 1824 | + return indicesLookup.size(); |
| 1825 | + } |
| 1826 | + |
| 1827 | + @Override |
| 1828 | + public boolean isEmpty() { |
| 1829 | + return indicesLookup.isEmpty(); |
| 1830 | + } |
| 1831 | + |
| 1832 | + @Override |
| 1833 | + public boolean containsKey(Object key) { |
| 1834 | + return indicesLookup.containsKey(key); |
| 1835 | + } |
| 1836 | + |
| 1837 | + @Override |
| 1838 | + public boolean containsValue(Object value) { |
| 1839 | + return indicesLookup.containsValue(value); |
| 1840 | + } |
| 1841 | + |
| 1842 | + @Override |
| 1843 | + public IndexAbstraction get(Object key) { |
| 1844 | + return indicesLookup.get(key); |
| 1845 | + } |
| 1846 | + |
| 1847 | + @Override |
| 1848 | + public IndexAbstraction put(String key, IndexAbstraction value) { |
| 1849 | + throw new UnsupportedOperationException(); |
| 1850 | + } |
| 1851 | + |
| 1852 | + @Override |
| 1853 | + public IndexAbstraction remove(Object key) { |
| 1854 | + throw new UnsupportedOperationException(); |
| 1855 | + } |
| 1856 | + |
| 1857 | + @Override |
| 1858 | + public void putAll(Map<? extends String, ? extends IndexAbstraction> m) { |
| 1859 | + throw new UnsupportedOperationException(); |
| 1860 | + } |
| 1861 | + |
| 1862 | + @Override |
| 1863 | + public void clear() { |
| 1864 | + throw new UnsupportedOperationException(); |
| 1865 | + } |
| 1866 | + |
| 1867 | + @Override |
| 1868 | + public boolean equals(Object obj) { |
| 1869 | + return indicesLookup.equals(obj); |
| 1870 | + } |
| 1871 | + |
| 1872 | + @Override |
| 1873 | + public int hashCode() { |
| 1874 | + return indicesLookup.hashCode(); |
| 1875 | + } |
| 1876 | + }; |
1773 | 1877 | } |
1774 | 1878 |
|
1775 | 1879 | private static void collectAliases(Map<String, List<IndexMetadata>> aliasToIndices, Map<String, IndexAbstraction> indicesLookup) { |
|
0 commit comments