it.uniroma3.mat.extendedset.intset.ConciseSet Java Examples

The following examples show how to use it.uniroma3.mat.extendedset.intset.ConciseSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitMapContainer.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@Override
public ConciseSet getBitMap(Integer startId, Integer endId) {
    if (startId == null && endId == null) {
        return sets[this.nValues];
    }

    int start = 0;
    int end = this.nValues - 1;
    if (startId != null) {
        start = startId;
    }
    if (endId != null) {
        end = endId;
    }

    ConciseSet ret = new ConciseSet();
    for (int i = start; i <= end; ++i) {
        ConciseSet temp = getBitMap(i);
        ret.addAll(temp);
    }
    return ret;
}
 
Example #2
Source File: ConciseBitmapFactoryTest.java    From bytebuffer-collections with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetOutOfBounds()
{
  final ConciseSet conciseSet = new ConciseSet();
  final Set<Integer> ints = ImmutableSet.of(0, 4, 9);
  for (int i : ints) {
    conciseSet.add(i);
  }
  final ImmutableBitmap immutableBitmap = new WrappedImmutableConciseBitmap(
      ImmutableConciseSet.newImmutableFromMutable(conciseSet));
  final MutableBitmap mutableBitmap = new WrappedConciseBitmap(conciseSet);
  for (int i = 0; i < 10; ++i) {
    Assert.assertEquals(Integer.toString(i), ints.contains(i), mutableBitmap.get(i));
    Assert.assertEquals(Integer.toString(i), ints.contains(i), immutableBitmap.get(i));
  }
}
 
Example #3
Source File: BitMapFilterEvaluator.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private ConciseSet evalCompare(CompareTupleFilter filter) {
    switch (filter.getOperator()) {
    case ISNULL:
        return evalCompareIsNull(filter);
    case ISNOTNULL:
        return evalCompareIsNotNull(filter);
    case EQ:
        return evalCompareEqual(filter);
    case NEQ:
        return evalCompareNotEqual(filter);
    case IN:
        return evalCompareIn(filter);
    case NOTIN:
        return evalCompareNotIn(filter);
    case LT:
        return evalCompareLT(filter);
    case LTE:
        return evalCompareLTE(filter);
    case GT:
        return evalCompareGT(filter);
    case GTE:
        return evalCompareGTE(filter);
    default:
        throw new IllegalStateException("Unsupported operator " + filter.getOperator());
    }
}
 
Example #4
Source File: IIEndpoint.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private IIProtos.IIResponse getNonAggregatedResponse(Iterable<Slice> slices, CoprocessorFilter filter, CoprocessorRowType type) {
    IIProtos.IIResponse.Builder responseBuilder = IIProtos.IIResponse.newBuilder();
    for (Slice slice : slices) {
        ConciseSet result = null;
        if (filter != null) {
            result = new BitMapFilterEvaluator(new SliceBitMapProvider(slice, type)).evaluate(filter.getFilter());
        }

        Iterator<RawTableRecord> iterator = slice.iterateWithBitmap(result);
        while (iterator.hasNext()) {
            byte[] data = iterator.next().getBytes();
            IIProtos.IIResponse.IIRow.Builder rowBuilder = IIProtos.IIResponse.IIRow.newBuilder().setColumns(ByteString.copyFrom(data));
            responseBuilder.addRows(rowBuilder.build());
        }
    }

    return responseBuilder.build();
}
 
Example #5
Source File: RunArrayAndNotBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toConcise(int[] dat) {
  ConciseSet ans = new ConciseSet();
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #6
Source File: BitMapFilterEvaluatorTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Override
public ConciseSet getBitMap(TblColRef col, Integer startId, Integer endId) {
    if (!col.equals(colA))
        return null;

    // i-th record has value ID i, and last record has value null
    if (startId == null && endId == null) {
        //entry for getting null value
        ConciseSet s = new ConciseSet();
        s.add(getRecordCount() - 1);
        return s;
    }

    int start = 0;
    int end = MAX_ID;
    if (startId != null) {
        start = startId;
    }
    if (endId != null) {
        end = endId;
    }

    ConciseSet ret = new ConciseSet();
    for (int i = start; i <= end; ++i) {
        ConciseSet temp = getBitMap(col, i);
        ret.addAll(temp);
    }
    return ret;
}
 
Example #7
Source File: BitMapFilterEvaluatorTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public ConciseSet getBitMap(TblColRef col, int valueId) {
    if (!col.equals(colA))
        return null;

    // i-th record has value ID i, and last record has value null
    ConciseSet bitMap = new ConciseSet();
    if (valueId < 0 || valueId > getMaxValueId(col)) // null
        bitMap.add(getRecordCount() - 1);
    else
        bitMap.add(valueId);

    return bitMap;
}
 
Example #8
Source File: BitMapFilterEvaluatorTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogicalAnd() {
    for (int i = 0; i < basicFilters.size(); i++) {
        for (int j = 0; j < basicFilters.size(); j++) {
            LogicalTupleFilter f = logical(FilterOperatorEnum.AND, basicFilters.get(i), basicFilters.get(j));
            ConciseSet r = basicResults.get(i).clone();
            r.retainAll(basicResults.get(j));
            assertEquals(r, eval.evaluate(f));
        }
    }
}
 
Example #9
Source File: BitMapFilterEvaluatorTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testLogicalOr() {
    for (int i = 0; i < basicFilters.size(); i++) {
        for (int j = 0; j < basicFilters.size(); j++) {
            LogicalTupleFilter f = logical(FilterOperatorEnum.OR, basicFilters.get(i), basicFilters.get(j));
            ConciseSet r = basicResults.get(i).clone();
            r.addAll(basicResults.get(j));
            assertEquals(r, eval.evaluate(f));
        }
    }
}
 
Example #10
Source File: AllRunHorizontalOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toConcise(int[] dat) {
  ConciseSet ans = new ConciseSet();
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #11
Source File: AllRunHorizontalOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toWAH(int[] dat) {
  ConciseSet ans = new ConciseSet(true);
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #12
Source File: AllRunHorizontalOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Benchmark
public int OrConcise(BenchmarkState benchmarkState) {
  ConciseSet base = benchmarkState.cc.get(0);
  for (int k = 1; k < benchmarkState.cc.size(); ++k)
    base.union(benchmarkState.cc.get(k));
  return base.size();
}
 
Example #13
Source File: AllRunHorizontalOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Benchmark
public int OrWAH(BenchmarkState benchmarkState) {
  ConciseSet base = benchmarkState.wah.get(0);
  for (int k = 1; k < benchmarkState.wah.size(); ++k)
    base.union(benchmarkState.wah.get(k));
  return base.size();
}
 
Example #14
Source File: AllRunHorizontalOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
public BenchmarkState() {
  int N = 30;
  Random rand = new Random(1234);
  for (int k = 0; k < N; ++k) {
    RoaringBitmap rb = new RoaringBitmap();
    int start = rand.nextInt(10000);

    for (int z = 0; z < 50; ++z) {
      int end = start + rand.nextInt(10000);
      rb.add(start, end);
      start = end + rand.nextInt(1000);
    }
    ConciseSet ccs = toConcise(rb.toArray());
    cc.add(ccs);
    wah.add(toWAH(rb.toArray()));
    icc.add(ImmutableConciseSet.newImmutableFromMutable(ccs));

    ac.add(rb);

    rb = rb.clone();
    rb.runOptimize();
    rc.add(rb);
    ewah.add(EWAHCompressedBitmap.bitmapOf(rb.toArray()));
    ewah32.add(EWAHCompressedBitmap32.bitmapOf(rb.toArray()));

  }
}
 
Example #15
Source File: RunArrayXorBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toConcise(int[] dat) {
  ConciseSet ans = new ConciseSet();
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #16
Source File: RunArrayOrBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toConcise(int[] dat) {
  ConciseSet ans = new ConciseSet();
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #17
Source File: BitMapContainer.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private ConciseSet bytesToSet(ImmutableBytesWritable bytes) {
    if (bytes.get() == null || bytes.getLength() == 0) {
        return new ConciseSet();
    } else {
        IntBuffer intBuffer = ByteBuffer.wrap(bytes.get(), bytes.getOffset(), bytes.getLength()).asIntBuffer();
        int[] words = new int[intBuffer.capacity()];
        intBuffer.get(words);
        return new ConciseSet(words, false);
    }
}
 
Example #18
Source File: RunArrayAndBenchmark.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
static ConciseSet toConcise(int[] dat) {
  ConciseSet ans = new ConciseSet();
  for (int i : dat) {
    ans.add(i);
  }
  return ans;
}
 
Example #19
Source File: BitmapFactory.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
private static ConciseSet newConciseSet(int[] data, boolean simulateWAH) {
  ConciseSet concise = new ConciseSet(simulateWAH);
  for (int i : data) {
    concise.add(i);
  }
  return concise;
}
 
Example #20
Source File: ConciseSetWrapper.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Override
public BitmapAggregator naiveAndAggregator() {
  return new BitmapAggregator() {
    @Override
    public Bitmap aggregate(Iterable<Bitmap> bitmaps) {
      final Iterator<Bitmap> i = bitmaps.iterator();
      ConciseSet bitmap = ((ConciseSetWrapper) i.next()).bitmap;
      while (i.hasNext()) {
        bitmap = bitmap.intersection(((ConciseSetWrapper) i.next()).bitmap);
      }
      return new ConciseSetWrapper(bitmap);
    }
  };
}
 
Example #21
Source File: ConciseSetWrapper.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Override
public BitmapAggregator naiveOrAggregator() {
  return new BitmapAggregator() {
    @Override
    public Bitmap aggregate(Iterable<Bitmap> bitmaps) {
      final Iterator<Bitmap> i = bitmaps.iterator();
      ConciseSet bitmap = ((ConciseSetWrapper) i.next()).bitmap;
      while (i.hasNext()) {
        bitmap = bitmap.union(((ConciseSetWrapper) i.next()).bitmap);
      }
      return new ConciseSetWrapper(bitmap);
    }
  };
}
 
Example #22
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public void or(MutableBitmap mutableBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) mutableBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  bitmap.addAll(unwrappedOtherBitmap);
}
 
Example #23
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public void and(MutableBitmap mutableBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) mutableBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  bitmap = bitmap.intersection(unwrappedOtherBitmap);
}
 
Example #24
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public void xor(MutableBitmap mutableBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) mutableBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  bitmap = bitmap.symmetricDifference(unwrappedOtherBitmap);
}
 
Example #25
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public void andNot(MutableBitmap mutableBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) mutableBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  bitmap = bitmap.difference(unwrappedOtherBitmap);
}
 
Example #26
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableBitmap union(ImmutableBitmap otherBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) otherBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  return new WrappedConciseBitmap(bitmap.clone().union(unwrappedOtherBitmap));
}
 
Example #27
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableBitmap intersection(ImmutableBitmap otherBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) otherBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  return new WrappedConciseBitmap(bitmap.clone().intersection(unwrappedOtherBitmap));
}
 
Example #28
Source File: WrappedConciseBitmap.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableBitmap difference(ImmutableBitmap otherBitmap)
{
  WrappedConciseBitmap other = (WrappedConciseBitmap) otherBitmap;
  ConciseSet unwrappedOtherBitmap = other.bitmap;
  return new WrappedConciseBitmap(bitmap.clone().difference(unwrappedOtherBitmap));
}
 
Example #29
Source File: BitMapFilterEvaluator.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private void not(ConciseSet set) {
    if (set == null)
        return;

    set.add(provider.getRecordCount());
    set.complement();
}
 
Example #30
Source File: BitMapFilterEvaluator.java    From Kylin with Apache License 2.0 5 votes vote down vote up
/**
 * @param filter
 * @return a set of records that match the filter; or null if filter is null or unable to evaluate
 */
public ConciseSet evaluate(TupleFilter filter) {
    if (filter == null)
        return null;

    if (filter instanceof LogicalTupleFilter)
        return evalLogical((LogicalTupleFilter) filter);

    if (filter instanceof CompareTupleFilter)
        return evalCompare((CompareTupleFilter) filter);

    return null; // unable to evaluate
}