Fortune Telling Collection - Fortune-telling birth date - Custom UDF function, saved from hive to mongodb.

Custom UDF function, saved from hive to mongodb.

(You can debug UDF function through the idea tool, and the second step will provide reference. )

1, the first is the pom.xml file.

2. About mongo's helper class

3. User-defined function MongoStorageHandler entry class

Preparation: First, upload the prepared UDF function jar package and related dependency packages to the server (WinSCP tool can be selected under windows). For example, the UDF function is uploaded to the /home/username/tmp directory, and the dependency package is under /home/username/tmp/lib.

1. Configure remote configuration in idea (as shown in figure 1):

2. Enable the debug mode of the hive:

Configuration unit debugging

3. At this time, we are listening to port 8000 (listening address: Transport DT _ Socket of 8000) and starting the debugging mode of the configured remote controller in the idea;

4. Enter the following command to customize the function name (sign_func):

5. Call the custom function sign_func:

Ok, go to mongodb to see if the data is stored in the mongo library.