Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set version numbers for the 1.0.rc2 release
- Loading branch information
Showing
69 changed files
with
1,771 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import hyperclient.*; | ||
import java.util.*; | ||
|
||
public class HyperBinaryTest | ||
{ | ||
public static void printRawBytes(byte[] bytes) | ||
{ | ||
System.out.print("{" + (bytes[0] & 0x000000ff)); // zero out the negative | ||
// spilly talky bits | ||
|
||
int i = 1; | ||
|
||
do | ||
{ | ||
System.out.print(", " + (bytes[i++] & 0x000000ff)); | ||
} while ( i < bytes.length ); | ||
|
||
System.out.println("}"); | ||
} | ||
|
||
public static void main(String[] args) throws Exception | ||
{ | ||
HyperClient c = new HyperClient("127.0.0.1",1982); | ||
|
||
String desc = "space phonebook " | ||
+ "key username " | ||
+ "attributes first, last, int phone " | ||
+ "subspace first, last, phone"; | ||
|
||
System.out.println("\n\nSpace Description:\n\n" + desc + "\n\n"); | ||
|
||
c.add_space(desc); | ||
|
||
try | ||
{ | ||
HashMap<Object,Object> attrs = new HashMap<Object,Object>(); | ||
|
||
// Make up some arbitrary bytes | ||
byte[] inBytes = new byte[256]; | ||
|
||
for (int i=0; i<inBytes.length; i++) inBytes[i] = (byte)i; | ||
|
||
// Put the bytes in the field for the first name, 'first' | ||
attrs.put("first",inBytes); | ||
attrs.put("last","Tolomiczenko"); | ||
attrs.put("phone",4165551024L); | ||
|
||
System.out.println("put success: " + c.put("phonebook", "mykey", attrs)); | ||
|
||
Map map = c.get("phonebook", "mykey"); | ||
|
||
// String values are returned in the form of a ByteArray. | ||
// Instance method 'getBytes()' will yield the byte[] that | ||
// it wraps. | ||
byte[] outBytes = ((ByteArray)(map.get("first"))).getBytes(); | ||
|
||
System.out.println("bytes in:"); | ||
printRawBytes(inBytes); | ||
System.out.println("\nbytes out:"); | ||
printRawBytes(outBytes); | ||
|
||
// Let's put a proper first name now | ||
attrs.put("first","Nick"); | ||
|
||
// "Nick" will be encoded using encoding "UTF-8" | ||
// no matter what the environment is set at. | ||
// | ||
System.out.println("put success: " + c.put("phonebook", "mykey", attrs)); | ||
|
||
map = c.get("phonebook", "mykey"); | ||
System.out.println(map); | ||
|
||
// ByteArray value returned inherits default encoding | ||
// of "UTF-8" (from the client) | ||
System.out.println(((ByteArray)(map.get("first"))).getDefaultEncoding()); | ||
|
||
// That's why we can print it ie., its 'toString()' method | ||
// is implicitly called below. | ||
System.out.println((ByteArray)(map.get("first"))); | ||
|
||
// Let's the change the client's default | ||
c.setDefaultStringEncoding("ISO-8859-1"); | ||
|
||
// Re-retrieve ... | ||
map = c.get("phonebook", "mykey"); | ||
|
||
System.out.println(((ByteArray)(map.get("first"))).getDefaultEncoding()); | ||
System.out.println((ByteArray)(map.get("first"))); | ||
|
||
// Or you, the coder, can just defy the client's default | ||
// string encoding altogether ... | ||
|
||
// in the form of ByteArray | ||
attrs.put("first",new ByteArray("Nick","UTF-16BE")); | ||
|
||
// or in the form of bytes | ||
attrs.put("first",ByteArray.encode("Nick","UTF-16BE")); | ||
|
||
System.out.println("put success: " + c.put("phonebook", "mykey", attrs)); | ||
map = c.get("phonebook", "mykey"); | ||
System.out.println(((ByteArray)(map.get("first"))).decode("UTF-16BE")); | ||
} | ||
finally | ||
{ | ||
c.rm_space("phonebook"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import hyperclient.*; | ||
import java.util.*; | ||
|
||
public class HyperSearchFloatRange | ||
{ | ||
public static void main(String[] args) throws Exception | ||
{ | ||
HashMap<String,Object> values = new HashMap<String,Object>(); | ||
|
||
HyperClient c = new HyperClient("127.0.0.1",1982); | ||
|
||
String desc = "space weightbook " | ||
+ "key username " | ||
+ "attributes first, last, float weight " | ||
+ "subspace first, last, weight"; | ||
|
||
System.out.println("\n\nSpace Description:\n\n" + desc + "\n\n"); | ||
|
||
c.add_space(desc); | ||
|
||
try | ||
{ | ||
values.put("first","Nick"); | ||
values.put("last","Tolomiczenko"); | ||
values.put("weight",175.2); | ||
|
||
System.out.println("ntolomic put: " + c.put("weightbook","ntolomic",values)); | ||
|
||
values.put("first","George"); | ||
values.put("last","Tolomiczenko"); | ||
values.put("weight",160.7); | ||
|
||
System.out.println("gtolomic put: " + c.put("weightbook","gtolomic",values)); | ||
|
||
values.put("first","Paul"); | ||
values.put("last","Tolomiczenko"); | ||
values.put("weight",162.3); | ||
|
||
System.out.println("ptolomic put: " + c.put("weightbook","ptolomic",values)); | ||
|
||
System.out.println("\nAbout retrieve key ntolomic:\n"); | ||
|
||
Map row = c.get("weightbook","ntolomic"); | ||
|
||
System.out.println("Got back: " + row); | ||
|
||
System.out.println("\nSearching for last name of 'Tolomiczenko':\n"); | ||
|
||
// We'll use the same 'values' map for our search predicate | ||
|
||
// This leaves us with only the last name entry | ||
values.remove("first"); | ||
values.remove("weight"); | ||
|
||
SearchBase s = c.search("weightbook",values); | ||
|
||
while(s.hasNext()) | ||
{ | ||
System.out.println(s.next()); | ||
} | ||
|
||
// Now add a range stipulation on the weight: [160.1,165] | ||
values.put("weight", | ||
new AbstractMap.SimpleEntry<Double,Double>(160.1D,165D)); | ||
|
||
System.out.println("\nSearching for last name of 'Tolomiczenko'\n\n AND\n\nweight in the range [160.1,165]:\n"); | ||
|
||
// Do the search again | ||
s = c.search("weightbook",values); | ||
|
||
while(s.hasNext()) | ||
{ | ||
System.out.println(s.next()); | ||
} | ||
|
||
// Stipulate the range using a List of Predicate based classes. | ||
// In particular, use a Vector implementation of a List and LessEqual, | ||
// GreaterEqual both derived from Predicate. | ||
// | ||
Vector<Predicate> predicates = new Vector<Predicate>(2); | ||
predicates.add(new GreaterEqual(160.1D)); | ||
predicates.add(new LessEqual(165D)); | ||
values.put("weight",predicates); | ||
|
||
System.out.println("\nDo the search again using a List of Predicate based classes:\n"); | ||
// Do the search again | ||
s = c.search("weightbook",values); | ||
|
||
while(s.hasNext()) | ||
{ | ||
System.out.println(s.next()); | ||
} | ||
} | ||
finally | ||
{ | ||
c.rm_space("weightbook"); | ||
} | ||
} | ||
} |
Oops, something went wrong.