Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
/ hive-ormlite Public archive

Light Weight ORM which convert Hive Table records on HDFS to an Java object using annotation.

Notifications You must be signed in to change notification settings

SleepyThread/hive-ormlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hive-ormlite

Light Weight ORM which convert Hive Table records on HDFS to an Java object using annotation.

Usage:

Lets assume you have following table in Hive

hive> describe student; OK name string age int phoneno double subject array numbers map<string,int> size structst:string union uniontype<int,string>

To Map Java Student class, following is class information: Using Student Class assuming thrift server is running on machine 10.0.0.1 and port 9083

public class Main 
{

 public static void main(String args[]) throws TException, DbConfigAnnotaionMissingException, InstantiationException, IllegalAccessException, FactoryInstantiationException {
      HiveBuilderFactory hiveBuilderFactory = HiveBuilderFactory.Instance("thrift://10.0.0.1:9083");
      Text studentRecords = new Text("Akash,1,7798987147,,,");
      Student student = hiveBuilderFactory.deSerialize(Student.class, studentRecords);
      System.out.println(student.age);
      System.out.println(student.phoneNo);
      System.out.println(student.name);
      System.out.println(student.subject);
 }

  @HiveDbConfig(db="test",table ="student")
  public class Student {

    String name;
    Integer age;
    Double phoneNo;
    String subject;
    String numbers;
    String size;
    String uni;
  }
}

This will result in output

1 7.798987147E9 Akash null

About

Light Weight ORM which convert Hive Table records on HDFS to an Java object using annotation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages