Java Code Examples for com.googlecode.javaewah.EWAHCompressedBitmap#and()

The following examples show how to use com.googlecode.javaewah.EWAHCompressedBitmap#and() . 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: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 2
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLClass c, OWLClass d) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	EWAHCompressedBitmap cad = bmc.and(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 3
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Set<Node<OWLClass>> getNamedCommonSubsumers(int cix, int dix) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix);
	EWAHCompressedBitmap cad = bmc.and(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 4
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLNamedIndividual i,
		OWLNamedIndividual j) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = bmc.and(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 5
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EWAHCompressedBitmap getNamedLowestCommonSubsumersAsBitmap(OWLClass c,
		OWLClass d) throws UnknownOWLClassException  {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	EWAHCompressedBitmap cad = bmc.and(bmd);	
	int[] csInts = cad.toArray();
	for (int ix : csInts) {
		cad = cad.andNot(ancsProperBitmapCachedModifiable(classArray[ix]));
	}
	return cad;
}
 
Example 6
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private EWAHCompressedBitmap getNamedLowestCommonSubsumersAsBitmap(int cix, int dix)
		throws UnknownOWLClassException  {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix);
	EWAHCompressedBitmap cad = bmc.and(bmd);	
	int[] csInts = cad.toArray();
	for (int ix : csInts) {
		cad = cad.andNot(ancsProperBitmapCachedModifiable(classArray[ix]));
	}
	return cad;
}
 
Example 7
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 8
Source File: SimSpeedTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLClass c, OWLClass d) {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(c);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(d);
	EWAHCompressedBitmap cad = bmc.and(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 9
Source File: EwahBitmapWrapper.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();
      EWAHCompressedBitmap bitmap = ((EwahBitmapWrapper) i.next()).bitmap;
      while (i.hasNext()) {
        bitmap = bitmap.and(((EwahBitmapWrapper) i.next()).bitmap);
      }
      return new EwahBitmapWrapper(bitmap);
    }
  };
}
 
Example 10
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private EWAHCompressedBitmap getNamedCommonSubsumersAsBitmap(int cix, int dix) throws UnknownOWLClassException {
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(cix);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(dix);
	EWAHCompressedBitmap cad = bmc.and(bmd);
	return cad;
}