Ankith Reddy has Published 1070 Articles

IntStream skip() method in Java

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

217 Views

The skip() method of the IntStream class in Java returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.The syntax is as followsIntStream skip(long n)Here, n is the number of elements to skip. The method returns the new stream.Create an ... Read More

Getting a distinct aggregation of an array field across indexes

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

71 Views

To get a distinct aggregation of an array field across indexes, let us take an example and create a collection with some documents.Following is the query to create a collection with documents> db.distinctAggregation.insertOne({"UserName":"Larry", "UserPost":["Hi", "Hello"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c98aefb330fd0aa0d2fe4c6") } > db.distinctAggregation.insertOne({"UserName":"Chris", "UserPost":["Hi", "Good Morning"]}); ... Read More

How many levels of pointers can we have in C/C++?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

127 Views

Actually, C programs one or two static levels of pointers are common. Triple indirection is rare. But infinite is very common. Infinite pointer indirection can be achieved with the help of a struct.struct list { struct list *next; ... } lst; lst->next->next->next->...->nextand in this way we can implement multiple pointer ... Read More

How to set two variables in a stored procedure with a single MySQL select statement?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

2K+ Views

For this, let us first create a new table in MySQLmysql> create table useProcedure - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > FirstName varchar(20), - > LastName varchar(20) - ... Read More

IntStream count() method in Java

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

89 Views

The count() method of the IntStream class in Java returns the count of elements in this streamThe syntax is as followslong count()First, create an IntStream and add some elementsIntStream intStream = IntStream.of(30, 13, 67, 56, 89, 99, 76, 56);Now, get the count of elements of the stream using the count() ... Read More

How to specify exact order with WHERE `id` IN (…) in MySql?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

586 Views

To specify exact order with where id IN, you need to use find_in_set() function.The syntax is as followsSELECT *FROM yourTableName WHERE yourColumnName IN (yourValue1, yourValue2, yourValue3, ....N) ORDER BY FIND_IN_SET(yourColumnName , ‘yourValue1, yourValue2, yourValue3, ....N’');Let us first create a tablemysql> create table FindInSetDemo    - > (    - > ... Read More

LongStream max() method in Java

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

208 Views

The max() method of the LongStream class in Java returns an OptionalLong describing the maximum element of this stream, or an empty optional if this stream is empty.The syntax is as followsOptionalLong max()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream ... Read More

Return True if a document exists in MongoDB?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

3K+ Views

Let us first create a collection. Following is the query to create a collection with documents> db.documentExistsOrNotDemo.insertOne({"UserId":101, "UserName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9932bd330fd0aa0d2fe4cf") } > db.documentExistsOrNotDemo.insertOne({"UserId":102, "UserName":"Chris"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9932c6330fd0aa0d2fe4d0") } > db.documentExistsOrNotDemo.insertOne({"UserId":102, "UserName":"Robert"}); {    "acknowledged" : true,   ... Read More

In C++ What are the differences between a pointer variable and a reference variable?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

269 Views

ReferencesWhen a variable is declared as reference, it becomes an alternative name for an existing variable.SyntaxType &newname = existing name;InitializatioType &pointer; pointer = variable name;PointersPointers are used to store the address of variable.SyntaxType *pointer;InitializationType *pointer; pointer = variable name;The main differences between references and pointers are -References are used to ... Read More

Find all the non-distinct values of a field in MongoDB?

Ankith Reddy

Ankith Reddy

Updated on 30-Jul-2019 22:30:25

768 Views

Use aggregate() method to get all the non-distinct values of a field. Let us first create a collection with documents> db.findAllNonDistinctDemo.insertOne({"UserName":"John", "UserAge":28}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c995078863d6ffd454bb647") } > db.findAllNonDistinctDemo.insertOne({"UserName":"Larry", "UserAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c995081863d6ffd454bb648") } > db.findAllNonDistinctDemo.insertOne({"UserName":"Larry", "UserAge":23}); {   ... Read More

Advertisements