Java Code Examples for com.googlecode.javaewah.EWAHCompressedBitmap#or()
The following examples show how to use
com.googlecode.javaewah.EWAHCompressedBitmap#or() .
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: SparseBitmap.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
/** * Creates a new SparseBitmap that is the logical <code>or</code> of all the given bitmaps. * * @param bitmaps Bitmaps to compute the logical <code>or</code> for * @return SparseBitmap that has the values set according to the <code>or</code> of the given * bitmaps. */ public static SparseBitmap batchOr(final SparseBitmap... bitmaps) { if (bitmaps.length < 1) { return SparseBitmap.createFromUnsortedData(); } if (bitmaps.length < 2) { return bitmaps[0]; } EWAHCompressedBitmap firstMap = bitmaps[0].bitmap; for (int index = 1; index < bitmaps.length; ++index) { firstMap = firstMap.or(bitmaps[index].bitmap); } return new SparseBitmap(firstMap); }
Example 2
Source File: SparseBitmap.java From nem.core with MIT License | 6 votes |
/** * Creates a new SparseBitmap that is the logical <code>or</code> of all the given bitmaps. * * @param bitmaps Bitmaps to compute the logical <code>or</code> for * @return SparseBitmap that has the values set according to the <code>or</code> of the given bitmaps. */ public static SparseBitmap batchOr(final SparseBitmap... bitmaps) { if (bitmaps.length < 1) { return SparseBitmap.createFromUnsortedData(); } if (bitmaps.length < 2) { return bitmaps[0]; } EWAHCompressedBitmap firstMap = bitmaps[0].bitmap; for (int index = 1; index < bitmaps.length; ++index) { firstMap = firstMap.or(bitmaps[index].bitmap); } return new SparseBitmap(firstMap); }
Example 3
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private double getAttributeGraphInformationContentSimilarity( int cix, int dix) throws UnknownOWLClassException { long t = System.currentTimeMillis(); EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix); EWAHCompressedBitmap cad = bmc.and(bmd); EWAHCompressedBitmap cud = bmc.or(bmd); double sumICboth = 0; double sumICunion = 0; // faster than translating to integer list IntIterator it = cud.intIterator(); while (it.hasNext()) { int x = it.next(); double ic = getInformationContentForAttribute(x); // TODO - we can avoid doing this twice by using xor in the bitmap sumICunion += ic; if (cad.get(x)) { sumICboth += ic; } } totalTimeGIC += tdelta(t); this.totalCallsGIC++; return sumICboth / sumICunion; }
Example 4
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Set<Node<OWLClass>> getNamedUnionSubsumers(OWLClass c, OWLClass d) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d); EWAHCompressedBitmap cud = bmc.or(bmd); Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>(); for (int ix : cud.toArray()) { OWLClassNode node = new OWLClassNode(classArray[ix]); nodes.add(node); } return nodes; }
Example 5
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Set<Node<OWLClass>> getNamedUnionSubsumers(OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); EWAHCompressedBitmap cad = bmc.or(bmd); Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>(); for (int ix : cad.toArray()) { OWLClassNode node = new OWLClassNode(classArray[ix]); nodes.add(node); } return nodes; }
Example 6
Source File: FastOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public double getElementGraphInformationContentSimilarity( OWLNamedIndividual i, OWLNamedIndividual j) throws UnknownOWLClassException { // TODO - optimize long t = System.currentTimeMillis(); EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i); EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j); EWAHCompressedBitmap cad = bmc.and(bmd); EWAHCompressedBitmap cud = bmc.or(bmd); //Set<Node<OWLClass>> ci = getNamedCommonSubsumers(i, j); //Set<Node<OWLClass>> cu = getNamedUnionSubsumers(i, j); double sumICboth = 0; double sumICunion = 0; // faster than translating to integer list IntIterator it = cud.intIterator(); while (it.hasNext()) { int x = it.next(); double ic = getInformationContentForAttribute(x); // TODO - we can avoid doing this twice by using xor in the bitmap sumICunion += ic; if (cad.get(x)) { sumICboth += ic; } } totalTimeGIC += tdelta(t); this.totalCallsGIC++; return sumICboth / sumICunion; }
Example 7
Source File: AllRunHorizontalOrBenchmark.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Benchmark public int horizontalOr_EWAH(BenchmarkState benchmarkState) { EWAHCompressedBitmap[] a = new EWAHCompressedBitmap[benchmarkState.ewah.size()]; EWAHCompressedBitmap bitmapor = EWAHCompressedBitmap.or(benchmarkState.ewah.toArray(a)); int answer = bitmapor.cardinality(); return answer; }
Example 8
Source File: EwahBitmapWrapper.java From RoaringBitmap with Apache License 2.0 | 5 votes |
@Override public BitmapAggregator naiveOrAggregator() { return new BitmapAggregator() { @Override public Bitmap aggregate(Iterable<Bitmap> bitmaps) { final Iterator<Bitmap> i = bitmaps.iterator(); EWAHCompressedBitmap bitmap = ((EwahBitmapWrapper) i.next()).bitmap; while (i.hasNext()) { bitmap = bitmap.or(((EwahBitmapWrapper) i.next()).bitmap); } return new EwahBitmapWrapper(bitmap); } }; }