예제 #1
0
  @Override
  public IndexedInts getBitmapIndex(String dimension, int index) {
    DimensionIndexer accessor = indexers.get(dimension);
    if (accessor == null) {
      return EmptyIndexedInts.EMPTY_INDEXED_INTS;
    }

    IncrementalIndex.SortedDimLookup dimLookup = accessor.getDimLookup();
    final int id = dimLookup.getUnsortedIdFromSortedId(index);
    if (id < 0 || id >= dimLookup.size()) {
      return EmptyIndexedInts.EMPTY_INDEXED_INTS;
    }

    MutableBitmap bitmapIndex = accessor.invertedIndexes[id];

    if (bitmapIndex == null) {
      return EmptyIndexedInts.EMPTY_INDEXED_INTS;
    }

    return new BitmapIndexedInts(bitmapIndex);
  }
예제 #2
0
  @Override
  public Indexed<String> getDimValueLookup(String dimension) {
    final DimensionIndexer indexer = indexers.get(dimension);
    if (indexer == null) {
      return null;
    }
    final IncrementalIndex.DimDim dimDim = indexer.getDimValues();
    final IncrementalIndex.SortedDimLookup dimLookup = indexer.getDimLookup();

    return new Indexed<String>() {
      @Override
      public Class<? extends String> getClazz() {
        return String.class;
      }

      @Override
      public int size() {
        return dimLookup.size();
      }

      @Override
      public String get(int index) {
        Comparable val = dimLookup.getValueFromSortedId(index);
        String strVal = val != null ? val.toString() : null;
        return strVal;
      }

      @Override
      public int indexOf(String value) {
        int id = dimDim.getId(value);
        return id < 0 ? -1 : dimLookup.getSortedIdFromUnsortedId(id);
      }

      @Override
      public Iterator<String> iterator() {
        return IndexedIterable.create(this).iterator();
      }
    };
  }