Question: I am converting a dataframe into a dataset using case class which has a sequence of another case class

```
case class IdMonitor(id: String, ipLocation: Seq[IpLocation])
case class IpLocation(
    ip: String,
    ipVersion: Byte,
    ipType: String,
    city: String,
    state: String,
    country: String)

```

Now I have another dataset of strings that has just IPs. My requirement is to get all records from `IpLocation` if `ipType` == "home" or IP dataset has the given IP from `ipLocation`. I am trying to use bloom filter on the IP dataset to search through that dataset but it is inefficient and not working that well in general. I want to join the IP dataset with `IpLocation` but I'm having trouble since this is in a Seq. I'm very new to spark and scala so I'm probably missing something. Right now my code looks like this

```

def buildBloomFilter(Ips: Dataset[String]): BloomFilter[String] = {
    val count = Ips.count
    val bloomFilter = Ips.rdd
      .mapPartitions { iter =>
        val b = BloomFilter.optimallySized[String](count, FP_PROBABILITY)
        iter.foreach(i => b += i)
        Iterator(b)
      }
      .treeReduce(_|_)
    bloomFilter
  }

val ipBf = buildBloomFilter(Ips)
val ipBfBroadcast = spark.sparkContext.broadcast(ipBf)

idMonitor.map { x => 
    x.ipLocation.filter(
       x => x.ipType == "home" && ipBfBroadcast.value.contains(x.ip)
    )
}

```

I just want to figure out how to join `IpLocation` and `Ips`

Answer: 
I you want more simplicity.  

`shapes.forEach(shape -> System.out.println(shape.getInfo()));`
First you have to add the fields that you need to your shapes. For example in the triangle you need p1, p2, p3. They must be part of the class if you want to get the right values printed.

E.g:

```java
public class Circle implements GeometricObject {

   private double center;
   private double radius;

   @Override
   public String getInfo() {
      return "Circle[ " + this.center + ", " + this.radius + " ]";
   }
   // Getters and setters
}

```

You do the same for all the shapes.

You can fill a list with objects like this:

```java
java.util.List<GeometricObject> shapes = new ArrayList<>();

Circle circle = new Circle(); // Initialize it

circle.setCenter(2); // Set the values
circle.setRadius(2);

shapes.add(circle); // Add it to the list

// Add some more objects into the list...

// Print them:

for (GeometricObject  shape : shapes) {
    System.out.println(shape.getInfo());
}

```