Permalink
Browse files

Began fixing broken java bindings

Signed-off-by: Nick Tolomiczenko <nick.tolomiczenko@gmail.com>
  • Loading branch information...
1 parent 34448bf commit fc45a5c467673cbb75e232c34a5bec73e46583c7 @neikos neikos committed Jan 1, 2013
Showing with 828 additions and 56 deletions.
  1. 0 {hyperclient → client}/java/examples/HyperAllTypes.java
  2. 0 {hyperclient → client}/java/examples/HyperBinaryTest.java
  3. 0 {hyperclient → client}/java/examples/HyperSearchFloatRange.java
  4. 0 {hyperclient → client}/java/examples/HyperTest.java
  5. 0 {hyperclient → client}/java/examples/README.txt
  6. 0 {hyperclient → client}/java/examples/source_me
  7. 0 {hyperclient → client}/java/extra_src/ByteArray.java
  8. 0 {hyperclient → client}/java/extra_src/ByteArrayKeyedMap.java
  9. 0 {hyperclient → client}/java/extra_src/ByteArrayKeyedSortedMap.java
  10. 0 {hyperclient → client}/java/extra_src/ByteArraySortedSet.java
  11. 0 {hyperclient → client}/java/extra_src/ByteArrayVector.java
  12. 0 {hyperclient → client}/java/extra_src/Deferred.java
  13. 0 {hyperclient → client}/java/extra_src/DeferredCondPut.java
  14. 0 {hyperclient → client}/java/extra_src/DeferredCount.java
  15. 0 {hyperclient → client}/java/extra_src/DeferredDelete.java
  16. 0 {hyperclient → client}/java/extra_src/DeferredFromAttrs.java
  17. 0 {hyperclient → client}/java/extra_src/DeferredGet.java
  18. 0 {hyperclient → client}/java/extra_src/DeferredGroupDel.java
  19. 0 {hyperclient → client}/java/extra_src/DeferredMapOp.java
  20. 0 {hyperclient → client}/java/extra_src/HyperClientException.java
  21. 0 {hyperclient → client}/java/extra_src/MapOp.java
  22. 0 {hyperclient → client}/java/extra_src/MemoryError.java
  23. 0 {hyperclient → client}/java/extra_src/Pending.java
  24. 0 {hyperclient → client}/java/extra_src/Search.java
  25. 0 {hyperclient → client}/java/extra_src/SearchBase.java
  26. 0 {hyperclient → client}/java/extra_src/SimpleOp.java
  27. 0 {hyperclient → client}/java/extra_src/SortedSearch.java
  28. 0 {hyperclient → client}/java/extra_src/TypeError.java
  29. 0 {hyperclient → client}/java/extra_src/ValueError.java
  30. 0 {hyperclient → client}/java/gen_code/MapOp.template.java
  31. 0 {hyperclient → client}/java/gen_code/SimpleOp.template.java
  32. 0 {hyperclient → client}/java/gen_code/gen_op_files
  33. 0 {hyperclient → client}/java/gen_code/op_list.txt
  34. +3 −3 {hyperclient → client}/java/hyperclient.i
  35. +46 −31 {hyperclient → client}/java/proxies/HyperClient.i
  36. 0 {hyperclient → client}/java/proxies/hyperclient_attribute.i
  37. +779 −0 client/java/proxies/hyperclient_attribute_check.i
  38. 0 {hyperclient → client}/java/proxies/hyperclient_map_attribute.i
  39. +0 −22 hyperclient/java/proxies/hyperclient_range_query.i
@@ -38,7 +38,7 @@
%{
#include <limits.h>
#include <cstdlib>
-#include "hyperclient/hyperclient.h"
+#include "client/hyperclient.h"
typedef hyperclient_attribute* hyperclient_attribute_asterisk;
typedef hyperclient_range_query* hyperclient_range_query_asterisk;
%}
@@ -93,7 +93,7 @@ typedef hyperclient_range_query* hyperclient_range_query_asterisk;
%apply (char *STRING, int LENGTH) { (const char *value, size_t value_sz) }
-// Pertaining to the include of hyperdex.h and hyperclient/hyperclient.h below:
+// Pertaining to the include of hyperdex.h and client/hyperclient.h below:
// Ignore everything
%ignore "";
@@ -116,4 +116,4 @@ typedef hyperclient_range_query* hyperclient_range_query_asterisk;
%rename("%s", %$ismember) "";
%include "hyperdex.h"
-%include "hyperclient/hyperclient.h"
+%include "client/hyperclient.h"
@@ -36,20 +36,28 @@
memcpy(name, str.data(), name_sz);
}
- static int get_range_query_attr_name_sz(hyperclient_range_query *rq)
+ static int get_attr_check_name_sz(hyperclient_attribute_check *hac)
{
- std::string str = std::string(rq->attr);
+ std::string str = std::string(hac->attr);
size_t name_sz = str.length();
return name_sz > INT_MAX ? (int)INT_MAX : (int)name_sz;
}
- static std::string read_range_query_attr_name(hyperclient_range_query *rq,
- char *name, size_t name_sz)
+ static void read_attr_check_name(hyperclient_attribute_check *hac,
+ char *name, size_t name_sz)
{
- std::string str = std::string(rq->attr);
+ std::string str = std::string(hac->attr);
memcpy(name, str.data(), name_sz);
}
+ static void read_attr_check_value(hyperclient_attribute_check *hac,
+ char *value, size_t value_sz,
+ size_t pos)
+ {
+ size_t available = hac->value_sz - pos;
+ memcpy(value, hac->value+pos, value_sz<available?value_sz:available);
+ }
+
static hyperclient_attribute *alloc_attrs(size_t attrs_sz)
{
return (hyperclient_attribute *)calloc(attrs_sz,sizeof(hyperclient_attribute));
@@ -84,20 +92,21 @@
free(attrs);
}
- static hyperclient_range_query *alloc_range_queries(size_t rqs_sz)
+ static hyperclient_attribute_check *alloc_attrs_check(size_t attrs_sz)
{
- return (hyperclient_range_query *)calloc(rqs_sz,
- sizeof(hyperclient_range_query));
+ return (hyperclient_attribute_check *)calloc(attrs_sz,
+ sizeof(hyperclient_attribute_check));
}
- static void free_range_queries(hyperclient_range_query *rqs, size_t rqs_sz)
+ static void free_attrs_check(hyperclient_attribute_check *attrs, size_t attrs_sz)
{
- for (size_t i=0; i<rqs_sz; i++)
+ for (size_t i=0; i<attrs_sz; i++)
{
- if (rqs[i].attr) free((void*)(rqs[i].attr));
+ if (attrs[i].attr) free((void*)(attrs[i].attr));
+ if (attrs[i].value) free((void*)(attrs[i].value));
}
- free(rqs);
+ free(attrs);
}
// Returns 1 on success. ha->attr will point to allocated memory
@@ -192,33 +201,39 @@
return 1;
}
- static int write_range_query(hyperclient_range_query *rq,
+ // Returns 1 on success. hac->attr will point to allocated memory
+ // Returns 0 on failure. hac->attr will be NULL
+ static int write_attr_check_name(hyperclient_attribute_check *hac,
const char *attr, size_t attr_sz,
- int64_t lower,
- int64_t upper)
+ hyperdatatype type, hyperpredicate pred)
{
char *buf;
if ((buf = (char *)calloc(attr_sz+1,sizeof(char))) == NULL) return 0;
memcpy(buf,attr,attr_sz);
- rq->attr = buf;
- (rq->lower_t).i = lower;
- (rq->upper_t).i = upper;
+ hac->attr = buf;
+ hac->datatype = type;
+ hac->predicate = pred;
return 1;
}
- static int write_range_query(hyperclient_range_query *rq,
- const char *attr, size_t attr_sz,
- double lower,
- double upper)
+ // Returns 1 on success. hac->value will point to allocated memory
+ // hac->value_sz will hold the size of this memory
+ // Returns 0 on failure. hac->value will be NULL
+ // hac->value_sz will be 0
+ //
+ // If hac->value is already non-NULL, then we are appending to it.
+ static int write_attr_check_value(hyperclient_attribute_check *hac,
+ const char *value, size_t value_sz)
{
- char *buf;
-
- if ((buf = (char *)calloc(attr_sz+1,sizeof(char))) == NULL) return 0;
- memcpy(buf,attr,attr_sz);
- rq->attr = buf;
- (rq->lower_t).d = lower;
- (rq->upper_t).d = upper;
+ char *buf = NULL;
+ // Note: Since hyperclient_attribute_check array was calloced
+ // hac->value = NULL and hac->value_sz = 0 initially
+ if ((buf = (char *)realloc((void *)(hac->value), hac->value_sz + value_sz))
+ == NULL) return 0;
+ memcpy(buf + hac->value_sz, value, value_sz);
+ hac->value = buf;
+ hac->value_sz += value_sz;
return 1;
}
@@ -232,9 +247,9 @@
return hma + i;
}
- static hyperclient_range_query *get_range_query(hyperclient_range_query *rqs, size_t i)
+ static hyperclient_attribute_check *get_attr_check(hyperclient_attribute *hac, size_t i)
{
- return rqs + i;
+ return hac + i;
}
};
Oops, something went wrong.

0 comments on commit fc45a5c

Please sign in to comment.