看完這個類,感覺設計這個類的哥們思維不清晰,有點腦殘。
這個類進程類RawComparator的意思是說,提供了一個兩個方法
1.個是通過類比較,1個是通過類的字符流比較。當然側重后者。
你看看里面管七八糟的方法,如果這個類別不用的方法,馬上麻煩設計的大哥能不能設置成私有方法。
?? 還有 如果通過流比較 還要把構造函數 第二參數 設置成true. 只是要備注說明吧。
?? 如果不看源代碼,只看api的人。真的用不起來這個類。
compare(WritableComparable a, WritableComparable b)
這個比較是比較值的大小
compareBytes(byte[] b1, int s1, int l1,
???????????????????????????????? byte[] b2, int s2, int l2)
這個需要構造參數的第二個參數為true
變量
comparators
private static HashMap<Class, WritableComparator> comparators =
??? new HashMap<Class, WritableComparator>(); // registry
為了提高效率把 類型和比較器放到map里
因為hashmap是線程不安全,為了保證線程安全
在用到put的方法上加了synchronized
? public static synchronized void define(Class c,
???????????????????????????????????????? WritableComparator comparator) {
??? comparators.put(c, comparator);
? }
里面很多redaInt ,readLong,readDouble等方法。
是字符串和 int longdouble類型的轉換。
具體怎么轉換,readVInt 和readInt區別
看我以后的博客
? /** Parse an integer from a byte array. */
? public static int readInt(byte[] bytes, int start) {
??? return (((bytes[start? ] & 0xff) << 24) +
??????????? ((bytes[start+1] & 0xff) << 16) +
??????????? ((bytes[start+2] & 0xff) <<?
+
??????????? ((bytes[start+3] & 0xff)));
? }
這個類進程類RawComparator的意思是說,提供了一個兩個方法
1.個是通過類比較,1個是通過類的字符流比較。當然側重后者。
你看看里面管七八糟的方法,如果這個類別不用的方法,馬上麻煩設計的大哥能不能設置成私有方法。
?? 還有 如果通過流比較 還要把構造函數 第二參數 設置成true. 只是要備注說明吧。
?? 如果不看源代碼,只看api的人。真的用不起來這個類。
compare(WritableComparable a, WritableComparable b)
這個比較是比較值的大小
compareBytes(byte[] b1, int s1, int l1,
???????????????????????????????? byte[] b2, int s2, int l2)
這個需要構造參數的第二個參數為true
變量
comparators
private static HashMap<Class, WritableComparator> comparators =
??? new HashMap<Class, WritableComparator>(); // registry
為了提高效率把 類型和比較器放到map里
因為hashmap是線程不安全,為了保證線程安全
在用到put的方法上加了synchronized
? public static synchronized void define(Class c,
???????????????????????????????????????? WritableComparator comparator) {
??? comparators.put(c, comparator);
? }
里面很多redaInt ,readLong,readDouble等方法。
是字符串和 int longdouble類型的轉換。
具體怎么轉換,readVInt 和readInt區別
看我以后的博客
? /** Parse an integer from a byte array. */
? public static int readInt(byte[] bytes, int start) {
??? return (((bytes[start? ] & 0xff) << 24) +
??????????? ((bytes[start+1] & 0xff) << 16) +
??????????? ((bytes[start+2] & 0xff) <<?

??????????? ((bytes[start+3] & 0xff)));
? }
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
