@Test public void testGet() { ids.add(store.getOrCreate(new Metric(METRIC1, Collections.singletonList("k1=v1")))); ids.add(store.getOrCreate(new Metric(METRIC2, Collections.singletonList("k1=v1")))); ids.add(store.getOrCreate(new Metric(METRIC1, Collections.singletonList("k1=v2")))); ids.add(store.getOrCreate(new Metric(METRIC2, Collections.singletonList("k1=v2")))); ids.add(store.getOrCreate(new Metric(METRIC2, Arrays.asList("k1=v1", "k2=v1")))); ids.add(store.getOrCreate(new Metric(METRIC3, emptyList()))); assertEquals(6, ids.size()); Set<Integer> deduped = new HashSet<>(ids); assertEquals(deduped.size(), ids.size()); assertEquals(ids.get(0), store.get(new Metric(METRIC1, Collections.singletonList("k1=v1"))).get()); assertEquals(ids.get(1), store.get(new Metric(METRIC2, Collections.singletonList("k1=v1"))).get()); assertEquals(ids.get(2), store.get(new Metric(METRIC1, Collections.singletonList("k1=v2"))).get()); assertEquals(ids.get(3), store.get(new Metric(METRIC2, Collections.singletonList("k1=v2"))).get()); assertEquals(ids.get(4), store.get(new Metric(METRIC2, Arrays.asList("k1=v1", "k2=v1"))).get()); assertEquals(ids.get(4), store.get(new Metric(METRIC2, Arrays.asList("k2=v1", "k1=v1"))).get()); assertEquals(ids.get(5), store.get(new Metric(METRIC3, emptyList())).get()); }
@Override public Optional<Integer> get(Metric m) { if (metricIndex.containsKey(m.fullMetricName)) { return Optional.of(lookupMetricIndex(m.fullMetricName).getIntIterator().next()); } return Optional.empty(); }
InvertedIndexTagStore implements TagStore { @Override public Optional<Integer> get(Metric m) { if (metricIndex.containsKey(m.fullMetricName)) { return Optional.of(lookupMetricIndex(m.fullMetricName).getIntIterator().next()); } return Optional.empty(); } }
InvertedIndexTagStore implements TagStore { @Override public Optional<Integer> get(Metric m) { if (metricIndex.containsKey(m.fullMetricName)) { return Optional.of(lookupMetricIndex(m.fullMetricName).getIntIterator().next()); } return Optional.empty(); } InvertedIndexTagStore();  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory, boolean useOffHeapIdStore,
                               boolean useOffHeapIndexStore); }
InvertedIndexTagStore implements TagStore { @Override public Optional<Integer> get(Metric m) { if (metricIndex.containsKey(m.fullMetricName)) { return Optional.of(lookupMetricIndex(m.fullMetricName).getIntIterator().next()); } return Optional.empty(); } InvertedIndexTagStore();  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory, boolean useOffHeapIdStore,
                               boolean useOffHeapIndexStore); @Override Optional<Integer> get(Metric m); @Override List<Integer> lookup(Query q); RoaringBitmap lookupMetricIndex(String key); @VisibleForTesting Map<Integer, String> getValuesForMetricKey(String metricName, String key); @Override int getOrCreate(final Metric m); @Override String getMetricName(final int metricId); @Override Map<String, Object> getStats(); @Override void close(); @Override boolean isReadOnly(); String getMetricNameFromId(final int id); }
InvertedIndexTagStore implements TagStore { @Override public Optional<Integer> get(Metric m) { if (metricIndex.containsKey(m.fullMetricName)) { return Optional.of(lookupMetricIndex(m.fullMetricName).getIntIterator().next()); } return Optional.empty(); } InvertedIndexTagStore();  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory);  InvertedIndexTagStore(int metricIdMapCapacity, int initialIndexSize,
                               String dataDirectory, boolean useOffHeapIdStore,
                               boolean useOffHeapIndexStore); @Override Optional<Integer> get(Metric m); @Override List<Integer> lookup(Query q); RoaringBitmap lookupMetricIndex(String key); @VisibleForTesting Map<Integer, String> getValuesForMetricKey(String metricName, String key); @Override int getOrCreate(final Metric m); @Override String getMetricName(final int metricId); @Override Map<String, Object> getStats(); @Override void close(); @Override boolean isReadOnly(); String getMetricNameFromId(final int id);  }