Search in sources :

Example 91 with BitSet

use of java.util.BitSet in project lucene-solr by apache.

the class GeoPolygonTest method testGeoConcaveRelationshipCase1.

@Test
public void testGeoConcaveRelationshipCase1() {
    /*
   [junit4]   1> doc=906 matched but should not
   [junit4]   1>   point=[lat=-0.9825762558001477, lon=2.4832136904725273]
   [junit4]   1>   quantized=[X=-0.4505446160475436, Y=0.34850109186970535, Z=-0.8539966368663765]

doc=906 added here:

   [junit4]   1>   cycle: cell=107836 parentCellID=107835 x: -1147288468 TO -742350917, y: -1609508490 TO 1609508490, z: -2147483647 TO 2147483647, splits: 3 queue.size()=1
   [junit4]   1>     minx=-0.6107484000858642 maxx=-0.39518364125756916 miny=-0.8568069517709872 maxy=0.8568069517709872 minz=-1.1431930485939341 maxz=1.1431930485939341
   [junit4]   1>     GeoArea.CONTAINS: now addAll

shape:
   [junit4]   1> TEST: iter=18 shape=GeoCompositeMembershipShape: {[GeoConvexPolygon: {
   planetmodel=PlanetModel(ab=0.8568069516722363 c=1.1431930483277637), points=
   [[lat=1.1577814487635816, lon=1.6283601832010004],
   [lat=0.6664570999069251, lon=2.0855825542851574],
   [lat=-0.23953537010974632, lon=1.8498724094352876]]}, GeoConcavePolygon: {planetmodel=PlanetModel(ab=0.8568069516722363 c=1.1431930483277637), points=
   [[lat=1.1577814487635816, lon=1.6283601832010004],
   [lat=-0.23953537010974632, lon=1.8498724094352876],
   [lat=-1.1766904875978805, lon=-2.1346828411344436]]}]}
    */
    PlanetModel pm = new PlanetModel(0.8568069516722363, 1.1431930483277637);
    // Build the polygon
    GeoCompositeMembershipShape c = new GeoCompositeMembershipShape();
    List<GeoPoint> points1 = new ArrayList<>();
    points1.add(new GeoPoint(pm, 1.1577814487635816, 1.6283601832010004));
    points1.add(new GeoPoint(pm, 0.6664570999069251, 2.0855825542851574));
    points1.add(new GeoPoint(pm, -0.23953537010974632, 1.8498724094352876));
    BitSet p1bits = new BitSet();
    c.addShape(new GeoConvexPolygon(pm, points1, p1bits, true));
    List<GeoPoint> points2 = new ArrayList<>();
    points2.add(new GeoPoint(pm, 1.1577814487635816, 1.6283601832010004));
    points2.add(new GeoPoint(pm, -0.23953537010974632, 1.8498724094352876));
    points2.add(new GeoPoint(pm, -1.1766904875978805, -2.1346828411344436));
    BitSet p2bits = new BitSet();
    p2bits.set(1, true);
    c.addShape(new GeoConcavePolygon(pm, points2, p2bits, false));
    //System.out.println(c);
    GeoPoint point = new GeoPoint(pm, -0.9825762558001477, 2.4832136904725273);
    GeoPoint quantizedPoint = new GeoPoint(-0.4505446160475436, 0.34850109186970535, -0.8539966368663765);
    GeoArea xyzSolid = GeoAreaFactory.makeGeoArea(pm, -0.6107484000858642, -0.39518364125756916, -0.8568069517709872, 0.8568069517709872, -1.1431930485939341, 1.1431930485939341);
    //System.out.println("relationship = "+xyzSolid.getRelationship(c));
    assertTrue(xyzSolid.getRelationship(c) == GeoArea.OVERLAPS);
}
Also used : ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) Test(org.junit.Test)

Example 92 with BitSet

use of java.util.BitSet in project lucene-solr by apache.

the class BaseDocIdSetTestCase method test2Bits.

/** Test length=2. */
public void test2Bits() throws IOException {
    final BitSet bs = new BitSet(2);
    if (random().nextBoolean()) {
        bs.set(0);
    }
    if (random().nextBoolean()) {
        bs.set(1);
    }
    final T copy = copyOf(bs, 2);
    assertEquals(2, bs, copy);
}
Also used : BitSet(java.util.BitSet)

Example 93 with BitSet

use of java.util.BitSet in project lucene-solr by apache.

the class BaseDocIdSetTestCase method testAgainstBitSet.

/** Compare the content of the set against a {@link BitSet}. */
public void testAgainstBitSet() throws IOException {
    final int numBits = TestUtil.nextInt(random(), 100, 1 << 20);
    // test various random sets with various load factors
    for (float percentSet : new float[] { 0f, 0.0001f, random().nextFloat(), 0.9f, 1f }) {
        final BitSet set = randomSet(numBits, percentSet);
        final T copy = copyOf(set, numBits);
        assertEquals(numBits, set, copy);
    }
    // test one doc
    BitSet set = new BitSet(numBits);
    // 0 first
    set.set(0);
    T copy = copyOf(set, numBits);
    assertEquals(numBits, set, copy);
    set.clear(0);
    set.set(random().nextInt(numBits));
    // then random index
    copy = copyOf(set, numBits);
    assertEquals(numBits, set, copy);
    // test regular increments
    for (int inc = 2; inc < 1000; inc += TestUtil.nextInt(random(), 1, 100)) {
        set = new BitSet(numBits);
        for (int d = random().nextInt(10); d < numBits; d += inc) {
            set.set(d);
        }
        copy = copyOf(set, numBits);
        assertEquals(numBits, set, copy);
    }
}
Also used : BitSet(java.util.BitSet)

Example 94 with BitSet

use of java.util.BitSet in project lucene-solr by apache.

the class BaseDocIdSetTestCase method test1Bit.

/** Test length=1. */
public void test1Bit() throws IOException {
    final BitSet bs = new BitSet(1);
    if (random().nextBoolean()) {
        bs.set(0);
    }
    final T copy = copyOf(bs, 1);
    assertEquals(1, bs, copy);
}
Also used : BitSet(java.util.BitSet)

Example 95 with BitSet

use of java.util.BitSet in project phoenix by apache.

the class PhoenixPreparedStatement method getParameterMetaData.

@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
    int paramCount = statement.getBindCount();
    List<Object> params = this.getParameters();
    BitSet unsetParams = new BitSet(statement.getBindCount());
    for (int i = 0; i < paramCount; i++) {
        if (params.get(i) == BindManager.UNBOUND_PARAMETER) {
            unsetParams.set(i);
            params.set(i, null);
        }
    }
    try {
        StatementPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE);
        return plan.getParameterMetaData();
    } finally {
        int lastSetBit = 0;
        while ((lastSetBit = unsetParams.nextSetBit(lastSetBit)) != -1) {
            params.set(lastSetBit, BindManager.UNBOUND_PARAMETER);
            lastSetBit++;
        }
    }
}
Also used : StatementPlan(org.apache.phoenix.compile.StatementPlan) BitSet(java.util.BitSet)

Aggregations

BitSet (java.util.BitSet)2037 Test (org.junit.Test)294 ArrayList (java.util.ArrayList)224 List (java.util.List)83 HashMap (java.util.HashMap)76 Map (java.util.Map)70 IOException (java.io.IOException)60 HashSet (java.util.HashSet)52 Test (org.junit.jupiter.api.Test)47 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)45 Random (java.util.Random)42 Configuration (org.apache.hadoop.conf.Configuration)40 Path (org.apache.hadoop.fs.Path)39 ValidReadTxnList (org.apache.hadoop.hive.common.ValidReadTxnList)33 BlockNode (jadx.core.dex.nodes.BlockNode)29 File (java.io.File)27 LinkedList (java.util.LinkedList)27 RexNode (org.apache.calcite.rex.RexNode)27 ByteBuffer (java.nio.ByteBuffer)25 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)25