#3 Application Development with Apache Cassandra™

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so welcome everyone for week three of the cassandra cloud native workshop series today will be all about application development thank you for being with us uh in the previous week it was all about theory about cassandra it's time to go practice in the code i'm cedric levine i'm the director of developer advocacy at data stacks and today with me i have my buddy david hey david hello hello hello hello hi cedric yeah that's about it's not only me david it's the wall crew behind the screen helping and swearing question today on the live on youtube also during the week on discord and also on the forum community.com where you ask all the questions when you do the exercise speaking of exercise you can see now that we have put the link just in in between us to do all the you know exercise this is a single link it's also part of the show note in the youtube description this time we have put provide you everything you need including the mentee card and everything and we should be ready to go let's do this cedric let's do this all right are you guys all excited is everybody excited excited to get into some application development today let's see those thumbs up and yes i see a thumbs up there i see some hellos oh oh my voice is not syncing with the video uh oh i just got a message from someone saying my voice is not synced with the video oh well as i mentioned i am stuck in another dimension today it seems oh you are so let me fix that dude we're gonna fix that yeah let me i want you to be there with us what about now try to speak how about how about now everybody now that you guys are seeing how the sauce is made yeah yeah how does my voice synced okay yeah i think we're back so in the meantime i will start uh we go on speaking so uh i don't know if you know but uh we do have eleven thousand registration for the workshop this is amazing so week one we had about eighteen a thousand view uh about 2k almost 2k people did the exercise the first week and week two uh it was a little lower but you know that's life but still amazing ten thousand uh you know ten thousand that just wow and that's all the exercise almost one thousand people doing the exercise so you have up to uh last week of august to do the exercise so you're not in a hurry you can catch up if you just join today totally fine you can catch up what we did in the previous week all right and now this is a time to talk your what's coming okay first we first two weeks while really deep into cassandra what is the database what is used for what is a data model and this knowledge is really required to go where we want to go but where we want to go is really building applications on top of cassandra and we are starting today building create read update delete services next weeks we will package that as the rest microservice and moving on we will put that step by step in kubernetes both cassandra and the app do the test and put that in the cloud so the workshop is not only about cassandra is about all the technology you would need to succeed with cassandra in the cloud all right then you know what today housekeeping just a demo to make you excited what kind of use case we will do connectivity to cassandra executing queries statement getting the result and a little bit of a java famous framework spring framework so let's talk about housekeeping as usual no you don't have to install anything to work with the with us today you have to do exercise but you don't have to install anything now we expect you to have already the astra instance in the exercise again we put everything you need to create your astra instance so you can go there if you don't have one and start doing it right now because today we expect you to have that same we also expect you to have basic knowledge of cassandra data modeling because we did a full week on that and most of you probably have taken the ds220 on academy.com as part of the homework this is a huge amount of work and also know some basics about node python java or c-sharp because every aspect of cassandra will talk with the drivers we will illustrate with one of the four just to notice to do the exercise today we have node python and java okay as usual we are live on youtube and also on twitch as a backup we are not really answering question on twitch really focus on the chat on youtube and discord um if you do have questions during the week there is community.com we will use the exercise using astra which is customers service in the cloud you already have the install you are you already have created your own instance all the materials presentation code is on github and to do the exercise today we will introduce a new tool called git pod hitpod is kind of eclipsed cr or visual studio code available online and you can see that starting from the github repo just click a button and it will spawn a github gitpod instance for you to work with yeah and just something to add to that you know like for those who are out there developing especially if you're using github so many of us are nowadays um like getpod is just awesome because you can have your code up in the repo hit a button and launch and then anybody you can launch anybody in that code um and you don't have to worry about mucking with an ide locally or anything uh so we've been starting to add these into the workshops now uh and we're gonna see how this works today the key thing is there's so many of you on today we we don't know how well getpod will handle all of the folks at the same time so hopefully it's nice and smooth we'll see but yeah yeah definitely even outside of what we're doing today something to check out potentially for your own projects and it's free that's wonderful you don't pay anything or whatever to use it let's see a demo of the uk's what do we build today well with all the space theme we are using from the start let's redo that and we will you know we will launch a rocket today we will move into space you know astra space let's see what it looks like okay all right so i'm moving again um this time here so this is the ui you will have not this week because this week is all about creating create read updates operation um to be able to insert data in cassandra but next week this is the demo you will launch like me so i would like to launch a rocket so spacecraft name let's see uh where's the rocket can come out of the box shop broke it behind you know let's yeah yeah we want to go to mars why not and i launch so what it will do it will insert the journey row in cassandra and then you can see at the bottom of the screen maybe it's a bit cropped but this is four metrics registered in real time speed pressure uh temperatures and location so we are injecting time series in real time in cassandra okay so we can see that we are you know writing a lot of data okay and when it's done okay i do have some uh summary here telling me that the workshop rocket had a journey id of this id uh it takes two seconds to go to mars yeah to read and write overall and here you can see all the data that has been written to cassandra and if you want to replay your uh journey you go to the left path and here you can see that oh this is the one we just launched for a rocket you you do have multiple journey and i can replay one journey and it will again take one two minutes to execute if i launch a new journey using the same rocket it will appear over here and i will have multiple journey for a return for a rocket so now that you have passed week one and week two with cassandra you can tell what we need to find out to be able to create an application like that is to know what are the queries the application workflow and what is entities and relationships okay so let's see moving back here whoa this is our rocket so this workshop workflow should be familiar to you this is the modalization process when it comes to create a data model for cassandra you need both the conceptual data model and application workflow to start with and then applying basic rules you get the physical data model and you are ready to start all right so application workflow first we do have a spacecraft catalog which queries we want to look up all the journeys for a spacecraft you know on the left part here i do have the falcon 9 uh you know crew dragon 9 let's yeah we'll see in the sample just later and here you see i do have two journeys so get all journeys for spacecraft now if i want to look at the detail of the journey i should be able to have the journey summary and of course this is the things i did in the first place you need to be able to create a new journey so okay now when it comes to the sensor you know pressure speed temperatures location what we need is to be able to save that in real time and also later on to be able to analyze one dimension over the other one maybe to be able to draw a curve explaining what is the speed over time or pressure over time to be able to do some analysis after that uh hey cedric real quick um um so a bunch of folks are asking how to launch and i just want to remind folks at this point cedric was just showing you the app and what it's doing we have not actually launched that as part of the workshop yet so don't worry about it you haven't missed anything or anything like that um we just we just haven't gotten there yet yes so you will do this demo next week when we do have all the pcs so we will build the demo step by step and first things to do is to insert stuff in cassandra so let's start with application workflow okay i did that and conceptual data model i do have a journey i defined the attribute summary is the journal active or not was it the name of the spacecraft is the journey started takeoff landing and what is the uid of a journey you see in the journey summary window we do have the journey uid you asked about creating a real app for customers here it is right so you also need all the readings speed temperature pressure location and each time you need a unit a time and the value all right with those two you go to the logical data model multiple queries means multiple tables you know that so having the journey catalog list all the journey for a spacecraft well spacecraft will be the partition key john 80 will be a clustering column um could be this to have the latest journey at top if it's the time you id start when the rockets take off and when the rocket landed if the journey is active or not and also the summary you know the little text ii tape same for now for all the metric speed pressure location temperatures again the space craft should be part of partition key but also the journey id you want to have the list of all the values for a single journey not only the spacecraft because you are doing the queries for each journey you want to speed over time for this journey and not another you do have the reading times which is a timestamp and the value and the unit of the value speed speed unit pressure pressure units okay moving on this is the logical data model what's next move to physical data model okay now for the spacecraft i use the text journey time uid so i do have the temp the timestamp and this is why i am able to sort the value all right is it active or not the summary uh and you know you can read the slide for the others we get the different types for each attributes and with that that's it we do have the ddl to be able to to create the cassandra query language to create our tables so first the spacecraft journey catalog and then four tables that look like a log like that which is stuff for each dimension speed pressure temperatures and location hey cedric real quick so um i do see a question i think is really quite relevant to what we're just looking at um why can't we have a single table to store all the sensor values oh um putting cedric on the spot yeah okay let's see let's discuss about that um having all the value over time um [Music] that mean you will request for a certain journey okay uh having text and time uid and then yeah why not we could have a speed speed limit pressure pressure units and reading times as a single tables that would make sense i guess yes and if you want to add a new matrix add a new column totally fine with cassandra we make the choice to split into multiple tables uh i don't know maybe because we do we don't have the same reading times for each value and we cannot insert everything at the same times but if it's possible to insert everything at the same time yes having a single table for the matrix and multiple columns is totally fine because we are querying with spacecraft journey id and we do we still have the reading time as a as a clustering column to just ensure unicity and and one thing to also point out per that clustering column right is that if you notice even the two examples that are up on the screen now they are not using the same clustering column so could i have uh the same partition key within those both of those as clustering columns i could however since clustering columns are going to if you have multiple clustering columns the order is going to be sorted in the order of your clustering columns i may not want that in my actual query access pattern right i may want to ensure that my clustering column is only being ordered off of say one of the columns or something so i guess at the end of the day it depends it's flexible it's not there's not an absolute that says that you absolutely have to date a model this one way um but you know yeah could you combine it yes but then of course you're gonna run into um some considerations with your clustering columns that you need to take into account are you gonna are you uh are you gonna minimize this in life no no yes by the way for those of you who are saying can david duck i could unfortunately you may have seen me laugh for a moment i turn to the side and if i do it too far you'll see behind me uh and it kind of yes it makes more of a problem than not uh so no i can't actually duck but yes you're seeing the the infinite house of mirrors as you see yeah uh how we're doing this live i think that looks a lot better and also maybe you know that the bad the bottom is not cropped anymore yeah it's i feel like we need to do like a meta episode yeah you know it's real life all the bloopers and everything see how much stressful i am to just do that okay let's move on yes and charlie yes uh we are in satellite dishes like i said i'm in a multi i'm multi-dimensional today so i'm actually phasing in between our dimension another one but that is you know totally off the satellite dish but anyway so going back to the data model hopefully i did see some questions come through with that um so the answer is the answer is you know why couldn't you use a single table you could you potentially could but you again you need to really take into consideration what's going on with those clustering columns um to ensure that it's actually giving you the results that you would expect yeah because thinking about that spacecraft journey idea and rainy times if all the values come at the same times um yeah you still have one unicity but yeah maybe you have a huge table let's see yeah i think the the choice have been made because we don't have the same reading times for all the metrics or this is what we pretend but that's a fair comment and you see how we we just think about that uh there is a little piece of heart by doing the data model i mean of course your challenge because you have just done data modeling all week long [Laughter] all right okay so let's jump to the exercise so first this i is still a notebook why because we will create the expected tables and i don't want to create that in multiple languages let's do that with the notebook just to see what are the queries under the hood the one that just show you with the demo and when we are done with that we can move on to all about the code okay so i think in uh crew is just sharing any link now both on youtube chat links are below the video um but it's still in the same github repo as the two week before now there is a new folder called surprise week three all right so i will do that with you let me go to my astra account okay here i am and i'm moving to okay let's close the demo and i go to developer studio remember developer studio is here lunch now okay um so week three remember this is cassandra workshop series week three and i'm following the rules so we do have slide deck discord all the video available for today and tomorrow there all the link and so first step creator ask instance and as we told you we expect you to have the astra instance today but if you don't use we still have provided you all the procedures and what we expect you to do okay so let's move on to two the spacecraft notebook okay so you download the spacecraft from git github and i think i provide you the icling here downloading okay so i'm inserting that in download okay spacecraft and i can simply go to my studio find the little this guy and drop so import you know as usual let me put you in the proper here you are and so i've just imported oh it's still downloading is it i think it's still downloading but anyway i do have my what is that i do have my notebook already imported here if i need to so let's see maybe it's there already oh yeah no i for some reason i know see i do have this are you taking up all the bandwidth and no no it's not a bandwidth it just look at the icon i know it's very small on my screen i do have an icon like telling me that this stuff is not fully downloaded but it's not the case it's probably downloaded yes okay so let me close you guys and put your doing big okay so space flag catalog data model working so we will create the table we just defined all together with the workflow the catalog and the four tables for uh the four uh matrix okay and the first things to do is to create the spacecraft johnny catalog if it does not exist um so you are probably using killer video which is the key space we are using for the first two weeks um totally fine if you ask why i'm not using it on my uh um on my own notebook it's just i do have already one key space ready to go remember one key space per astra free tier so and you cannot rename it so i will keep my own named to-do app because i've created a to-do app on cassandra a few weeks ago but that's totally fine oh and you may have just said that and i completely missed it but i did see some questions about folks asking do we need to create a new key space if you've been following along with us and you already have the killer video key space did you just say this cedric and i missed it yeah something like that no reuse the key space you did no reuse killer video key space totally fine you can reuse killer video as well so all you'll have to do is as centric goes through um the instructions and shows you the configuration where you're putting in the to do app stuff if you had that you would just replace it with the killer video piece so we can you can use the other one exactly all right i'm seeing the notebook is not getting down when you click on it again this time i just did it in front of you cannot say that to me yeah yeah no i'm doing it myself as well but you know bettina i think i saw bettina drop the actual the raw link i'm i'm grabbing it now myself all right okay so i've created now the other bunch of tables okay and i will truncate the tables why because they are not empty at least on my end because i've just run the demo with you so those tables are not empty for me and to be honest when i did create table if not exist nothing happened because it was already there and so you can see that i do have the table spacecraft yada yada all right so now insert some demo data okay i'm inserting three yes three journey and i'm right away executing a command i should not execute which is select star from okay and for some reason why do i have a single guy whereas just ask to insert three that's so funny oh here they are yeah he told me no that uh return but okay it takes a few seconds to just get my three guys here so and the one we will use for this notebook is apollo 11. okay one of the probably the most famous so what i'm doing we have created the journey so we provided the spacecraft name and a journey id okay then we insert stuff so speed location temperature and pressure okay each time four metrics okay he told me success um and so here this is the query we need to do remember application workflow this is the query we need to do to do the app and this time i put some code you know some labels in each query just for you to be able to map what we are doing with later on the exercise so first for a list old journey for spacecraft 4b get details over journey fourth c get instrument reading for journey so if i use apollo 11 okay for a list all the dna for this spacecraft i do have a single journey which is fc one yeah i can select of course the full row okay but as i provided the partition key totally fine then i need to get the detail of journey so now i will also provide the journey id and now it will be unique because i'm requesting with the full primary key and before i was only using the partition key and see i don't need hello filtering for that all right moving on so now to get the details you know find journey by id if you're already familiar with programming you might tell that this is the kind of query we do but it's also related to a spacecraft so i provide the spacecraft here for c get the instrument reading for a journey and i think yeah i provide the four so first the the speed okay then the location x x y z you might notice that here we are using a udt user defined type yeah the idea is to give you as much you know flavors cod as we can so we put you some time series we put some udt we put some uh time u id all the fun stuff to play with when you deal with when you deal with cassandra okay out willow filtering well i don't know i never use that just about to answer that don't use it yeah don't use it just pretend it doesn't exist no honestly uh um if you really wanted to at the end of your query you could actually put the words allow filtering but i know we talk about this every every episode i'm going to belabor the point you should not be using love filtering it's actually kind of an internal joke in the cassandra world that that that when you uh write a query that is starting to say um not use your partition key in your where clause that the driver actually the database comes back and it tells you exactly what not to do it's like oh by the way you could use a lot of filtering you should never use it because um when you're using allow filtering that's usually an indication that you are trying to query outside of your partition key and unlike a relational database where i can just say query my where clause against really any column in my table that's not how it works in cassandra you always have to have that partition key right and if you are not using the partition key and you're getting that allow filtering error which you're really telling the database to do is i want to scan through all of my nodes to go find some data and if i've got like a thousand node cluster or something imagine what that might look like right so again allow filtering is an indication that you need to kind of rethink that query access pattern what you're trying to do in your query i would not use it at all ever especially in production workloads it will cause you issues down the road absolutely yeah yeah or but somebody said i love bearing yeah i i yeah yeah fabry youtube yeah i i yeah i i'm pretty sure i talked about that uh a few weeks ago man last week of the week before hello yeah i like to say that um okay so that was uh the temperatures pressure yeah again it's always the same type of query and in just a bit sorry sorry i said just to finish something off i say alka grover is asking so when do you use it generally you don't right it's a holdover from the past there are some advanced cases when maybe you were looking at doing things with spark workloads or other things that it might come into play but this is under the hood stuff generally speaking in cql you should not be using it so it is it's yeah it's more or less i don't know if it's a good point maybe if you are doing olap queries you know like you say you talk about spark if you are doing all of queries then you do not care about the time to to to your query transfer we don't speak in a millisecond either on second but maybe in minutes yeah maybe you can think about a lot of filtering but again you should have the proper tables to to do your your work and not try to use some kind of walk around all right so so now you get the tables and which select query we will do what about write query what about the mutation well the first mutation 5a is to create a new journey so i will create a new journey for the spacecraft true dagon true dragon 9 uh yeah to bring back uh astronaut to the ess all right and so i you can see that the active flag is false because i'm just creating the journey now what i want to do is to take off so to take off i will update the journey and i will put active to true and i will provide the start date as of now and again i need to provide the full primary key to update this item okay so what does it look like i do have my journey started and i have the start date and now i will start record readings for each dimension so speed pressure all the force so this is just a few insertion okay so here is uh speed speed dump speed speed location temperatures just a couple and when i want to land i will update the record and say now active is false and i will update the column end with the date to now if i now look at what the journey look like now i it's the journey is not active anymore i have a start date a end date a summary and boom i can still query all the journey for a spacecraft and get the status yeah so i see some people with file corrupted so maybe you should just download the full github repo here and go down so here it is and so uh where it is again download zip yeah in the very base yeah so for those of you who are getting corrupted tar i know this happens for some windows folks watch what cedric is doing right now yes so go to the root of the the repo and say download zip and you would have all the tar because i can assure you this star is not corrupted okay yeah i i just imported in front of you in the astra but it's uh sometimes with window machine i don't know the default stuff first try to unturn it where you should not and then for some reason do not have the you know corrupted but that's all due to either the brother or windows i cannot show you that the file is correct all right um and we are done with this exercise okay oh raw link is working in windows for sure so okay we are covered just stop using window it's not a west wall man now i love all the no i we love all the os and when we do you will see in two weeks when we do the kubernetes stuff and you need to install kubernetes on your laptop we have the procedure for linux windows and uh mac we yeah everybody happy we just love all the goodies we love all the ways yeah it looks like gerard is working i know jar was having a hard time with the uh uh the crept guitar i if i've got that right gerard it looks like since you've downloaded the entire github repo that it's working better for you so wonderful yes thank you guys for confirming we prefer uh appreciate that yeah we yeah we keep yeah we keep having this issue also try to import with url and we don't do with that anymore yeah just download the full stuff on your laptop and drag and drop should be the best way to go okay so we are done for exercise one um i will show you now a little bit of slides just to see how the drivers will connect to cassandra let's start playing with code i would advise you now to so go back to week three and start git pod right now because git pod may take five ten minutes to start depending on your uh on your uh bandwidth so you just go to you know cassandra workshop series the readme of today the one we are using from the start and go to chapter number three and say connectivity to cassandra and then click on the git opening github you should rather say open in a new tab i think otherwise it will just yeah you want to pop up in front of you and this is what it would like see it will pull the docker image and soon we will have a full working uh ide to do all the code okay so again this is the open in git pod button and if you want to browse very quick you just look for step three a okay open git pod and when it's done yeah this is what you got okay see i'm still on the same readme but i'm now in a food working uh id and i can start typing some command and do some stuff we will go back there right away i will let you start that properly and we'll go in slide in slide mode okay and charlie collins and youtube was asking do i need to get something set up to see get pod you shouldn't it the link should just be there for you in the repo you should just be able to click it it's a fully online cloud-based experience you shouldn't need anything locally to make that yeah totally fine yeah so look for 3a key because it's hidden in the middle of the readme because yeah i put back the all to how to create instructions in the beginning just have everything at a thing in place just if somebody just join us today just to be able to do the exercise there a chance you could show that one more time cedric going down to the gitpod link and launching oh yes of course okay so i'm going to let's go back to so you know we do have a single github repo for the full series cassandra workshop series okay and today we are doing the week three so i'm clicking on week three okay and so there is a dedicated readme for week three and see i go to uh i i go go to connectivity to customer i could have used the the table of content but let's browse to what we need connectivity to customer here you do have a open in git pod okay then what i did instead of just clicking the button because it will open git board in the same window and i would allow will lose the instruction what to do i simply right click and say open link in a new tab and so that's appear and we will do that this week next week and each time we need to code it's quite new gitpod it's based on eclip fia and uh so there is maven there so you can do java there is npm insta npm there you can do node and there is also python three instead you can do python now to do c sharp you need to add uh more dependency in the in the in the keyboard and this is why we did not provide the exercises in c sharp today but still you do have the exercise in the three or seven language all right are we good okay perfect yeah it looks like it looks like we have some questions of folks that getpod is asking for login info i believe that's probably because it's expecting you're logging in to get home that's probably using your your login in github yeah it's very look like vs code and yeah the first time i saw ecliptia for me it was man vs cod totally that so you won't be lost and to be honest you can go to git pod uh you know dedicated website and they explain you how to import all your extension for vs code yeah that's totally fluent and that's probably the future maybe we don't have to install anything and everything will be there and you you might tell the latency is not that bad we will see that in a minute but let's go to slide mode okay so to connect to cassandra you are using some drivers those are libraries that are uh embedded in your application so you don't have to handle the connection on your own this is the job of the driver you will only interact with the driver so the driver ensure the connectivity you know connect but also anything related to retrying if you lost the network the driver will try to reconnect if a query fail because the database is not there the driver will retry the query remember the first week when we say a client can ask any node to be the coordinator node for a query and the coordinator node will send the request to the replica well the driver is token aware so even at the driver level the driver level knows which are the proper replica and go ask for the data to the replica and so 99 of the time one the coordinator node is one of the replica you need and so the response is very very fast if you are using cl1 because you hit the the proper node and there is no extra request over the wire it's also unlinked the connection pooling you can put big or small it's doing health check so let's see one of the node in your castle right cluster is down then the driver will notice and don't ask to this guy for a period of time you just set up and it will s-check and when the when the node goes back online then the customer the driver will again connect to this guy and do all and sell the request to him so the driver is very very clever all this stuff is done by the library you don't have to okay for authentication authorization ssl okay this is what you expect for any connectivity tools and now when you do when you query against cassandra we support of course the cassandra query language but also everything to create tables type in any object in in the key spaces even create the key spaces you can interact with cassandra using synchronous query so today we are using only synchronous let's see next week or asynchronous and reactive okay you do have something to help you building the queries and everything is done to make you as fast as possible so either using compression or paging because you don't want to retrieve the full tables or the full partition you maybe just want to display in your ui you know the first range of data and so you might want to use paging and also you know passing result we will see that in a minute and just something for those of you who are seeing that gitpod is taking a moment um we do have a lot of you on today and this is the first time honestly like get getpod is obviously a service from github but this is the first time we had this many people trying it all at once get pot on its on its own without all these folks at one time can take a couple of minutes to start up right you're gonna see that kind of one of three two three three or three it might take a couple minutes but with all of us hitting it once it might be a little bit slower than normal um the cool thing with git pod is if for some reason it seems like it's hanging or whatever you can just kill that tab and start another one and it'll it'll restart all the resources if it needs to so um it's it's not something like it's gonna like corrupt it or or do anything like that but we may have to just be patient with it uh because it is a lot of folks yeah and also david don't uh yeah don't hesitate to interrupt me if you have some spicy question in the chat uh for instance i i see one from charlie collins telling me that is reactive always necessary for serverless quite a lot of buzz word in the single sentence isn't it yeah yeah yeah so for me the answer is no because uh in the service world uh the endpoint could be also synchronous if you are working in aws and the endpoint is using the api gateway then you are using rest and the synchronous part of rest and so there is no point for your backing code to be reactive and if you start doing reactive the full stack should be reactive so not only the driver and your code but also the way you deploy so if you are using spring it's just you know it needs to be spring web flux if you are using you're not a new man [Laughter] that's a good question that was a good question all right but you know we will discuss all that in the coming weeks as well so i told you it's a library the drivers are library and so first you need to install so if you are using with if you are working with java this is a maven dependency and if you are working with gradle you can translate in json it's not that difficult latest version 4.7.2 this is a python this is npm for node.js so node package manager and this is how you will install that for the cassandra c-sharp driver with the nugget package okay but visual studio can help you find this package with a proper search function and that's it with this library you have everything just a note if you have used the driver the java driver before you might notice that we used to have two set of drivers one for enterprise features one for open source now this driver you see that is the only one everything has been merged so in there you still have some capabilities that will not work with oss cassandra like graph spark search but any advance you know reactive stuff advanced load balancing advanced configuration it's now all available in there yeah finally open as you talk that okay so now with your driver you will connect to customer so the at the initial initialization of the connection you will contact you will address a contact point only one is necessary but if for this very first query to connect this contact point is not available well having two is not bad okay but once the connectivity has been established the the response coming back from cassandra gets all the topology of the cassandra cluster so now the driver knows all the ips of each node and how the ring and rack are distributed and this is why the driver is pretty pretty clever and can now interact with the local data center the one that is close to him just to reduce the latency and not try to contact all the node from everywhere on the planet because your cassandra cluster is fully distributed okay so that's the theory boom this is a code and i try to do that now for each notion i will talk to i provide you the code in each language um of course it's not to be uh learned by you know by heart or anything but remember we give you the slides okay so you do have a pdf on the github repo each week so you do have this code you will also have this code in the exercise but that's still good to have this you know cheat sheet how to how to establish the connection to casanova so as you can see we define the contact point a local data center which one is close to me to reduce latencies the key space which is by the way optional you can connect without providing a key space and then interacting with cassandra using any key space by using prefix you provide user password okay java python node c-sharp you might tell that java and c-sharp code are very similar sometimes you're just adding some uppercase at the first in the method name and same for node and python pretty close using the same object yeah the driver teams you know they do a really good job in my opinion of keeping parity across the different languages right so one of the things that i've always kind of noticed about coding cassandra and the different various code languages is that if you figure it out for one you're not that far off to understand how to do it for another yeah there's some differences like node being async you know by default and such uh and how to handle that but as far as the syntax goes and the feel of it you generally speaking maybe the object mapper is a good exception to that it's a little different though but for all the regular commands like i said generally once you figure it out with for one you're gonna be very very close to doing it for the others the driver teams do a very nice job of keeping that kind of in sync across the languages um okay so i do have some queries coming um user will be killer video yes because it's the one we are using uh why is there a port number in the java version i think it's uh optional you can use either a ninenet socket address or a socket address where you don't have to provide the port how to turn on the debug on the driver to track well using you know the you do have a logger so slf 4j if you're working in java and providing or log back providing in the log back that xml you just say anything com.datastage.oss should be log debug boom you do have the of the log and also you will see that but each time you query cassandra you will get an object called a result set and in the result set you will have the truss so which node did you hit how much time did the request and a lot of extra information that you can export to dedicated tools like promoters for instance all right moving on i want you to go for it oh real quick yeah i've got a question here from uh nev junt navjot i don't know if i've i said that you know he he or she was with us last week i have no idea how to pronounce that name so if anyone can tell me how to pronounce it probably that's great um but the question is is there any issue if we specify all the nodes let's say i have a cluster of 36 nodes span over three dc's actually yeah so you don't want to actually specify all your nodes for one it's just flat out overkill the as cedric has explained when you connect up to the nodes you only need three of them a handful of them because through the gossip mechanism oh thank you yeah through the gossip mechanism then the driver will become aware of all the other nodes right so you really do not need to do that and if you specify them all i guess the question is if you specify mom on the driver as compared to specifying models c nodes i know if you specify all of your nodes of c nodes right you're gonna end up being very chatty and that's absolute overkill um i believe it's much the same if you specify say all of your nodes in the driver as well but i think that's just on startup though it's just the initial startup but it doesn't it doesn't give you any benefit to add in all your nodes imagine for a moment going back to the thousand node cluster scenario do you really want to include all thousand ips and have to know what those are the power here is to use the use gossip and use the fact that the driver gossips just like your nodes do to only provide say three of your seed nodes as um your your configuration points here and then that way it will it will explore and find all the rest of your nodes there's no need for you to provide all of yes so if you do have let's say a cluster of 10 nodes the best practice is to provide two nodes and those two nodes could be the seed nodes so just that's the best practice because seed nodes tends to be the most up to dates when it comes to the cassandra topology but it's not mandatory i mean just two ip of the node totally fine and how to add multiple nodes well you can tell with the with the code that for python and node you provide an array of ip and for java and csharp which are using more some kind of fluent api you just add contact point add contact point add contact point any time you need and you know that's when you want to explicitly provide all the parameters you can also externalize all these settings in a configuration file and you will see when we move to kubernetes we want to have all this value externalized from your app and we will see that i think it's two weeks three weeks all right oh and one last thing cedric because i see a really juicy question that just came in from essay does token aware policy driver policy always take care that every request goes to the node responsible for data and not to any other coordinator what are the scenarios when this is not handled um so the token aware policy along with the the load balancing pieces they're going to do their best to try to ensure that requests are actually going to nodes that in fact can facilitate the data right it's an optimization in there to help reduce the amount of network overhead and such because if i can go right to the node that has the data then i reduce the hop right um but that's not always guaranteed what happens if for some reason a node is down or you know you can't communicate with one or something and this is actually getting into some of the real power of cassandra the fact that it is a peer-to-peer leaderless system that request can go to any node and it will forward it on to the correct node that has the data but yes there is optimization um that will attempt to shorten that path as much as possible cedric is there anything else i'm just reading the the question and as i did i had the question three times now i will repeat so if so you can provide multiple contact points okay one is mandatory you can have multiple if the one you provided is down and it's the only one so no magic you will get an error i cannot connect to cassandra if you provided two contact points which is a recommended path then the driver will do the load balance will retry on the other contact points for you and once this first connection success then everything's fine because now the the client has the full topology of the cluster and can do uh load balancing among any nodes just for this very first one if this node is down yeah i have multiple attack points better and one last thing and then i promise i'll let you go on because this is another one that comes up a lot and it's a good question from avinash what if the connected node goes down again this is one of those cool cool things about how the driver works and how much work the drivers are doing for you so even if again let's use the thousand node you know cluster as a scenario once the driver connects to your cluster even in the thousand nodes right it will gossip and become aware it doesn't matter the node that you initially connected to that initial contact point was just that initial contact point that's all it was once it's connected up to your cluster it gossips and it's aware of all the rest of them so you could lose that node it doesn't matter you're totally good yeah then the driver will reach any any node no problem okay um but you know we are using astra for two weeks now and astra is full customer in the cloud so do we provide you hundreds and hundreds of ip well so no there is some there are some proxies and load balancing on top of casserole nodes providing in astra and we are using something called server name indication sni so what we do we open a two-way tls connection using strong strong certificate you know the connection remain open and with this socket open and secure now the driver can do all the health check retry load balance using some sni instruction on top of the tls connection and so when we will connect to cassandra we will need to download a zip file and in this zip file you do have the certificates not only user password but also the certificates to be able to open this two-way tls connection when it's done it's working exactly the same as you know your driver connecting to customer and of course as the load balancer is redundant there is no single point of failure all right moving on and so if i look at the code now um when i when we will connect all together to astra exercise number two uh see that we are using the zip file okay so now instead of having contact point i'm using zip file and it's available you know in the four languages as we as you see here uh either reduce the path just secure that zip you will provide the full path but just to fit in one screen but you get the id now you only need user password and a class secure bundle and you can have or not the key space and here i put back killer video because this is the one you will probably use because this is the one we created in the previous week all right important about session and client the session the one we use to interact with cassandra is a stateful object he's doing else check so this guy open socket to any of the node when it deals with cassandra local cassandra and also doing a lot of sni when it comes to astra so when you close your app you want to add what we call a shutdown hook which is some listener that will close the session when you close the app just to properly close all the tcp connection that has been open because if you do have 1000 nodes in your cluster you will have 1000 open tcp socket for each connected client because the client is connected to each node and doing else check that's a lot of tcp sockets so don't forget to just close the secure session when you close the app all right and now we can go to connect to customer so go back to the readme when you find all the instruction okay so the first things to do is to download the zip file you know the secure clamp yeah how to download secure exactly go have set so this is exactly what i'm showing now so in the exercise download the secure bundle so when you go to astra there is something called authentication and i put a red circle download secure cloud bundle so if i go there i refresh don't forget to yeah make sure you make sure to refresh because look the download link expire every five minutes when you get the file it's done it will be uh it will be valid forever but to avoid any scrapping or any weird stuff we just ask you to just refresh refresh before so and then you just download okay and so mine is called secure connect dash dev maybe it's two let me put that below so secure connect dev workshop db why because my my database is called dev workshop db if you use the parameter for week one or two it should be called secure connect the killer video cluster all right so you download that okay it's local okay perfect moving on with the instruction once you have downloaded that's file you you go to git pod okay so i'm going to gitpod i'm select you know you need to select one of the folder to import something so i will select week 3 okay and i will say file upload file and i will pick my secure connect bundle and so the file is now uploaded and here on my terminal i can go to week 3 and let's do it the proper way yeah and now if i list you can see that the secure connect bundle is there all right you know what i will do pwd just to see this is the path of the zip file okay you need the path okay going on with the exercise you see now that the file is there okay this is what we just did and now depending on the language you are more confident with you will use any of those so myself i'm quite of a java geek so i will go with java but you do have the same instruction for node and python all right so we can see that vg already is ahead of us so i will open the java part okay so yeah i think i've noticed a lot of folks are uh you started talking about the original slides are already jumping in the code i think people are excited just like let's just go into the club guys that's a good sign and you know it's yeah there is enough documentation in the get me to for you to do all the exercise pretty quickly okay so uh first there is a class called db connection and you want to just uh specified the see you want to specify the zip path user password and key space okay so me if i'm going to my here git so i'm going to code java because i'm doing java sources main java db connection and here it is so i will use the path and i will provide the name of my zip okay so username is to-do user-to-drop that just me so you would have to change that to clear video kv user kv password so i save don't forget to save autosave is not enabled by default in git pod this is one of the drawback so ctrl s or command s if you're on mac so let me go to java and then you should be able to execute the first test so let's see i'm here in gitbird and in ssa test java remember i'm a java geek so i really wanted to do unit test and no and no main but those units tests are not 100 perfect i want to have some assertion to validate that it is indeed a test and i must admit that for some it's just executing the code and not doing the assertion afterward but yeah that's just a workshop be yeah be happy with that be nice with me okay so um exercise two what it will do should connect to astra okay so it will use the constant we just defined and it will do the code you know sql session with cloud secure without credential with key space and it should write connected with key space so i go first to create java i'm doing a clean compile you know just safety hey cedric can you um can you zoom your the font i think it's hard to read for folks i'm not sure i can but you know what i will switch to my local id just after that okay because you can do that with your own eclipse you know so i gotta i gotta call you out on some cedric not really calling you out so um uh prussian just asked do we have a c sharp with instructions so funny enough right uh you can imagine that uh having to code up all four languages for this uh you know is is a good amount of work we we just didn't yeah we didn't yeah we did the 30 exercise not 40. sorry yeah yeah exactly yeah it's a it's a lot to repeat so now cedric i don't want to put you on the spot um i know that you had some of that done are we still planning to to put that out there at some point yeah um or yeah next week we do have the full app ready to go in a c-sharp already so if okay if you go to week four okay then you can see that the app is fully uh ready uh in including in seashore okay so seems like my exercise is success and i was able to connect okay um and if i'm doing the same now on my local machine oh magic now it's white see i think i do have the proper path and so if i go to my uni tester i should be able to run as as the unit test so same uh yeah i like this green uh telling me that my units test is correct yeah one thing um we should just reiterate real fast cedric um for you know in any one of the languages that you're working with when you upload once you've pulled down your secure conduct bundle that zip file and you're uploading it in there make sure that you're putting it into the root of the week 3 folder that way as you're going through any of the code languages you don't it's in one location you can use the same file for all of them i saw a couple questions come true so in the root of your week 3 folder if you right click on that folder in gitpod you will see an upload you can just upload it directly there this is what i did yeah but you know you know technically any path is okay because you provide the path in the db connection class and also you you might ask why on earth did you provide a db connection class or interface in the java part well because we use exactly the same code convention for any language so if i go to crude node.js i do have a db connection.js with the same and you know same for python okay yeah and one last thing uh i i see some questions coming in do i have to do all the languages or anything these you don't have to do them all you can pick one he's doing java you could do python you could do node totally up to you we provide all of these because as you saw in the question in the beginning we have a lot of folks from different languages so we're trying to help folks with all the major languages at least get a starting point you can just do one of them you can do all of them totally up to you but all of them are essentially the same exact thing just implemented in the differences but you know each time we provide you the exact command to pass so you should be able to do those and go broad the code it's there for you so in the homework for this week we will say please end the exercises so just exercise this for the language you like you don't have to do all the exercise for all languages of course i find it fun to kind of do them all anyway but that's not the point yeah totally fine okay so now we are connected let's do some stuff with that let's execute some queries against customer okay so to execute queries of course you can totally execute the cassandra query language as is but then you can have all the sql injections uh attack so each time you want to externalize the the parameter of your queries so as you can see using some question mark or you can even use some labels so any query you execute against cassandra is what we call a statement so that's a good practice to instantiate a statement before executing it because once you get a statement you have access to extra attributes parameters of the statement you know like the timeout how many times do you want to wait or remember last week the costs are still the consistency level the famous consistency level that is cared per query per statement this is a statement object that would hold the consistency level you do here have the five languages of five i don't know how to count four languages here uh moving on this code is there for you to go back whenever you need each time you execute a statement cassandra need to validate that the statement is valid looking at the grammar is the table exist is a column name first is a valid query language do you use all the proper keywords or do you have introduced any strange stuff okay then evaluate if table exists colon exists for this table and everything's work properly to avoid doing this work for every query it's recommended to prepare your statement and it's pretty explicit in the java code a bit less in the other but still look there is a prepare true option and what it does is at the beginning at the startup launch of your application it will prepare the statement so connect to cassandra validate that all the statements are okay and then at the cassandra level we will store something called a prepare statement id and then when you execute the query you will only provide the parameter and the prepare statement id you don't have to provide the full i mean the driver won't give the full request to validate each time and so this way to interact now it's called a prepare statement and from a prepair statement you will bind the parameter to create what we call the bound statement and you execute the bound statement much faster than execute a basic statement which need validation each time okay same features with all the glam which you see here moving on okay so this one is really now a bit step aside step above when you want to create some code that interact with a tables or an entity most of the time is always the same method you want to find the entity by its identifier you want to save an entity you want to delete an entity by identifier or you want to update an existing entity and then you want to execute some select read queries could be list find all or providing the proper filters so there is a pretty famous way to implement those and is the repository in the java world and i think it's in t-sharp it's called the repository in ruby it's called active record but it's always the same same function same generators signatures to interact with each table and so we will try to implement those method when we work with the code it's a best practice like that you know you do have a new table let's implement the i repository for this table because then yeah you will have always the same two nectars and guess what one you have the same signatures you can expose the same rest api more or less only the entity model will change it work always the same then you need to think start thinking only when you need to select and we will see next week when you select which is the best rest graphql grpc kafka all that stuff will be discussed next week okay so that's the overall principles when you interact with your table you try to implement those methods or functions i told you not not a lot of slide today yeah kafka yeah not a lot a lot lot of slides there is code good good so remember the notebook we created a journey we take off by updating the journey we save stuff and we landed so let's do that with the code and and yeah so let's do it um and i will do it with my eclipse let's see okay why because i just like it so if you still doing git bud so you do have here so each time we provide you the command to pass and the expected output and so there is no real brain power here is really executing step by step and broadening code to understand what it does okay so yeah and one thing i'd like to point out as well and cedric if you could scroll to the top i'm seeing a ton of questions from folks in most many of the languages oh back i'm sorry back to the uh the github piece with the code um where you have the install instructions if you will say it again oh back to the github github not github github is getpod anyway um back to the yes if you go to the top there um so for those of you who kind of went ahead and such which is is totally fine make sure the very first step is the most important one um let's see if you scroll down just a little bit cedric it should be the essentially the install requirements kind of step right i think that's more i can't remember yeah okay you see in this case he's got a clean compile a maven clean compile right that's the important step in python you're gonna see the uh the pip3 you require i think it's the sander driver yeah and the node is gonna have the npm install if you are getting any errors like can't find module can't find cassandra driver whatever it's because that wasn't done right so make sure that you're running that step before you do any of this other stuff um so so what i you know remember how i how i import this project in my eclipse where i simply you know downloading the repo and import the the project is a maven project i could also do the python locally because i do have the cred python locally and i can just python in insta is install so i can go and python i will do the python if you need if you want just after give you time to to do so uh but you know each time install what you need here i do clean compile if i do node i will need npm install okay because we provide a package.gs with the customer driver dependency and last but not least in the python one because i told you that if you are not familiar with any language pick python so here start with pip three install cassandra drivers and as you can oops as you can see peep is is there boom and here you're good to go to do the python see and if i'm working locally but i don't want to lost you so i can totally have my own terminal let's put that here okay this is my terminal if i go to week three like you create python yeah i should be able to execute the connect to cassandra python execute to cassandra pi you know having so okay um start exercise you are okay you are connected to cluster why because the db connection that i have the proper values so everything that you are doing in git pod because you don't have to install anything you can do them locally by importing the project in your favorite id and you don't even need an ide to do python and notice all common lines uh okay so exercise so as you can see all the exercises are here and we want to do create read no create update insert now create update delete not the read because for now there is no data in the db so i'm going to insert a journey and do that di do i lost david david are you back i'm here maybe not yeah i i i am weird yeah some weird sound that you just disappear and bring back okay my i see that my image is frozen so i don't know if i'm in or not let me go check yeah sanity check move move yeah you're fine [Music] all right so moving on yeah you're frozen again yeah you're back yeah for some reason the connection okay okay maybe on your side i don't know what's happening in florida today uh no oh yeah i lost switch and everything all right well hopefully hopefully hopefully it's completely coming back so yeah i will need to hide you okay i will need to move sorry if it's rich okay so moving on i will insert a journey by saying okay i will use the repo pattern so in the java there is something called the journey repository where i did the create takeoff which is update log which is saving records and landing which is updating an existing one and look what i did i more or less add the cassandra query language queries why just because for you to figure it out what would be the query to just update the the journey so it's has been provided before in the it has been provided before in the notebook and also it has been provided in uh there at the bottom of the video all right okay so let's see let's do exercise number three insert the journey so i will simply run that and execute a unit this step is very important for everyone because i'm inserting a journey and this guy will generate a unique id you will need this id for any other exercise so make sure to copy paste this one okay moving on all right so um i could go to the notebook and show what's happening so let's see let's do that because you know you also take your time to do the exercise i want to give you the time so let's see what happens i'm going to the studio and i open a new uh you know what i'm quite lazy i will simply go there so what is we have created a journey okay and we have provided crew dragon endeavor spacex bring us rose to vss so this is the uh space craft name and the uid is there so i'm going there okay so i will select spacecraft so journey id is this guy and spacecraft is the one we just defined together crew driver endeavor okay and you know what before the quiz i will make sure that i will make david come back all right so this oh no i just copy paste the one guy okay here we go so we have created this new journey with this spacecraft and it's not yet active we just have created it but we will use this uid to move forward okay so next is takeoff right are you back i think am i is the question yeah i think you are that's a magical internet yes so you know everything is live did you finally uh plug back your internet i see some funny comments here yeah i was i was frozen no there's technology for you right there right uh no all my stuff just completely died all right yeah so anyway sorry yes we're back i'm right back i i i felt lonely though i'm sorry welcome back i won't leave you again i'm so sorry uh okay so now i will take off so i will update the existing one so see i will update the journey id and then i will take off oh did i do the right thing i think i i want zero okay and then i will execute that as a job as a unit test suspense oh yeah ignition journey has now takeoff if i look at my table boom now my journey is active and i do have a start date so it's time to register some metrics and as i define this journey id as static variables in java i don't have to do that in every other exercise but for python and for python and node exercise sorry about that you need to provide this journey id on each exercise sorry about that all right so now let's travel so travel mean you know inserting a bunch of value i do some random metrics maybe could be better just me doing a bit of random so let's see and i should be able to execute only that yeah okay now everything has been set so if i go back here and instead of selecting this spacecraft catalog i try to select let's see speed of a time okay boom i do have my 50 record for the speed not bad all right okay moving on now that we have recorded some values we will simply update the journey again just to see oh now i will make my rocket land yeah so from missa gopalan yes this is exactly what we are trying to do in the in the in the notebook yeah in the notebook we just explain you what will be the query we need you know even providing the full query and now i'll show you how to execute the very same query using the drivers because the full purpose of today is really to make you have your hands around the driver so now i told me that the journey has landed and so if i go back to the catalog and want to see what's happened now it's back to inactive and i do have an end and here i can do some matrix and we just make a rocket take off send a bunch of data and land okay create update yes please okay so 30 minutes totally fine now it's a few slides a few exercises and we are done we will be on time okay so we have just executed some queries so sometimes queries are select and you want to get back the result okay so in the four language is the same object we are using result set okay and in the result set you do have two stuff coming out of the db so first your rows this is the data you want to to pass and also execution info and before i had a question about query trust execution time it's all part of execution info then the result set is an iterable we do not provide you a list it's like a cursor you will move step by step because all the queries are paged if you do select star from a table with 1 billion rows we won't review the 1 billion rows because at best case scenario cassandra has more memory than you and you explode out of memory worst case scenario you have more memory than customer casual exploit so all queries are paged okay this is how you use a result set you execute okay this is a result of execution and if there is only one result remember you execute providing the full primary key on showing unicity you can do resultset.1 but if it's not if there are multiple things then you will have some cursor you can iterate in in rows of the resume set if you do dot list or dot all it will fetch all the pages for you so be careful with resource dot all you know i see ice i know some developer immediately do results dot all to get everything from the table but under the hood it will fetch all tables needed in until the results that it's exhausted and it can be long and you may not need all the results but also only the first page because on the ui you want to show there is only a few lines okay so now if you want to pass rows so you get a row form a result set then you will access the column with the column names exactly the same way you would do with gdbc or relational database nothing really new here and you can see that in java c-sharp we are using the name and python node we are using some suffix if the name follows some confunction without space you can totally use the column name as a variable an object mapper remember not remember but this is how the name tell how to map object to tables and we will create some objects some entities and we will define some [Music] and we will define some classes uh without code we just define the interface and with that the driver will generate for us all the query to read delete update you don't have to do it you simply have to provide an object mapping attribute to column for the table and it works so this is the four languages and i i zoom on the java one so if i look on the right part of the screen here you do have an entity providing all the values a column name and who is partition key who are which are the clustering column and with only identity spacecraft journey catalog i can say d-a-o find all and get a iterable of this object the driver will introspect this class know that we are working with this don't click with this table with this column and we'll generate the code uh at compile time to make it work as you expect and now when you want to use it you simply new mapper new diy and see with ddo you can now still start using dlo don't find all and you will get all the spacecraft and you have never written a single line of sql it just object with the proper partition so cedric i got a good one for you here yep uh try who has we've seen try multiple times in previous workshops so hello again try um i was going to answer this but then i wanted to put you on the spot because i thought it'd be fun this is a good question though thank you david thank you yeah no problem probably i don't know now what if the app crashes midway through the result set would cassandra hold the pending result set if not is the results that dropped oh that's a good one isn't it yeah i think it would be dropped so first i think it's lost yeah yeah for sure you do have a state because when you get a paging result you have something called a paging state and in the paging state what it does is actually providing the offset of the token where it is just to be able to go back to exactly what it was so you know you can query the first page get back the result with a paging state shut down everything request page number two with the same page in state because the paging state contained the token then it will fetch page two but if you have started page to you know fetching page two yeah there are still data there on the on the coordinator node but it will be timeout soon if you go fetch if you don't go fetch a page afterwards but you know still there is some kind of state mechanism if you you know you are showing a ui you are showing page one to the full to the to the people and in between you click page number two and somebody insert something in between you want to keep the same state as before and to do that they are using paging state not only to provide the the token the offset token but also the time time the timestamps this is a way to execute a query you say with timestamp and so it won't get the very last value it will get the value at the time the request has been issued in the first place yeah and there's actually some follow-up questions here um where is the results that paging stay stored in the server side or is that on the yes so the paging the page in states should be saved at the application level uh you know if so i think the next do i have some paging no i know slide from paging but in the exercise there is the last exercise is paging so in the resume set you will get something paging state you save that value and then you re-execute the same query providing now the paging step as an additional parameter and then it will go fetch page two okay um all right so let's go for the exercise five minute i can do that in front of you in five minutes no problem and uh i will answer the question of a few folks about spring right after that and i want to be on time or at five minutes late at most so i'm going to my id no my id is i lost my id here it is okay and i'm going to read exercise so first is list all all the journey for at least all the journey for uh one spacecraft so so here i do have a single journey because i have truncated my table just before we started but the query is pretty simple select star from spacecraft where spacecraft name is okay and here i'm reading the row and i say dot all why because i know there is a very few and i don't need to use paging okay same for user journey details i know if i do a query providing the full primary key i know that i will get a single result so i can go and execute select so this time is in the repository so and i need the written request select start from spacecraft and as i've provided the full primary key i know i do have a single result and so oh i just say all but i could have say one for this one should be the same oh yeah this one i should update and just only now get yeah all right let's do it the proper way i was not on the photoglass read journal details i know that i will get a journey or not and i will simply list the journey we just created together okay now matrix if i want to read all the metric stellar select start from the matrix and let me execute this one uh and see no paging whatsoever i just want everything and i'm doing dot all ah bad if i do one trillion row it can sometimes so what will happen i'm iterating with on the rows so i will get the first 5 000 which is the the default value and when i reach the latest of the page one the driver will go and fetch page two for me and so forth and so on so without noticing you will get everything listed here just because the driver just fetching page after page so now if we want to do explicit paging and this is exactly the question we had in the chat do you need to save that as the application level so yes so now east is the last exercise and the same query see select star so i'm looking for all the partition all the value in the partition speed for spacecraft and generally could be a lot but what i did in the result set i will go to execution info get the paging state okay so now i here i do have my paging state and i ask for only 10 record in the page one see page size is metadata is part of the simple statement so here i display page one then i'm using exactly the same statement just providing the paging state and now i will show page two so if you are using something like a rest api in in between calls you need to have the paging step as part of your specification to be able to invoke that page one page two and so forth and so on and if i run that so same you shouldn't have to code uh simply execute the line we provide you boom this is page one and this is page two okay and this was illustrating the uh read okay how to read the result set how to read the row how to do paging all right i told you in the beginning in the end i go very fast with the exercise but again take your time to read the code and just re-execute everything ask question on community on discord if you have a time to execute their exercise during the week those are part of the homework okay quickly if you are familiar with print okay you know that spring provide a ton of so it's a most famous java framework and spring provided tons of sub framework to help you to do one part of the other and so now related to data there is spring data doing quite the same things as the object mapper we showed we just show you provide you only the interface and entity and we will generate the code for you so funny enough we have released i think last month's uh the new uh in the new um you know compatibility between spring data 3.0 and the latest version of the data stacks driver so under the hood i'm not sure is using the same object mapper but it's working exactly the same if now you pick the latest version of spring data it is using the latest data stacks drivers working you know the same and now be able to prepare statement by the way on the youtube channel we have recorded an episode with the spring data cassandra developer it's available so remember don't forget to subscribe to the youtube channel it's not only this workshop twice a week we also doing a lot of live and this so for spring data it was distributed data show it's an episode we are doing every week and also we do have example of the week with code we show you we drive to so and just to not miss all these uh nice small video 10 minute no more then you can subscribe to the channel but they are there you can broad is this should be just below me somewhere okay and with spring data cassandra you can either use the convention in as a spring boot application ml or using a spring data case an entity and a repository working the same this is how we would like and if you're interested again go to community.nadasa.com on the forum of this workshop or uh using discord ask the question and we can provide the links with these working you know live and with that enough talking i think we are on time david i i give it it's two or two yeah yeah two minutes it's fine i think okay so your homework now for week three uh so we totally know that ds220 is massive and you know last week we asked you all not to do to only watch the video on purpose it's still a long stuff to do so for this week no new data stacks academy to digest you can keep working on ds220 and data modeling you can start doing the exercise if you didn't do before uh we have just scratched the surface about code if you go to that git git github.com examples you do have tons of sample code in any language so go for it there are samples here to do and what about now you to practice not only learn try to finish the exercise on your own okay it should be only copy paste the command but if you have any issue ask us why not also run the same on your laptop as i did simply import the project on your ide those are not mandatory just bonus try to run that on your laptop and also bonus why not changing the code moving back from secure connect bundle to contact point and connect to real cassandra not estra not astra and to have cassandra running on your laptop we provide you a docker compose you know that's the bonus of the bonus for the most advanced folk here but hey like that you practice and yet again the validation form of the week with three questions from the workshop today from uh ds220 again because it's a follow-up and these three questions as well so it's open question just to engage now we are together with three weeks already so what for you what could be the good use case for cassandra now in your future do you have any project you would consider cassandra also share with us your vision about what is cloud native and the future of climate because soon we will discuss a lot about those terms and also share what you need to success with to succeed with cassandra do we miss something is there some content we have not providing in the three three weeks tell us and we will try to prove that in the coming weeks because we still have five weeks to go and with that still again the resource but we are done we simply want you to thank you and do your homework and see you next week bye
Info
Channel: DataStax Developers
Views: 7,085
Rating: 4.9349594 out of 5
Keywords:
Id: JSDbX77NmFw
Channel Id: undefined
Length: 106min 39sec (6399 seconds)
Published: Wed Jul 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.