test.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "thrift_wrapper.h"
  4. #define host "127.0.0.1"
  5. #define port 9160
  6. int main()
  7. {
  8. char *keyspace = NULL;
  9. char *value_in = NULL;
  10. char *value_out = NULL;
  11. char *column_family = NULL;
  12. char *key = NULL;
  13. char *column = NULL;
  14. /* Setting the values. */
  15. keyspace = "indigital";
  16. value_in = "Luis Martin Gil";
  17. column_family = "employees";
  18. key = "lmartin";
  19. column = "name_ext";
  20. /* Doing the insert. */
  21. printf("Insert. %s['%s']['%s'] <== '%s' ", column_family, key, column, value_in);
  22. if (insert_wrap(host, port, keyspace, column_family, key, column, &value_in) > 0) {printf("SUCCESS\n");}
  23. else {printf("FAILURE\n");}
  24. printf ("-----------------\n");
  25. /* Doing the retrieve. */
  26. printf("Retrieve. %s['%s']['%s'] ==> ", column_family, key, column);
  27. if (retrieve_wrap(host, port, keyspace, column_family, key, column, &value_out) > 0) {
  28. if (value_out) {
  29. printf("'%s' SUCCESS\n", value_out);
  30. free(value_out);
  31. }
  32. } else {printf("FAILURE\n");}
  33. return 1;
  34. }