Code examples
1. Code examples
person: Let's now show some code examples. Let's show with an example how to use these small, concise APIs for typical data processing examples. We'll start by filtering purchases based on geolocation using longitude and latitude coordinates. Please note that these examples only cover the Java SDK. For Python, SQL and [indistinct] APIs are used instead and will be introduced later in the course. Feel free to check out the [indistinct] documentation on the Apache Beam website for guidance on using schemas in Python as well. We can see how concise the code for filtering is in both cases. This is possible thanks to features introducing Java SDK 8 to filter streams with lambdas. It's easy to understand the logic we are trying to implement with and without using schemas. Now let's see a more verbose example to implement joins in the Java SDK. Let's talk about joining datasets using this example. We're going to join transactions with purchases from an online system. It's important to point out that one transaction always has one or more purchases so we can use an inner join. We want to calculate the total purchases per transaction grouped by user ID. We can see how expressive the solution is when using schemas compared with actual Java without schemas, focusing on the business logic instead of having to embed steps to [indistinct] types, right? Schemas make your code more readable and easier to manage--whoo-hoo.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.