Friday, August 18, 2017

MFC Concepts for Preparation

MFC Concepts

Visual Studio 2015
 
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at MFC Concepts.
This section provides conceptual and task-based topics to help you program using the Microsoft Foundation Class (MFC) Library.
General MFC Topics
Discusses the technical details of the MFC Library.
Using CObject
Provides links to using CObject, the base class for most classes in MFC.
Collections
Discusses collection classes created from and not created from C++ templates.
Date and Time
Provides links to topics discussing using date and time with MFC.
Files
Discusses CFile and how to handle files in MFC.
Memory Management (MFC)
Describes how to take advantage of the general-purpose services related to memory management.
Message Handling and Mapping
Describes how messages and commands are processed by the MFC framework and how to connect them to their handler functions.
Serialization
Explains the serialization mechanism provided to allow objects to persist between runs of your program.
Unicode
Describes MFC support for the Unicode standard for encoding wide characters on Windows NT, Windows 2000, and Windows XP platforms.
Exception Handling (MFC)
Explains the exception-handling mechanisms available in MFC.
MFC Internet Programming Basics
Discusses the MFC classes that support Internet programming.
MFC Internet Programming Tasks
Discusses how to add Internet support to your applications.
MFC COM
Discusses a subset of MFC, which is designed to support COM, while most of the Active Template Library (ATL) is designed for COM programming.
Multithreading with C++ and MFC
Describes what processes and threads are and discusses the MFC approach to multithreading.
Windows Sockets in MFC
Covers the MFC implementation of Windows Sockets.
MFC Reference
Provides reference material for the MFC Library, a set of classes that constitute an application framework, which is the framework of an application written for the Windows API.
MFC Samples
Provides links to samples that show how to use MFC in desktop applications, DLLs, database applications, controls, Web applications, and more.

Friday, July 14, 2017

What i s a Function Pointer ?


function pointer is a variable that stores the address of a function that can later be called through that function pointer. This is useful because functions encapsulate behavior.
Declaring a Pointer to a Function
Declaration of pointers to functions resembles other declarations. For example, just as we write
int *p;
to say that *p has type int and implying that p is a pointer, we may write
int (*pf)(int);
to say that if we dereference pf, and call it with an int argument, the result has type int. By implication, pf is a pointer to a function that takes an int argument and returns an int result.
A pointer to a function is similar to a pointer to data but it should always be enclosed in parenthesis when using the dereference operator (*) to avoid an compilation error. It then be followed by another parenthesis containing any arguments to be passed to the function when using the *.
Because all that we can do with a function is to take its address or call it, any use of a function that is not a call is assumed to be taking its address, even without an explicit &.
Suppose we have a function with the following prototype:
int f(int); //prototype
Note that it look just like our declaration of pointer to a function:
int (*pf)(int);
Because f is a function, so is (*pf). And if (*pf) is a function, then pf must be a pointer to a function.
The declaration requires the parentheses around *pf to provide the proper operator precedence. Parentheses have a higher precedence than the * operator, so *pf(int) means pf() is a function that returns a pointer while (*pf)(int) means pf is a pointer to a function.
int (*pf)(int); // pf points to a function that returns int
int *pf(int); // pf() is a function that returns a pointer to int
Once we declare pf properly, we can assign to it the address of a matching function:
int f(int);
int (*pf)(int);
pf = f;  // pf now points to the f() function
Invoking a Function Using a Pointer
As we discussed in the previous section, (*pf) serves as a name of a function. In other words, function pointers are invoked by name just like normal function calls.
int f(int);
int (*pf)(int);
pf = f;   // pf now points to the f() function
int i = f(4);  // call f() using the function name
int j = (*pf)(4); // call f() using the pointer pf
int k = pf(5)  // also call f() using the pointer pf
The code below shows very simple usage of function pointer:
#include <iostream>
using namespace std;

int square(int n) {
 return n*n;
}

int main()
{
 int (*pf)(int);
 pf = square;
 cout << "square(7) = " << pf(7) << endl;
        return 0;
}

Here is another example using a pointer to a function.
#include <iostream>  
using namespace std;

int operation (int i, int j, int (*pf)(int,int)) {
 int k;
 k = (*pf)(i,j);
 /* This works, too.
   k = pf(i,j) 
 */
 return k;
}

int addition (int a, int b) { 
 return a+b; 
}

int division (int a, int b) { 
 return a/b; 
}

int main()  
{   
 int m = operation (10, 5, addition);
 int n = operation (10, 5, division);

 cout << "m = " << m << endl;
 cout << "n = " << n << endl;

 return 0;
}
Output is:
m = 15
n = 2


For More Please refer the link

 http://www.bogotobogo.com/cplusplus/pointers3_function_multidimensional_arrays.php

Tuesday, June 13, 2017

HDFS (hadoop distrubuted file system) commands

1)Start-all.sh  -to start all
2) ->Hadoop
3) Hadoop namenode –format

To start hdfs
1)           Start-dfs-sh to start hadoop i.e name node,data node ,secondary node
2)           Start-mapred.sh to start job tracker and task tracker
Admin commands
Dfsadmin
Mradmin
Fsck
Balancer
Distep
Fs
Pipes
Job
Queue
Jar

Developer commands
1)           Hadoop fs
2)           Hadoop fs –ls /
3)           Hadoop –lsr
4)           Hadoop fs –mkdir /newfolder
5)           Hadoop fs –ls foldername
6)           Hadoop fs – put /etc/hostname /etc/hosts/kalian
7)           Jps
8)           Hadoop fs –cp /folder/host1 /folder/host2
9)           put – local to hdfs
10)   cp,mv – hdfs to hdfs
11)   get – hdfs to local
12)   rm
13)   hadoop fs –chown -  r    (read permissions to other user)
14)   hadoop fs –cat
15)   hadoop fs –text
16)   hadoop fs –du
17)   hadoop fs –dus

18)   hadoop –help

Saturday, June 10, 2017

HADOOP ECOSYSTEM


HADOOP ECO SYSTEM

More detailed refer : https://www.youtube.com/watch?v=1WY63n2XRLM&list=PLBk6njDje9VvahPJMFbC4uK_CWXKcVoKY&index=1

More training Material refer the link : http://www.kalyanhadooptraining.com/



Wednesday, June 7, 2017

What is Big Data ?


What is Big Data ?

1. Big data is a term for data sets that are so large or complex that traditional data processing application software is inadequate to deal with them. Challenges include capture, storage, analysis, data curation, search, sharing, transfer, visualization, querying, updating and information privacy

Wiki Link : https://en.wikipedia.org/wiki/Big_data

Useful Videos :

1) https://www.youtube.com/watch?v=9iqlrlWj91g

2) https://www.youtube.com/watch?v=zez2Tv-bcXY&list=PL9ooVrP1hQOFrYxqxb0NJCdCABPZNo0pD


#1. Hadoop Real-World Solutions Cookbook by Jonathan Owens, Brian Femiano, Jon Lentz 
The book offers code examples and real-world explanations for Hadoop. Each chapter brings a set of easy to follow instructions including technical challenges and solutions for Hadoop-related problems. The book breaks down a single problem into discrete steps that are easy to follow. You can use this one as a practice book to get started with Hadoop. 

#2. Hadoop in 24 hours by SamsTeach Yourself 

This is a good Hadoop book for beginners. It is basically an easy guide to learn Hadoop. Beginners can find Hadoop as a complex technical framework to learn but this book simplifies everything. The book teaches about Hadoop environment, HDFS, Java MapReduce and proper syntax for all. You will also learn more about open source tools like Pig, Hive, and YARN. 

#3. Hadoop 2 Quick Start Guide by Douglas Eadline 

The quick start guide covers all the latest features and explains how the Hadoop environment works. You don't need many years of experience of coding in Hadoop to start using this book. The chapters included in this book cover basics of MapReduce, and various Hadoop tools. 

#4. Hadoop for Dummies by Dirk deRoos, Paul Zikopoulos, Roman Melnyk, Bruce Brown, Rafael Cross 

The Dummies series is a good reference point for beginners. These books offer a lot in terms of learning and you don’t have to be bothered about the complexities of the project. Any developer can pick up this book and acquire a good understating of Hadoop. The framework seems complex at first, but this guide will help move along swiftly in understanding Hadoop. 

#5. Hadoop in Action by Chuck Lan 

This book starts with the basic idea of Hadoop and MapReduce. It teaches concepts that are easier to grasp by applying the default Hadoop installation and easy to follow tasks. You can use this book to understand various basic concepts of MapReduce applications developed using Hadoop, including a close look at framework components. The book include numerous examples of Hadoop in action.

Friday, December 30, 2016

.NET Multi Threading

Multi Threading:-Ø  A single program performing multiple actions in a symaltencily is known as Multi Threading. Traditionally we come accrues a concept multi tasking. In which more then one program can execute at a given point of time.
Ø  Multi tasking is supported by the OS, where as Multi threading is supported by the language.
Ø  DOS was a single tasking. Window, Linux was a multi tasking applications.
Ø  Servers, MS Word, Excel etc… were example for multi threading applications.
Ø  A thread is a unit of execution by default every program has one thread or unit of execution, that is main thread, which is responsible in executing the code.
Ø  In single thread a model in there were multiple methods executed the execution will be one method call after the other. In the sense after completely executing one method then only the controls go’s to the other method for execution.
Ø  So, in this case until the method which is executed is completing its execution other method has to wait even if there was a delay execution of the method.
Ø  In multi threading there will be multiple unit of execution responsible in execution of code. That is for each method we use a different thread for execution. So, the execution will be as following:
1.   Time sharing.
-      This was the first principle on which multiple thread will be executing. Where the OS results some time period for teach thread to execute and makes then to execute in a symaltencily.
2.   Maximum Utilization of Resource.
-      This principle comes into picture only when the first principle violated. That is if a thread could not execute in the time allocated to it without waiting for the thread to execute the control immediately to transfer to the other thread in execution.
Ø  How to create a thread:-to create a thread we were provided with a class thread under the system. Threading Namespace each object we create for the class will be consider as one thread. Will be creating the object of thread we need to pass the method name as a parameter to its constructor.
Ex:-*  System Threading.Thread(<Method Name>)
Thread t1 = new Thread(Method1);Thread t2 = new Thread(Method2);Thread t3 = new Thread(Method3);Ø  Methods and Properties of thread class:-
1.   Start()
-      Start the execution of a thread.
2.   Abort()
-      Terminates the execution of a thread.
3.   Suspend()
-      Suspends the execution of a thread, until resume was called.
4.   Resume()
-      Resumes a suspend of a thread.
5.   Sleep(int milliseconds)
-      Suspends the execution of a thread. A static which suspend the current executing thread until the given time period was elapsed.
6.   Join()
-      Makes the main thread to wait until the thread which calls leaving the program.
7.   Priority()
-      A newmaritic property for setting the thread of a given thread.
*      Add a class ThreadDemo.cs
using System.Threading;class ThreadDemo{Thread t1, t2;public ThreadDemo(){t1 =new Thread(show1);t2 =new Thread(show2);t1.Start}public void Show1(){for(int i=1; i<100; i++);{Console.WriteLine(“Test1: +i”);if(i==100)Thread.Sleep(1000);}Console.WriteLine(“Thread 1 exiting”);}public void Show2(){for(int i=1; i<100; i++);{Console.WriteLine(“Test2: +i”);}Console.WriteLine(“Thread 2 exiting”);}static void Main(){ThreadDemo obj=new ThreadDemo();Obj.t1.Join();Obj.t2.Join();Console.WriteLine(“Main Thread Exiting”);}}  Ø  Thread Priority: -
By default when there was multiple threads in execution all the threads gets executed within equal implement are priority that is OS gives same preference to all threads to share the CPU resources. If required we can change the priority of the threads and request the OS to give additional priority to any of the thread in execution. Each can be done by setting the priority with any of the 5 values.1.    Lowest
2.    Below Normal
3.    Normal(default)
4.    Above Normal
5.    Highest
Ø  The thread with the highest priority well consumes more CPU resources then the thread with lowest priority.
*  Add a class ThreadDemo.cs and write the following code.
*  using System;
using System.Threading;class ThreadDemo2{Thread t1, t2;long count1, count2;public ThreadDemo2(){t1=new Thread(IncrementCount1);t2=new Thread(IncrementCount2);//t1.Priority = ThreadPriority.Lowest;//t2.Priority = ThreadPriority.Highest;t1.Start(); t2.Start();}public void IncrementCount1(){while(true)Count1  += 1;}public void IncrementCount2(){while(true)Count2  += 1;}static void Main(){ThreadDemo2 obj =new ThreadDemo2();Obj.t1.Abort(); Obj.t2.Abort();Console.WriteLine(“Count1 :” + obj.Count1);Console.WriteLine(“Count2 :” + obj.Count2);obj.t1.Join(); obj.t2.Join();} }Ø  When you execute the above program two threads gets created incrementing the count variables in a independent loop. So, by default as all the thread have the equal priority they increment the value with equal important. In this case we can’t judge which count variable will be higher.
Ø  Now uncomment the two line of code under the constructor and then execute to check the result. Where in this case maximum the count2 value will be higher when compare be count1. Because it was given more priority than the thread1.
Ø  Thread locking (Or) Synchronization: -
Ø  In multithreading we were using a different thread to call a different method. In such cases we never have a problem but in some cases multiple threads may be calling the same method of execution. In such case we will be getting unexpected results to check this.
Ø  Add a class ThreadDemo3.cs and write the following code.
*  using System;
using System.Threading;class ThreadDemo3{Thread t1, t2, t3;public ThreadDemo3(){t1 = new Thread(Display);t2 = new Thread(Display);t3 = new Thread(Display);t1.Start(); t2.Start(); t3.Start();}public void Display(){Cosole.Write(“[C# is”);Thread.Sleep(5000);Console.WriteLine(“object oriented]”);}static void Main(){ThreadDemo3 obj = new ThreadDemo3();obj.t1.Join();}Ø  Run the above program and check the results where we can understand the problem which comes in the picture because multiple threads accessing the same problem. To over come this above problem we can lock  the code under present the method as following:
             public void Display()             {Lock(this){Cosole.Write(“[C# is”);Thread.Sleep(5000);Console.WriteLine(“object oriented ]”);}}Ø  Know run the program and check out difference in out put. Where in this case as the code under the method is lock it will allow only one thread to enter inside. And if any other thread tries to access the method at the same time it has to wait out side until the thread which is inside come out.
  
           

Vi Editor

VI EDITOR Move move in the editor: h right j up k  down l left move top shift +g gg down the line of the file :8 go to line 8 search /string...