http://git-wip-us.apache.org/repos/asf/hbase-site/blob/00c22388/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.html index 52745c5..e098e72 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.html @@ -70,69 +70,75 @@ <span class="sourceLineNo">062</span> return this.count > this.limit;<a name="line.62"></a> <span class="sourceLineNo">063</span> }<a name="line.63"></a> <span class="sourceLineNo">064</span><a name="line.64"></a> -<span class="sourceLineNo">065</span> @Override<a name="line.65"></a> -<span class="sourceLineNo">066</span> public ReturnCode filterKeyValue(Cell v) {<a name="line.66"></a> -<span class="sourceLineNo">067</span> this.count++;<a name="line.67"></a> -<span class="sourceLineNo">068</span> return filterAllRemaining() ? ReturnCode.NEXT_COL : ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.68"></a> +<span class="sourceLineNo">065</span> @Deprecated<a name="line.65"></a> +<span class="sourceLineNo">066</span> @Override<a name="line.66"></a> +<span class="sourceLineNo">067</span> public ReturnCode filterKeyValue(final Cell c) {<a name="line.67"></a> +<span class="sourceLineNo">068</span> return filterCell(c);<a name="line.68"></a> <span class="sourceLineNo">069</span> }<a name="line.69"></a> <span class="sourceLineNo">070</span><a name="line.70"></a> <span class="sourceLineNo">071</span> @Override<a name="line.71"></a> -<span class="sourceLineNo">072</span> public void reset() {<a name="line.72"></a> -<span class="sourceLineNo">073</span> this.count = 0;<a name="line.73"></a> -<span class="sourceLineNo">074</span> }<a name="line.74"></a> -<span class="sourceLineNo">075</span><a name="line.75"></a> -<span class="sourceLineNo">076</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.76"></a> -<span class="sourceLineNo">077</span> Preconditions.checkArgument(filterArguments.size() == 1,<a name="line.77"></a> -<span class="sourceLineNo">078</span> "Expected 1 but got: %s", filterArguments.size());<a name="line.78"></a> -<span class="sourceLineNo">079</span> int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));<a name="line.79"></a> -<span class="sourceLineNo">080</span> return new ColumnCountGetFilter(limit);<a name="line.80"></a> -<span class="sourceLineNo">081</span> }<a name="line.81"></a> -<span class="sourceLineNo">082</span><a name="line.82"></a> -<span class="sourceLineNo">083</span> /**<a name="line.83"></a> -<span class="sourceLineNo">084</span> * @return The filter serialized using pb<a name="line.84"></a> -<span class="sourceLineNo">085</span> */<a name="line.85"></a> -<span class="sourceLineNo">086</span> public byte [] toByteArray() {<a name="line.86"></a> -<span class="sourceLineNo">087</span> FilterProtos.ColumnCountGetFilter.Builder builder =<a name="line.87"></a> -<span class="sourceLineNo">088</span> FilterProtos.ColumnCountGetFilter.newBuilder();<a name="line.88"></a> -<span class="sourceLineNo">089</span> builder.setLimit(this.limit);<a name="line.89"></a> -<span class="sourceLineNo">090</span> return builder.build().toByteArray();<a name="line.90"></a> -<span class="sourceLineNo">091</span> }<a name="line.91"></a> -<span class="sourceLineNo">092</span><a name="line.92"></a> -<span class="sourceLineNo">093</span> /**<a name="line.93"></a> -<span class="sourceLineNo">094</span> * @param pbBytes A pb serialized {@link ColumnCountGetFilter} instance<a name="line.94"></a> -<span class="sourceLineNo">095</span> * @return An instance of {@link ColumnCountGetFilter} made from <code>bytes</code><a name="line.95"></a> -<span class="sourceLineNo">096</span> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException<a name="line.96"></a> -<span class="sourceLineNo">097</span> * @see #toByteArray<a name="line.97"></a> -<span class="sourceLineNo">098</span> */<a name="line.98"></a> -<span class="sourceLineNo">099</span> public static ColumnCountGetFilter parseFrom(final byte [] pbBytes)<a name="line.99"></a> -<span class="sourceLineNo">100</span> throws DeserializationException {<a name="line.100"></a> -<span class="sourceLineNo">101</span> FilterProtos.ColumnCountGetFilter proto;<a name="line.101"></a> -<span class="sourceLineNo">102</span> try {<a name="line.102"></a> -<span class="sourceLineNo">103</span> proto = FilterProtos.ColumnCountGetFilter.parseFrom(pbBytes);<a name="line.103"></a> -<span class="sourceLineNo">104</span> } catch (InvalidProtocolBufferException e) {<a name="line.104"></a> -<span class="sourceLineNo">105</span> throw new DeserializationException(e);<a name="line.105"></a> -<span class="sourceLineNo">106</span> }<a name="line.106"></a> -<span class="sourceLineNo">107</span> return new ColumnCountGetFilter(proto.getLimit());<a name="line.107"></a> -<span class="sourceLineNo">108</span> }<a name="line.108"></a> -<span class="sourceLineNo">109</span><a name="line.109"></a> -<span class="sourceLineNo">110</span> /**<a name="line.110"></a> -<span class="sourceLineNo">111</span> * @param other<a name="line.111"></a> -<span class="sourceLineNo">112</span> * @return true if and only if the fields of the filter that are serialized<a name="line.112"></a> -<span class="sourceLineNo">113</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.113"></a> -<span class="sourceLineNo">114</span> */<a name="line.114"></a> -<span class="sourceLineNo">115</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.115"></a> -<span class="sourceLineNo">116</span> if (o == this) return true;<a name="line.116"></a> -<span class="sourceLineNo">117</span> if (!(o instanceof ColumnCountGetFilter)) return false;<a name="line.117"></a> -<span class="sourceLineNo">118</span><a name="line.118"></a> -<span class="sourceLineNo">119</span> ColumnCountGetFilter other = (ColumnCountGetFilter)o;<a name="line.119"></a> -<span class="sourceLineNo">120</span> return this.getLimit() == other.getLimit();<a name="line.120"></a> -<span class="sourceLineNo">121</span> }<a name="line.121"></a> -<span class="sourceLineNo">122</span><a name="line.122"></a> -<span class="sourceLineNo">123</span> @Override<a name="line.123"></a> -<span class="sourceLineNo">124</span> public String toString() {<a name="line.124"></a> -<span class="sourceLineNo">125</span> return this.getClass().getSimpleName() + " " + this.limit;<a name="line.125"></a> -<span class="sourceLineNo">126</span> }<a name="line.126"></a> -<span class="sourceLineNo">127</span>}<a name="line.127"></a> +<span class="sourceLineNo">072</span> public ReturnCode filterCell(final Cell c) {<a name="line.72"></a> +<span class="sourceLineNo">073</span> this.count++;<a name="line.73"></a> +<span class="sourceLineNo">074</span> return filterAllRemaining() ? ReturnCode.NEXT_COL : ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.74"></a> +<span class="sourceLineNo">075</span> }<a name="line.75"></a> +<span class="sourceLineNo">076</span><a name="line.76"></a> +<span class="sourceLineNo">077</span> @Override<a name="line.77"></a> +<span class="sourceLineNo">078</span> public void reset() {<a name="line.78"></a> +<span class="sourceLineNo">079</span> this.count = 0;<a name="line.79"></a> +<span class="sourceLineNo">080</span> }<a name="line.80"></a> +<span class="sourceLineNo">081</span><a name="line.81"></a> +<span class="sourceLineNo">082</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.82"></a> +<span class="sourceLineNo">083</span> Preconditions.checkArgument(filterArguments.size() == 1,<a name="line.83"></a> +<span class="sourceLineNo">084</span> "Expected 1 but got: %s", filterArguments.size());<a name="line.84"></a> +<span class="sourceLineNo">085</span> int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));<a name="line.85"></a> +<span class="sourceLineNo">086</span> return new ColumnCountGetFilter(limit);<a name="line.86"></a> +<span class="sourceLineNo">087</span> }<a name="line.87"></a> +<span class="sourceLineNo">088</span><a name="line.88"></a> +<span class="sourceLineNo">089</span> /**<a name="line.89"></a> +<span class="sourceLineNo">090</span> * @return The filter serialized using pb<a name="line.90"></a> +<span class="sourceLineNo">091</span> */<a name="line.91"></a> +<span class="sourceLineNo">092</span> public byte [] toByteArray() {<a name="line.92"></a> +<span class="sourceLineNo">093</span> FilterProtos.ColumnCountGetFilter.Builder builder =<a name="line.93"></a> +<span class="sourceLineNo">094</span> FilterProtos.ColumnCountGetFilter.newBuilder();<a name="line.94"></a> +<span class="sourceLineNo">095</span> builder.setLimit(this.limit);<a name="line.95"></a> +<span class="sourceLineNo">096</span> return builder.build().toByteArray();<a name="line.96"></a> +<span class="sourceLineNo">097</span> }<a name="line.97"></a> +<span class="sourceLineNo">098</span><a name="line.98"></a> +<span class="sourceLineNo">099</span> /**<a name="line.99"></a> +<span class="sourceLineNo">100</span> * @param pbBytes A pb serialized {@link ColumnCountGetFilter} instance<a name="line.100"></a> +<span class="sourceLineNo">101</span> * @return An instance of {@link ColumnCountGetFilter} made from <code>bytes</code><a name="line.101"></a> +<span class="sourceLineNo">102</span> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException<a name="line.102"></a> +<span class="sourceLineNo">103</span> * @see #toByteArray<a name="line.103"></a> +<span class="sourceLineNo">104</span> */<a name="line.104"></a> +<span class="sourceLineNo">105</span> public static ColumnCountGetFilter parseFrom(final byte [] pbBytes)<a name="line.105"></a> +<span class="sourceLineNo">106</span> throws DeserializationException {<a name="line.106"></a> +<span class="sourceLineNo">107</span> FilterProtos.ColumnCountGetFilter proto;<a name="line.107"></a> +<span class="sourceLineNo">108</span> try {<a name="line.108"></a> +<span class="sourceLineNo">109</span> proto = FilterProtos.ColumnCountGetFilter.parseFrom(pbBytes);<a name="line.109"></a> +<span class="sourceLineNo">110</span> } catch (InvalidProtocolBufferException e) {<a name="line.110"></a> +<span class="sourceLineNo">111</span> throw new DeserializationException(e);<a name="line.111"></a> +<span class="sourceLineNo">112</span> }<a name="line.112"></a> +<span class="sourceLineNo">113</span> return new ColumnCountGetFilter(proto.getLimit());<a name="line.113"></a> +<span class="sourceLineNo">114</span> }<a name="line.114"></a> +<span class="sourceLineNo">115</span><a name="line.115"></a> +<span class="sourceLineNo">116</span> /**<a name="line.116"></a> +<span class="sourceLineNo">117</span> * @param o the other filter to compare with<a name="line.117"></a> +<span class="sourceLineNo">118</span> * @return true if and only if the fields of the filter that are serialized<a name="line.118"></a> +<span class="sourceLineNo">119</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.119"></a> +<span class="sourceLineNo">120</span> */<a name="line.120"></a> +<span class="sourceLineNo">121</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.121"></a> +<span class="sourceLineNo">122</span> if (o == this) return true;<a name="line.122"></a> +<span class="sourceLineNo">123</span> if (!(o instanceof ColumnCountGetFilter)) return false;<a name="line.123"></a> +<span class="sourceLineNo">124</span><a name="line.124"></a> +<span class="sourceLineNo">125</span> ColumnCountGetFilter other = (ColumnCountGetFilter)o;<a name="line.125"></a> +<span class="sourceLineNo">126</span> return this.getLimit() == other.getLimit();<a name="line.126"></a> +<span class="sourceLineNo">127</span> }<a name="line.127"></a> +<span class="sourceLineNo">128</span><a name="line.128"></a> +<span class="sourceLineNo">129</span> @Override<a name="line.129"></a> +<span class="sourceLineNo">130</span> public String toString() {<a name="line.130"></a> +<span class="sourceLineNo">131</span> return this.getClass().getSimpleName() + " " + this.limit;<a name="line.131"></a> +<span class="sourceLineNo">132</span> }<a name="line.132"></a> +<span class="sourceLineNo">133</span>}<a name="line.133"></a>
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/00c22388/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.html index a10d265..9aa2b91 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.html @@ -118,118 +118,124 @@ <span class="sourceLineNo">110</span> }<a name="line.110"></a> <span class="sourceLineNo">111</span><a name="line.111"></a> <span class="sourceLineNo">112</span> @Override<a name="line.112"></a> -<span class="sourceLineNo">113</span> public ReturnCode filterKeyValue(Cell v)<a name="line.113"></a> -<span class="sourceLineNo">114</span> {<a name="line.114"></a> -<span class="sourceLineNo">115</span> if (columnOffset != null) {<a name="line.115"></a> -<span class="sourceLineNo">116</span> if (count >= limit) {<a name="line.116"></a> -<span class="sourceLineNo">117</span> return ReturnCode.NEXT_ROW;<a name="line.117"></a> -<span class="sourceLineNo">118</span> }<a name="line.118"></a> -<span class="sourceLineNo">119</span> int cmp = 0;<a name="line.119"></a> -<span class="sourceLineNo">120</span> // Only compare if no KV's have been seen so far.<a name="line.120"></a> -<span class="sourceLineNo">121</span> if (count == 0) {<a name="line.121"></a> -<span class="sourceLineNo">122</span> cmp = CellUtil.compareQualifiers(v, this.columnOffset, 0, this.columnOffset.length);<a name="line.122"></a> -<span class="sourceLineNo">123</span> }<a name="line.123"></a> -<span class="sourceLineNo">124</span> if (cmp < 0) {<a name="line.124"></a> -<span class="sourceLineNo">125</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.125"></a> -<span class="sourceLineNo">126</span> } else {<a name="line.126"></a> -<span class="sourceLineNo">127</span> count++;<a name="line.127"></a> -<span class="sourceLineNo">128</span> return ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.128"></a> +<span class="sourceLineNo">113</span> @Deprecated<a name="line.113"></a> +<span class="sourceLineNo">114</span> public ReturnCode filterKeyValue(final Cell c) {<a name="line.114"></a> +<span class="sourceLineNo">115</span> return filterCell(c);<a name="line.115"></a> +<span class="sourceLineNo">116</span> }<a name="line.116"></a> +<span class="sourceLineNo">117</span><a name="line.117"></a> +<span class="sourceLineNo">118</span> @Override<a name="line.118"></a> +<span class="sourceLineNo">119</span> public ReturnCode filterCell(final Cell c)<a name="line.119"></a> +<span class="sourceLineNo">120</span> {<a name="line.120"></a> +<span class="sourceLineNo">121</span> if (columnOffset != null) {<a name="line.121"></a> +<span class="sourceLineNo">122</span> if (count >= limit) {<a name="line.122"></a> +<span class="sourceLineNo">123</span> return ReturnCode.NEXT_ROW;<a name="line.123"></a> +<span class="sourceLineNo">124</span> }<a name="line.124"></a> +<span class="sourceLineNo">125</span> int cmp = 0;<a name="line.125"></a> +<span class="sourceLineNo">126</span> // Only compare if no KV's have been seen so far.<a name="line.126"></a> +<span class="sourceLineNo">127</span> if (count == 0) {<a name="line.127"></a> +<span class="sourceLineNo">128</span> cmp = CellUtil.compareQualifiers(c, this.columnOffset, 0, this.columnOffset.length);<a name="line.128"></a> <span class="sourceLineNo">129</span> }<a name="line.129"></a> -<span class="sourceLineNo">130</span> } else {<a name="line.130"></a> -<span class="sourceLineNo">131</span> if (count >= offset + limit) {<a name="line.131"></a> -<span class="sourceLineNo">132</span> return ReturnCode.NEXT_ROW;<a name="line.132"></a> -<span class="sourceLineNo">133</span> }<a name="line.133"></a> -<span class="sourceLineNo">134</span><a name="line.134"></a> -<span class="sourceLineNo">135</span> ReturnCode code = count < offset ? ReturnCode.NEXT_COL :<a name="line.135"></a> -<span class="sourceLineNo">136</span> ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.136"></a> -<span class="sourceLineNo">137</span> count++;<a name="line.137"></a> -<span class="sourceLineNo">138</span> return code;<a name="line.138"></a> -<span class="sourceLineNo">139</span> }<a name="line.139"></a> -<span class="sourceLineNo">140</span> }<a name="line.140"></a> -<span class="sourceLineNo">141</span><a name="line.141"></a> -<span class="sourceLineNo">142</span> @Override<a name="line.142"></a> -<span class="sourceLineNo">143</span> public Cell getNextCellHint(Cell cell) {<a name="line.143"></a> -<span class="sourceLineNo">144</span> return CellUtil.createFirstOnRowCol(cell, columnOffset, 0, columnOffset.length);<a name="line.144"></a> -<span class="sourceLineNo">145</span> }<a name="line.145"></a> -<span class="sourceLineNo">146</span><a name="line.146"></a> -<span class="sourceLineNo">147</span> @Override<a name="line.147"></a> -<span class="sourceLineNo">148</span> public void reset()<a name="line.148"></a> -<span class="sourceLineNo">149</span> {<a name="line.149"></a> -<span class="sourceLineNo">150</span> this.count = 0;<a name="line.150"></a> +<span class="sourceLineNo">130</span> if (cmp < 0) {<a name="line.130"></a> +<span class="sourceLineNo">131</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.131"></a> +<span class="sourceLineNo">132</span> } else {<a name="line.132"></a> +<span class="sourceLineNo">133</span> count++;<a name="line.133"></a> +<span class="sourceLineNo">134</span> return ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.134"></a> +<span class="sourceLineNo">135</span> }<a name="line.135"></a> +<span class="sourceLineNo">136</span> } else {<a name="line.136"></a> +<span class="sourceLineNo">137</span> if (count >= offset + limit) {<a name="line.137"></a> +<span class="sourceLineNo">138</span> return ReturnCode.NEXT_ROW;<a name="line.138"></a> +<span class="sourceLineNo">139</span> }<a name="line.139"></a> +<span class="sourceLineNo">140</span><a name="line.140"></a> +<span class="sourceLineNo">141</span> ReturnCode code = count < offset ? ReturnCode.NEXT_COL :<a name="line.141"></a> +<span class="sourceLineNo">142</span> ReturnCode.INCLUDE_AND_NEXT_COL;<a name="line.142"></a> +<span class="sourceLineNo">143</span> count++;<a name="line.143"></a> +<span class="sourceLineNo">144</span> return code;<a name="line.144"></a> +<span class="sourceLineNo">145</span> }<a name="line.145"></a> +<span class="sourceLineNo">146</span> }<a name="line.146"></a> +<span class="sourceLineNo">147</span><a name="line.147"></a> +<span class="sourceLineNo">148</span> @Override<a name="line.148"></a> +<span class="sourceLineNo">149</span> public Cell getNextCellHint(Cell cell) {<a name="line.149"></a> +<span class="sourceLineNo">150</span> return CellUtil.createFirstOnRowCol(cell, columnOffset, 0, columnOffset.length);<a name="line.150"></a> <span class="sourceLineNo">151</span> }<a name="line.151"></a> <span class="sourceLineNo">152</span><a name="line.152"></a> -<span class="sourceLineNo">153</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.153"></a> -<span class="sourceLineNo">154</span> Preconditions.checkArgument(filterArguments.size() == 2,<a name="line.154"></a> -<span class="sourceLineNo">155</span> "Expected 2 but got: %s", filterArguments.size());<a name="line.155"></a> -<span class="sourceLineNo">156</span> int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));<a name="line.156"></a> -<span class="sourceLineNo">157</span> int offset = ParseFilter.convertByteArrayToInt(filterArguments.get(1));<a name="line.157"></a> -<span class="sourceLineNo">158</span> return new ColumnPaginationFilter(limit, offset);<a name="line.158"></a> -<span class="sourceLineNo">159</span> }<a name="line.159"></a> -<span class="sourceLineNo">160</span><a name="line.160"></a> -<span class="sourceLineNo">161</span> /**<a name="line.161"></a> -<span class="sourceLineNo">162</span> * @return The filter serialized using pb<a name="line.162"></a> -<span class="sourceLineNo">163</span> */<a name="line.163"></a> -<span class="sourceLineNo">164</span> public byte [] toByteArray() {<a name="line.164"></a> -<span class="sourceLineNo">165</span> FilterProtos.ColumnPaginationFilter.Builder builder =<a name="line.165"></a> -<span class="sourceLineNo">166</span> FilterProtos.ColumnPaginationFilter.newBuilder();<a name="line.166"></a> -<span class="sourceLineNo">167</span> builder.setLimit(this.limit);<a name="line.167"></a> -<span class="sourceLineNo">168</span> if (this.offset >= 0) {<a name="line.168"></a> -<span class="sourceLineNo">169</span> builder.setOffset(this.offset);<a name="line.169"></a> -<span class="sourceLineNo">170</span> }<a name="line.170"></a> -<span class="sourceLineNo">171</span> if (this.columnOffset != null) {<a name="line.171"></a> -<span class="sourceLineNo">172</span> builder.setColumnOffset(UnsafeByteOperations.unsafeWrap(this.columnOffset));<a name="line.172"></a> -<span class="sourceLineNo">173</span> }<a name="line.173"></a> -<span class="sourceLineNo">174</span> return builder.build().toByteArray();<a name="line.174"></a> -<span class="sourceLineNo">175</span> }<a name="line.175"></a> -<span class="sourceLineNo">176</span><a name="line.176"></a> -<span class="sourceLineNo">177</span> /**<a name="line.177"></a> -<span class="sourceLineNo">178</span> * @param pbBytes A pb serialized {@link ColumnPaginationFilter} instance<a name="line.178"></a> -<span class="sourceLineNo">179</span> * @return An instance of {@link ColumnPaginationFilter} made from <code>bytes</code><a name="line.179"></a> -<span class="sourceLineNo">180</span> * @throws DeserializationException<a name="line.180"></a> -<span class="sourceLineNo">181</span> * @see #toByteArray<a name="line.181"></a> -<span class="sourceLineNo">182</span> */<a name="line.182"></a> -<span class="sourceLineNo">183</span> public static ColumnPaginationFilter parseFrom(final byte [] pbBytes)<a name="line.183"></a> -<span class="sourceLineNo">184</span> throws DeserializationException {<a name="line.184"></a> -<span class="sourceLineNo">185</span> FilterProtos.ColumnPaginationFilter proto;<a name="line.185"></a> -<span class="sourceLineNo">186</span> try {<a name="line.186"></a> -<span class="sourceLineNo">187</span> proto = FilterProtos.ColumnPaginationFilter.parseFrom(pbBytes);<a name="line.187"></a> -<span class="sourceLineNo">188</span> } catch (InvalidProtocolBufferException e) {<a name="line.188"></a> -<span class="sourceLineNo">189</span> throw new DeserializationException(e);<a name="line.189"></a> -<span class="sourceLineNo">190</span> }<a name="line.190"></a> -<span class="sourceLineNo">191</span> if (proto.hasColumnOffset()) {<a name="line.191"></a> -<span class="sourceLineNo">192</span> return new ColumnPaginationFilter(proto.getLimit(),<a name="line.192"></a> -<span class="sourceLineNo">193</span> proto.getColumnOffset().toByteArray());<a name="line.193"></a> -<span class="sourceLineNo">194</span> }<a name="line.194"></a> -<span class="sourceLineNo">195</span> return new ColumnPaginationFilter(proto.getLimit(),proto.getOffset());<a name="line.195"></a> -<span class="sourceLineNo">196</span> }<a name="line.196"></a> -<span class="sourceLineNo">197</span><a name="line.197"></a> -<span class="sourceLineNo">198</span> /**<a name="line.198"></a> -<span class="sourceLineNo">199</span> * @param other<a name="line.199"></a> -<span class="sourceLineNo">200</span> * @return true if and only if the fields of the filter that are serialized<a name="line.200"></a> -<span class="sourceLineNo">201</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.201"></a> -<span class="sourceLineNo">202</span> */<a name="line.202"></a> -<span class="sourceLineNo">203</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.203"></a> -<span class="sourceLineNo">204</span> if (o == this) return true;<a name="line.204"></a> -<span class="sourceLineNo">205</span> if (!(o instanceof ColumnPaginationFilter)) return false;<a name="line.205"></a> -<span class="sourceLineNo">206</span><a name="line.206"></a> -<span class="sourceLineNo">207</span> ColumnPaginationFilter other = (ColumnPaginationFilter)o;<a name="line.207"></a> -<span class="sourceLineNo">208</span> if (this.columnOffset != null) {<a name="line.208"></a> -<span class="sourceLineNo">209</span> return this.getLimit() == other.getLimit() &&<a name="line.209"></a> -<span class="sourceLineNo">210</span> Bytes.equals(this.getColumnOffset(), other.getColumnOffset());<a name="line.210"></a> -<span class="sourceLineNo">211</span> }<a name="line.211"></a> -<span class="sourceLineNo">212</span> return this.getLimit() == other.getLimit() && this.getOffset() == other.getOffset();<a name="line.212"></a> -<span class="sourceLineNo">213</span> }<a name="line.213"></a> -<span class="sourceLineNo">214</span><a name="line.214"></a> -<span class="sourceLineNo">215</span> @Override<a name="line.215"></a> -<span class="sourceLineNo">216</span> public String toString() {<a name="line.216"></a> -<span class="sourceLineNo">217</span> if (this.columnOffset != null) {<a name="line.217"></a> -<span class="sourceLineNo">218</span> return (this.getClass().getSimpleName() + "(" + this.limit + ", " +<a name="line.218"></a> -<span class="sourceLineNo">219</span> Bytes.toStringBinary(this.columnOffset) + ")");<a name="line.219"></a> -<span class="sourceLineNo">220</span> }<a name="line.220"></a> -<span class="sourceLineNo">221</span> return String.format("%s (%d, %d)", this.getClass().getSimpleName(),<a name="line.221"></a> -<span class="sourceLineNo">222</span> this.limit, this.offset);<a name="line.222"></a> -<span class="sourceLineNo">223</span> }<a name="line.223"></a> -<span class="sourceLineNo">224</span>}<a name="line.224"></a> +<span class="sourceLineNo">153</span> @Override<a name="line.153"></a> +<span class="sourceLineNo">154</span> public void reset()<a name="line.154"></a> +<span class="sourceLineNo">155</span> {<a name="line.155"></a> +<span class="sourceLineNo">156</span> this.count = 0;<a name="line.156"></a> +<span class="sourceLineNo">157</span> }<a name="line.157"></a> +<span class="sourceLineNo">158</span><a name="line.158"></a> +<span class="sourceLineNo">159</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.159"></a> +<span class="sourceLineNo">160</span> Preconditions.checkArgument(filterArguments.size() == 2,<a name="line.160"></a> +<span class="sourceLineNo">161</span> "Expected 2 but got: %s", filterArguments.size());<a name="line.161"></a> +<span class="sourceLineNo">162</span> int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));<a name="line.162"></a> +<span class="sourceLineNo">163</span> int offset = ParseFilter.convertByteArrayToInt(filterArguments.get(1));<a name="line.163"></a> +<span class="sourceLineNo">164</span> return new ColumnPaginationFilter(limit, offset);<a name="line.164"></a> +<span class="sourceLineNo">165</span> }<a name="line.165"></a> +<span class="sourceLineNo">166</span><a name="line.166"></a> +<span class="sourceLineNo">167</span> /**<a name="line.167"></a> +<span class="sourceLineNo">168</span> * @return The filter serialized using pb<a name="line.168"></a> +<span class="sourceLineNo">169</span> */<a name="line.169"></a> +<span class="sourceLineNo">170</span> public byte [] toByteArray() {<a name="line.170"></a> +<span class="sourceLineNo">171</span> FilterProtos.ColumnPaginationFilter.Builder builder =<a name="line.171"></a> +<span class="sourceLineNo">172</span> FilterProtos.ColumnPaginationFilter.newBuilder();<a name="line.172"></a> +<span class="sourceLineNo">173</span> builder.setLimit(this.limit);<a name="line.173"></a> +<span class="sourceLineNo">174</span> if (this.offset >= 0) {<a name="line.174"></a> +<span class="sourceLineNo">175</span> builder.setOffset(this.offset);<a name="line.175"></a> +<span class="sourceLineNo">176</span> }<a name="line.176"></a> +<span class="sourceLineNo">177</span> if (this.columnOffset != null) {<a name="line.177"></a> +<span class="sourceLineNo">178</span> builder.setColumnOffset(UnsafeByteOperations.unsafeWrap(this.columnOffset));<a name="line.178"></a> +<span class="sourceLineNo">179</span> }<a name="line.179"></a> +<span class="sourceLineNo">180</span> return builder.build().toByteArray();<a name="line.180"></a> +<span class="sourceLineNo">181</span> }<a name="line.181"></a> +<span class="sourceLineNo">182</span><a name="line.182"></a> +<span class="sourceLineNo">183</span> /**<a name="line.183"></a> +<span class="sourceLineNo">184</span> * @param pbBytes A pb serialized {@link ColumnPaginationFilter} instance<a name="line.184"></a> +<span class="sourceLineNo">185</span> * @return An instance of {@link ColumnPaginationFilter} made from <code>bytes</code><a name="line.185"></a> +<span class="sourceLineNo">186</span> * @throws DeserializationException<a name="line.186"></a> +<span class="sourceLineNo">187</span> * @see #toByteArray<a name="line.187"></a> +<span class="sourceLineNo">188</span> */<a name="line.188"></a> +<span class="sourceLineNo">189</span> public static ColumnPaginationFilter parseFrom(final byte [] pbBytes)<a name="line.189"></a> +<span class="sourceLineNo">190</span> throws DeserializationException {<a name="line.190"></a> +<span class="sourceLineNo">191</span> FilterProtos.ColumnPaginationFilter proto;<a name="line.191"></a> +<span class="sourceLineNo">192</span> try {<a name="line.192"></a> +<span class="sourceLineNo">193</span> proto = FilterProtos.ColumnPaginationFilter.parseFrom(pbBytes);<a name="line.193"></a> +<span class="sourceLineNo">194</span> } catch (InvalidProtocolBufferException e) {<a name="line.194"></a> +<span class="sourceLineNo">195</span> throw new DeserializationException(e);<a name="line.195"></a> +<span class="sourceLineNo">196</span> }<a name="line.196"></a> +<span class="sourceLineNo">197</span> if (proto.hasColumnOffset()) {<a name="line.197"></a> +<span class="sourceLineNo">198</span> return new ColumnPaginationFilter(proto.getLimit(),<a name="line.198"></a> +<span class="sourceLineNo">199</span> proto.getColumnOffset().toByteArray());<a name="line.199"></a> +<span class="sourceLineNo">200</span> }<a name="line.200"></a> +<span class="sourceLineNo">201</span> return new ColumnPaginationFilter(proto.getLimit(),proto.getOffset());<a name="line.201"></a> +<span class="sourceLineNo">202</span> }<a name="line.202"></a> +<span class="sourceLineNo">203</span><a name="line.203"></a> +<span class="sourceLineNo">204</span> /**<a name="line.204"></a> +<span class="sourceLineNo">205</span> * @param o the other filter to compare with<a name="line.205"></a> +<span class="sourceLineNo">206</span> * @return true if and only if the fields of the filter that are serialized<a name="line.206"></a> +<span class="sourceLineNo">207</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.207"></a> +<span class="sourceLineNo">208</span> */<a name="line.208"></a> +<span class="sourceLineNo">209</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.209"></a> +<span class="sourceLineNo">210</span> if (o == this) return true;<a name="line.210"></a> +<span class="sourceLineNo">211</span> if (!(o instanceof ColumnPaginationFilter)) return false;<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> ColumnPaginationFilter other = (ColumnPaginationFilter)o;<a name="line.213"></a> +<span class="sourceLineNo">214</span> if (this.columnOffset != null) {<a name="line.214"></a> +<span class="sourceLineNo">215</span> return this.getLimit() == other.getLimit() &&<a name="line.215"></a> +<span class="sourceLineNo">216</span> Bytes.equals(this.getColumnOffset(), other.getColumnOffset());<a name="line.216"></a> +<span class="sourceLineNo">217</span> }<a name="line.217"></a> +<span class="sourceLineNo">218</span> return this.getLimit() == other.getLimit() && this.getOffset() == other.getOffset();<a name="line.218"></a> +<span class="sourceLineNo">219</span> }<a name="line.219"></a> +<span class="sourceLineNo">220</span><a name="line.220"></a> +<span class="sourceLineNo">221</span> @Override<a name="line.221"></a> +<span class="sourceLineNo">222</span> public String toString() {<a name="line.222"></a> +<span class="sourceLineNo">223</span> if (this.columnOffset != null) {<a name="line.223"></a> +<span class="sourceLineNo">224</span> return (this.getClass().getSimpleName() + "(" + this.limit + ", " +<a name="line.224"></a> +<span class="sourceLineNo">225</span> Bytes.toStringBinary(this.columnOffset) + ")");<a name="line.225"></a> +<span class="sourceLineNo">226</span> }<a name="line.226"></a> +<span class="sourceLineNo">227</span> return String.format("%s (%d, %d)", this.getClass().getSimpleName(),<a name="line.227"></a> +<span class="sourceLineNo">228</span> this.limit, this.offset);<a name="line.228"></a> +<span class="sourceLineNo">229</span> }<a name="line.229"></a> +<span class="sourceLineNo">230</span>}<a name="line.230"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/00c22388/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html index 9287cdb..8a6d034 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.html @@ -66,102 +66,108 @@ <span class="sourceLineNo">058</span> return false;<a name="line.58"></a> <span class="sourceLineNo">059</span> }<a name="line.59"></a> <span class="sourceLineNo">060</span><a name="line.60"></a> -<span class="sourceLineNo">061</span> @Override<a name="line.61"></a> -<span class="sourceLineNo">062</span> public ReturnCode filterKeyValue(Cell cell) {<a name="line.62"></a> -<span class="sourceLineNo">063</span> if (this.prefix == null) {<a name="line.63"></a> -<span class="sourceLineNo">064</span> return ReturnCode.INCLUDE;<a name="line.64"></a> -<span class="sourceLineNo">065</span> } else {<a name="line.65"></a> -<span class="sourceLineNo">066</span> return filterColumn(cell);<a name="line.66"></a> -<span class="sourceLineNo">067</span> }<a name="line.67"></a> -<span class="sourceLineNo">068</span> }<a name="line.68"></a> -<span class="sourceLineNo">069</span><a name="line.69"></a> -<span class="sourceLineNo">070</span> public ReturnCode filterColumn(Cell cell) {<a name="line.70"></a> -<span class="sourceLineNo">071</span> int qualifierLength = cell.getQualifierLength();<a name="line.71"></a> -<span class="sourceLineNo">072</span> if (qualifierLength < prefix.length) {<a name="line.72"></a> -<span class="sourceLineNo">073</span> int cmp = compareQualifierPart(cell, qualifierLength, this.prefix);<a name="line.73"></a> -<span class="sourceLineNo">074</span> if (cmp <= 0) {<a name="line.74"></a> -<span class="sourceLineNo">075</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.75"></a> -<span class="sourceLineNo">076</span> } else {<a name="line.76"></a> -<span class="sourceLineNo">077</span> return ReturnCode.NEXT_ROW;<a name="line.77"></a> -<span class="sourceLineNo">078</span> }<a name="line.78"></a> -<span class="sourceLineNo">079</span> } else {<a name="line.79"></a> -<span class="sourceLineNo">080</span> int cmp = compareQualifierPart(cell, this.prefix.length, this.prefix);<a name="line.80"></a> -<span class="sourceLineNo">081</span> if (cmp < 0) {<a name="line.81"></a> -<span class="sourceLineNo">082</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.82"></a> -<span class="sourceLineNo">083</span> } else if (cmp > 0) {<a name="line.83"></a> -<span class="sourceLineNo">084</span> return ReturnCode.NEXT_ROW;<a name="line.84"></a> -<span class="sourceLineNo">085</span> } else {<a name="line.85"></a> -<span class="sourceLineNo">086</span> return ReturnCode.INCLUDE;<a name="line.86"></a> -<span class="sourceLineNo">087</span> }<a name="line.87"></a> -<span class="sourceLineNo">088</span> }<a name="line.88"></a> -<span class="sourceLineNo">089</span> }<a name="line.89"></a> -<span class="sourceLineNo">090</span><a name="line.90"></a> -<span class="sourceLineNo">091</span> private static int compareQualifierPart(Cell cell, int length, byte[] prefix) {<a name="line.91"></a> -<span class="sourceLineNo">092</span> if (cell instanceof ByteBufferCell) {<a name="line.92"></a> -<span class="sourceLineNo">093</span> return ByteBufferUtils.compareTo(((ByteBufferCell) cell).getQualifierByteBuffer(),<a name="line.93"></a> -<span class="sourceLineNo">094</span> ((ByteBufferCell) cell).getQualifierPosition(), length, prefix, 0, length);<a name="line.94"></a> -<span class="sourceLineNo">095</span> }<a name="line.95"></a> -<span class="sourceLineNo">096</span> return Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), length, prefix, 0,<a name="line.96"></a> -<span class="sourceLineNo">097</span> length);<a name="line.97"></a> -<span class="sourceLineNo">098</span> }<a name="line.98"></a> -<span class="sourceLineNo">099</span><a name="line.99"></a> -<span class="sourceLineNo">100</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.100"></a> -<span class="sourceLineNo">101</span> Preconditions.checkArgument(filterArguments.size() == 1,<a name="line.101"></a> -<span class="sourceLineNo">102</span> "Expected 1 but got: %s", filterArguments.size());<a name="line.102"></a> -<span class="sourceLineNo">103</span> byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));<a name="line.103"></a> -<span class="sourceLineNo">104</span> return new ColumnPrefixFilter(columnPrefix);<a name="line.104"></a> -<span class="sourceLineNo">105</span> }<a name="line.105"></a> -<span class="sourceLineNo">106</span><a name="line.106"></a> -<span class="sourceLineNo">107</span> /**<a name="line.107"></a> -<span class="sourceLineNo">108</span> * @return The filter serialized using pb<a name="line.108"></a> -<span class="sourceLineNo">109</span> */<a name="line.109"></a> -<span class="sourceLineNo">110</span> public byte [] toByteArray() {<a name="line.110"></a> -<span class="sourceLineNo">111</span> FilterProtos.ColumnPrefixFilter.Builder builder =<a name="line.111"></a> -<span class="sourceLineNo">112</span> FilterProtos.ColumnPrefixFilter.newBuilder();<a name="line.112"></a> -<span class="sourceLineNo">113</span> if (this.prefix != null) builder.setPrefix(UnsafeByteOperations.unsafeWrap(this.prefix));<a name="line.113"></a> -<span class="sourceLineNo">114</span> return builder.build().toByteArray();<a name="line.114"></a> -<span class="sourceLineNo">115</span> }<a name="line.115"></a> -<span class="sourceLineNo">116</span><a name="line.116"></a> -<span class="sourceLineNo">117</span> /**<a name="line.117"></a> -<span class="sourceLineNo">118</span> * @param pbBytes A pb serialized {@link ColumnPrefixFilter} instance<a name="line.118"></a> -<span class="sourceLineNo">119</span> * @return An instance of {@link ColumnPrefixFilter} made from <code>bytes</code><a name="line.119"></a> -<span class="sourceLineNo">120</span> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException<a name="line.120"></a> -<span class="sourceLineNo">121</span> * @see #toByteArray<a name="line.121"></a> -<span class="sourceLineNo">122</span> */<a name="line.122"></a> -<span class="sourceLineNo">123</span> public static ColumnPrefixFilter parseFrom(final byte [] pbBytes)<a name="line.123"></a> -<span class="sourceLineNo">124</span> throws DeserializationException {<a name="line.124"></a> -<span class="sourceLineNo">125</span> FilterProtos.ColumnPrefixFilter proto;<a name="line.125"></a> -<span class="sourceLineNo">126</span> try {<a name="line.126"></a> -<span class="sourceLineNo">127</span> proto = FilterProtos.ColumnPrefixFilter.parseFrom(pbBytes);<a name="line.127"></a> -<span class="sourceLineNo">128</span> } catch (InvalidProtocolBufferException e) {<a name="line.128"></a> -<span class="sourceLineNo">129</span> throw new DeserializationException(e);<a name="line.129"></a> -<span class="sourceLineNo">130</span> }<a name="line.130"></a> -<span class="sourceLineNo">131</span> return new ColumnPrefixFilter(proto.getPrefix().toByteArray());<a name="line.131"></a> -<span class="sourceLineNo">132</span> }<a name="line.132"></a> -<span class="sourceLineNo">133</span><a name="line.133"></a> -<span class="sourceLineNo">134</span> /**<a name="line.134"></a> -<span class="sourceLineNo">135</span> * @param other<a name="line.135"></a> -<span class="sourceLineNo">136</span> * @return true if and only if the fields of the filter that are serialized<a name="line.136"></a> -<span class="sourceLineNo">137</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.137"></a> -<span class="sourceLineNo">138</span> */<a name="line.138"></a> -<span class="sourceLineNo">139</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.139"></a> -<span class="sourceLineNo">140</span> if (o == this) return true;<a name="line.140"></a> -<span class="sourceLineNo">141</span> if (!(o instanceof ColumnPrefixFilter)) return false;<a name="line.141"></a> -<span class="sourceLineNo">142</span><a name="line.142"></a> -<span class="sourceLineNo">143</span> ColumnPrefixFilter other = (ColumnPrefixFilter)o;<a name="line.143"></a> -<span class="sourceLineNo">144</span> return Bytes.equals(this.getPrefix(), other.getPrefix());<a name="line.144"></a> -<span class="sourceLineNo">145</span> }<a name="line.145"></a> -<span class="sourceLineNo">146</span><a name="line.146"></a> -<span class="sourceLineNo">147</span> @Override<a name="line.147"></a> -<span class="sourceLineNo">148</span> public Cell getNextCellHint(Cell cell) {<a name="line.148"></a> -<span class="sourceLineNo">149</span> return CellUtil.createFirstOnRowCol(cell, prefix, 0, prefix.length);<a name="line.149"></a> -<span class="sourceLineNo">150</span> }<a name="line.150"></a> -<span class="sourceLineNo">151</span><a name="line.151"></a> -<span class="sourceLineNo">152</span> @Override<a name="line.152"></a> -<span class="sourceLineNo">153</span> public String toString() {<a name="line.153"></a> -<span class="sourceLineNo">154</span> return this.getClass().getSimpleName() + " " + Bytes.toStringBinary(this.prefix);<a name="line.154"></a> -<span class="sourceLineNo">155</span> }<a name="line.155"></a> -<span class="sourceLineNo">156</span>}<a name="line.156"></a> +<span class="sourceLineNo">061</span> @Deprecated<a name="line.61"></a> +<span class="sourceLineNo">062</span> @Override<a name="line.62"></a> +<span class="sourceLineNo">063</span> public ReturnCode filterKeyValue(final Cell c) {<a name="line.63"></a> +<span class="sourceLineNo">064</span> return filterCell(c);<a name="line.64"></a> +<span class="sourceLineNo">065</span> }<a name="line.65"></a> +<span class="sourceLineNo">066</span><a name="line.66"></a> +<span class="sourceLineNo">067</span> @Override<a name="line.67"></a> +<span class="sourceLineNo">068</span> public ReturnCode filterCell(final Cell cell) {<a name="line.68"></a> +<span class="sourceLineNo">069</span> if (this.prefix == null) {<a name="line.69"></a> +<span class="sourceLineNo">070</span> return ReturnCode.INCLUDE;<a name="line.70"></a> +<span class="sourceLineNo">071</span> } else {<a name="line.71"></a> +<span class="sourceLineNo">072</span> return filterColumn(cell);<a name="line.72"></a> +<span class="sourceLineNo">073</span> }<a name="line.73"></a> +<span class="sourceLineNo">074</span> }<a name="line.74"></a> +<span class="sourceLineNo">075</span><a name="line.75"></a> +<span class="sourceLineNo">076</span> public ReturnCode filterColumn(Cell cell) {<a name="line.76"></a> +<span class="sourceLineNo">077</span> int qualifierLength = cell.getQualifierLength();<a name="line.77"></a> +<span class="sourceLineNo">078</span> if (qualifierLength < prefix.length) {<a name="line.78"></a> +<span class="sourceLineNo">079</span> int cmp = compareQualifierPart(cell, qualifierLength, this.prefix);<a name="line.79"></a> +<span class="sourceLineNo">080</span> if (cmp <= 0) {<a name="line.80"></a> +<span class="sourceLineNo">081</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.81"></a> +<span class="sourceLineNo">082</span> } else {<a name="line.82"></a> +<span class="sourceLineNo">083</span> return ReturnCode.NEXT_ROW;<a name="line.83"></a> +<span class="sourceLineNo">084</span> }<a name="line.84"></a> +<span class="sourceLineNo">085</span> } else {<a name="line.85"></a> +<span class="sourceLineNo">086</span> int cmp = compareQualifierPart(cell, this.prefix.length, this.prefix);<a name="line.86"></a> +<span class="sourceLineNo">087</span> if (cmp < 0) {<a name="line.87"></a> +<span class="sourceLineNo">088</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.88"></a> +<span class="sourceLineNo">089</span> } else if (cmp > 0) {<a name="line.89"></a> +<span class="sourceLineNo">090</span> return ReturnCode.NEXT_ROW;<a name="line.90"></a> +<span class="sourceLineNo">091</span> } else {<a name="line.91"></a> +<span class="sourceLineNo">092</span> return ReturnCode.INCLUDE;<a name="line.92"></a> +<span class="sourceLineNo">093</span> }<a name="line.93"></a> +<span class="sourceLineNo">094</span> }<a name="line.94"></a> +<span class="sourceLineNo">095</span> }<a name="line.95"></a> +<span class="sourceLineNo">096</span><a name="line.96"></a> +<span class="sourceLineNo">097</span> private static int compareQualifierPart(Cell cell, int length, byte[] prefix) {<a name="line.97"></a> +<span class="sourceLineNo">098</span> if (cell instanceof ByteBufferCell) {<a name="line.98"></a> +<span class="sourceLineNo">099</span> return ByteBufferUtils.compareTo(((ByteBufferCell) cell).getQualifierByteBuffer(),<a name="line.99"></a> +<span class="sourceLineNo">100</span> ((ByteBufferCell) cell).getQualifierPosition(), length, prefix, 0, length);<a name="line.100"></a> +<span class="sourceLineNo">101</span> }<a name="line.101"></a> +<span class="sourceLineNo">102</span> return Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), length, prefix, 0,<a name="line.102"></a> +<span class="sourceLineNo">103</span> length);<a name="line.103"></a> +<span class="sourceLineNo">104</span> }<a name="line.104"></a> +<span class="sourceLineNo">105</span><a name="line.105"></a> +<span class="sourceLineNo">106</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.106"></a> +<span class="sourceLineNo">107</span> Preconditions.checkArgument(filterArguments.size() == 1,<a name="line.107"></a> +<span class="sourceLineNo">108</span> "Expected 1 but got: %s", filterArguments.size());<a name="line.108"></a> +<span class="sourceLineNo">109</span> byte [] columnPrefix = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));<a name="line.109"></a> +<span class="sourceLineNo">110</span> return new ColumnPrefixFilter(columnPrefix);<a name="line.110"></a> +<span class="sourceLineNo">111</span> }<a name="line.111"></a> +<span class="sourceLineNo">112</span><a name="line.112"></a> +<span class="sourceLineNo">113</span> /**<a name="line.113"></a> +<span class="sourceLineNo">114</span> * @return The filter serialized using pb<a name="line.114"></a> +<span class="sourceLineNo">115</span> */<a name="line.115"></a> +<span class="sourceLineNo">116</span> public byte [] toByteArray() {<a name="line.116"></a> +<span class="sourceLineNo">117</span> FilterProtos.ColumnPrefixFilter.Builder builder =<a name="line.117"></a> +<span class="sourceLineNo">118</span> FilterProtos.ColumnPrefixFilter.newBuilder();<a name="line.118"></a> +<span class="sourceLineNo">119</span> if (this.prefix != null) builder.setPrefix(UnsafeByteOperations.unsafeWrap(this.prefix));<a name="line.119"></a> +<span class="sourceLineNo">120</span> return builder.build().toByteArray();<a name="line.120"></a> +<span class="sourceLineNo">121</span> }<a name="line.121"></a> +<span class="sourceLineNo">122</span><a name="line.122"></a> +<span class="sourceLineNo">123</span> /**<a name="line.123"></a> +<span class="sourceLineNo">124</span> * @param pbBytes A pb serialized {@link ColumnPrefixFilter} instance<a name="line.124"></a> +<span class="sourceLineNo">125</span> * @return An instance of {@link ColumnPrefixFilter} made from <code>bytes</code><a name="line.125"></a> +<span class="sourceLineNo">126</span> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException<a name="line.126"></a> +<span class="sourceLineNo">127</span> * @see #toByteArray<a name="line.127"></a> +<span class="sourceLineNo">128</span> */<a name="line.128"></a> +<span class="sourceLineNo">129</span> public static ColumnPrefixFilter parseFrom(final byte [] pbBytes)<a name="line.129"></a> +<span class="sourceLineNo">130</span> throws DeserializationException {<a name="line.130"></a> +<span class="sourceLineNo">131</span> FilterProtos.ColumnPrefixFilter proto;<a name="line.131"></a> +<span class="sourceLineNo">132</span> try {<a name="line.132"></a> +<span class="sourceLineNo">133</span> proto = FilterProtos.ColumnPrefixFilter.parseFrom(pbBytes);<a name="line.133"></a> +<span class="sourceLineNo">134</span> } catch (InvalidProtocolBufferException e) {<a name="line.134"></a> +<span class="sourceLineNo">135</span> throw new DeserializationException(e);<a name="line.135"></a> +<span class="sourceLineNo">136</span> }<a name="line.136"></a> +<span class="sourceLineNo">137</span> return new ColumnPrefixFilter(proto.getPrefix().toByteArray());<a name="line.137"></a> +<span class="sourceLineNo">138</span> }<a name="line.138"></a> +<span class="sourceLineNo">139</span><a name="line.139"></a> +<span class="sourceLineNo">140</span> /**<a name="line.140"></a> +<span class="sourceLineNo">141</span> * @param o the other filter to compare with<a name="line.141"></a> +<span class="sourceLineNo">142</span> * @return true if and only if the fields of the filter that are serialized<a name="line.142"></a> +<span class="sourceLineNo">143</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.143"></a> +<span class="sourceLineNo">144</span> */<a name="line.144"></a> +<span class="sourceLineNo">145</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.145"></a> +<span class="sourceLineNo">146</span> if (o == this) return true;<a name="line.146"></a> +<span class="sourceLineNo">147</span> if (!(o instanceof ColumnPrefixFilter)) return false;<a name="line.147"></a> +<span class="sourceLineNo">148</span><a name="line.148"></a> +<span class="sourceLineNo">149</span> ColumnPrefixFilter other = (ColumnPrefixFilter)o;<a name="line.149"></a> +<span class="sourceLineNo">150</span> return Bytes.equals(this.getPrefix(), other.getPrefix());<a name="line.150"></a> +<span class="sourceLineNo">151</span> }<a name="line.151"></a> +<span class="sourceLineNo">152</span><a name="line.152"></a> +<span class="sourceLineNo">153</span> @Override<a name="line.153"></a> +<span class="sourceLineNo">154</span> public Cell getNextCellHint(Cell cell) {<a name="line.154"></a> +<span class="sourceLineNo">155</span> return CellUtil.createFirstOnRowCol(cell, prefix, 0, prefix.length);<a name="line.155"></a> +<span class="sourceLineNo">156</span> }<a name="line.156"></a> +<span class="sourceLineNo">157</span><a name="line.157"></a> +<span class="sourceLineNo">158</span> @Override<a name="line.158"></a> +<span class="sourceLineNo">159</span> public String toString() {<a name="line.159"></a> +<span class="sourceLineNo">160</span> return this.getClass().getSimpleName() + " " + Bytes.toStringBinary(this.prefix);<a name="line.160"></a> +<span class="sourceLineNo">161</span> }<a name="line.161"></a> +<span class="sourceLineNo">162</span>}<a name="line.162"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/00c22388/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnRangeFilter.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnRangeFilter.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnRangeFilter.html index 08ef551..ece4303 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnRangeFilter.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/ColumnRangeFilter.html @@ -129,114 +129,120 @@ <span class="sourceLineNo">121</span> }<a name="line.121"></a> <span class="sourceLineNo">122</span><a name="line.122"></a> <span class="sourceLineNo">123</span> @Override<a name="line.123"></a> -<span class="sourceLineNo">124</span> public ReturnCode filterKeyValue(Cell kv) {<a name="line.124"></a> -<span class="sourceLineNo">125</span> int cmpMin = 1;<a name="line.125"></a> -<span class="sourceLineNo">126</span><a name="line.126"></a> -<span class="sourceLineNo">127</span> if (this.minColumn != null) {<a name="line.127"></a> -<span class="sourceLineNo">128</span> cmpMin = CellUtil.compareQualifiers(kv, this.minColumn, 0, this.minColumn.length);<a name="line.128"></a> -<span class="sourceLineNo">129</span> }<a name="line.129"></a> -<span class="sourceLineNo">130</span><a name="line.130"></a> -<span class="sourceLineNo">131</span> if (cmpMin < 0) {<a name="line.131"></a> -<span class="sourceLineNo">132</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.132"></a> -<span class="sourceLineNo">133</span> }<a name="line.133"></a> -<span class="sourceLineNo">134</span><a name="line.134"></a> -<span class="sourceLineNo">135</span> if (!this.minColumnInclusive && cmpMin == 0) {<a name="line.135"></a> -<span class="sourceLineNo">136</span> return ReturnCode.NEXT_COL;<a name="line.136"></a> -<span class="sourceLineNo">137</span> }<a name="line.137"></a> -<span class="sourceLineNo">138</span><a name="line.138"></a> -<span class="sourceLineNo">139</span> if (this.maxColumn == null) {<a name="line.139"></a> -<span class="sourceLineNo">140</span> return ReturnCode.INCLUDE;<a name="line.140"></a> -<span class="sourceLineNo">141</span> }<a name="line.141"></a> -<span class="sourceLineNo">142</span><a name="line.142"></a> -<span class="sourceLineNo">143</span> int cmpMax = CellUtil.compareQualifiers(kv, this.maxColumn, 0, this.maxColumn.length);<a name="line.143"></a> +<span class="sourceLineNo">124</span> @Deprecated<a name="line.124"></a> +<span class="sourceLineNo">125</span> public ReturnCode filterKeyValue(final Cell c) {<a name="line.125"></a> +<span class="sourceLineNo">126</span> return filterCell(c);<a name="line.126"></a> +<span class="sourceLineNo">127</span> }<a name="line.127"></a> +<span class="sourceLineNo">128</span><a name="line.128"></a> +<span class="sourceLineNo">129</span> @Override<a name="line.129"></a> +<span class="sourceLineNo">130</span> public ReturnCode filterCell(final Cell c) {<a name="line.130"></a> +<span class="sourceLineNo">131</span> int cmpMin = 1;<a name="line.131"></a> +<span class="sourceLineNo">132</span><a name="line.132"></a> +<span class="sourceLineNo">133</span> if (this.minColumn != null) {<a name="line.133"></a> +<span class="sourceLineNo">134</span> cmpMin = CellUtil.compareQualifiers(c, this.minColumn, 0, this.minColumn.length);<a name="line.134"></a> +<span class="sourceLineNo">135</span> }<a name="line.135"></a> +<span class="sourceLineNo">136</span><a name="line.136"></a> +<span class="sourceLineNo">137</span> if (cmpMin < 0) {<a name="line.137"></a> +<span class="sourceLineNo">138</span> return ReturnCode.SEEK_NEXT_USING_HINT;<a name="line.138"></a> +<span class="sourceLineNo">139</span> }<a name="line.139"></a> +<span class="sourceLineNo">140</span><a name="line.140"></a> +<span class="sourceLineNo">141</span> if (!this.minColumnInclusive && cmpMin == 0) {<a name="line.141"></a> +<span class="sourceLineNo">142</span> return ReturnCode.NEXT_COL;<a name="line.142"></a> +<span class="sourceLineNo">143</span> }<a name="line.143"></a> <span class="sourceLineNo">144</span><a name="line.144"></a> -<span class="sourceLineNo">145</span> if (this.maxColumnInclusive && cmpMax <= 0 ||<a name="line.145"></a> -<span class="sourceLineNo">146</span> !this.maxColumnInclusive && cmpMax < 0) {<a name="line.146"></a> -<span class="sourceLineNo">147</span> return ReturnCode.INCLUDE;<a name="line.147"></a> -<span class="sourceLineNo">148</span> }<a name="line.148"></a> -<span class="sourceLineNo">149</span><a name="line.149"></a> -<span class="sourceLineNo">150</span> return ReturnCode.NEXT_ROW;<a name="line.150"></a> -<span class="sourceLineNo">151</span> }<a name="line.151"></a> -<span class="sourceLineNo">152</span><a name="line.152"></a> -<span class="sourceLineNo">153</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.153"></a> -<span class="sourceLineNo">154</span> Preconditions.checkArgument(filterArguments.size() == 4,<a name="line.154"></a> -<span class="sourceLineNo">155</span> "Expected 4 but got: %s", filterArguments.size());<a name="line.155"></a> -<span class="sourceLineNo">156</span> byte [] minColumn = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));<a name="line.156"></a> -<span class="sourceLineNo">157</span> boolean minColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(1));<a name="line.157"></a> -<span class="sourceLineNo">158</span> byte [] maxColumn = ParseFilter.removeQuotesFromByteArray(filterArguments.get(2));<a name="line.158"></a> -<span class="sourceLineNo">159</span> boolean maxColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(3));<a name="line.159"></a> -<span class="sourceLineNo">160</span><a name="line.160"></a> -<span class="sourceLineNo">161</span> if (minColumn.length == 0)<a name="line.161"></a> -<span class="sourceLineNo">162</span> minColumn = null;<a name="line.162"></a> -<span class="sourceLineNo">163</span> if (maxColumn.length == 0)<a name="line.163"></a> -<span class="sourceLineNo">164</span> maxColumn = null;<a name="line.164"></a> -<span class="sourceLineNo">165</span> return new ColumnRangeFilter(minColumn, minColumnInclusive,<a name="line.165"></a> -<span class="sourceLineNo">166</span> maxColumn, maxColumnInclusive);<a name="line.166"></a> -<span class="sourceLineNo">167</span> }<a name="line.167"></a> -<span class="sourceLineNo">168</span><a name="line.168"></a> -<span class="sourceLineNo">169</span> /**<a name="line.169"></a> -<span class="sourceLineNo">170</span> * @return The filter serialized using pb<a name="line.170"></a> -<span class="sourceLineNo">171</span> */<a name="line.171"></a> -<span class="sourceLineNo">172</span> public byte [] toByteArray() {<a name="line.172"></a> -<span class="sourceLineNo">173</span> FilterProtos.ColumnRangeFilter.Builder builder =<a name="line.173"></a> -<span class="sourceLineNo">174</span> FilterProtos.ColumnRangeFilter.newBuilder();<a name="line.174"></a> -<span class="sourceLineNo">175</span> if (this.minColumn != null) builder.setMinColumn(<a name="line.175"></a> -<span class="sourceLineNo">176</span> UnsafeByteOperations.unsafeWrap(this.minColumn));<a name="line.176"></a> -<span class="sourceLineNo">177</span> builder.setMinColumnInclusive(this.minColumnInclusive);<a name="line.177"></a> -<span class="sourceLineNo">178</span> if (this.maxColumn != null) builder.setMaxColumn(<a name="line.178"></a> -<span class="sourceLineNo">179</span> UnsafeByteOperations.unsafeWrap(this.maxColumn));<a name="line.179"></a> -<span class="sourceLineNo">180</span> builder.setMaxColumnInclusive(this.maxColumnInclusive);<a name="line.180"></a> -<span class="sourceLineNo">181</span> return builder.build().toByteArray();<a name="line.181"></a> -<span class="sourceLineNo">182</span> }<a name="line.182"></a> -<span class="sourceLineNo">183</span><a name="line.183"></a> -<span class="sourceLineNo">184</span> /**<a name="line.184"></a> -<span class="sourceLineNo">185</span> * @param pbBytes A pb serialized {@link ColumnRangeFilter} instance<a name="line.185"></a> -<span class="sourceLineNo">186</span> * @return An instance of {@link ColumnRangeFilter} made from <code>bytes</code><a name="line.186"></a> -<span class="sourceLineNo">187</span> * @throws DeserializationException<a name="line.187"></a> -<span class="sourceLineNo">188</span> * @see #toByteArray<a name="line.188"></a> -<span class="sourceLineNo">189</span> */<a name="line.189"></a> -<span class="sourceLineNo">190</span> public static ColumnRangeFilter parseFrom(final byte [] pbBytes)<a name="line.190"></a> -<span class="sourceLineNo">191</span> throws DeserializationException {<a name="line.191"></a> -<span class="sourceLineNo">192</span> FilterProtos.ColumnRangeFilter proto;<a name="line.192"></a> -<span class="sourceLineNo">193</span> try {<a name="line.193"></a> -<span class="sourceLineNo">194</span> proto = FilterProtos.ColumnRangeFilter.parseFrom(pbBytes);<a name="line.194"></a> -<span class="sourceLineNo">195</span> } catch (InvalidProtocolBufferException e) {<a name="line.195"></a> -<span class="sourceLineNo">196</span> throw new DeserializationException(e);<a name="line.196"></a> -<span class="sourceLineNo">197</span> }<a name="line.197"></a> -<span class="sourceLineNo">198</span> return new ColumnRangeFilter(proto.hasMinColumn()?proto.getMinColumn().toByteArray():null,<a name="line.198"></a> -<span class="sourceLineNo">199</span> proto.getMinColumnInclusive(),proto.hasMaxColumn()?proto.getMaxColumn().toByteArray():null,<a name="line.199"></a> -<span class="sourceLineNo">200</span> proto.getMaxColumnInclusive());<a name="line.200"></a> -<span class="sourceLineNo">201</span> }<a name="line.201"></a> -<span class="sourceLineNo">202</span><a name="line.202"></a> -<span class="sourceLineNo">203</span> /**<a name="line.203"></a> -<span class="sourceLineNo">204</span> * @param other<a name="line.204"></a> -<span class="sourceLineNo">205</span> * @return true if and only if the fields of the filter that are serialized<a name="line.205"></a> -<span class="sourceLineNo">206</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.206"></a> -<span class="sourceLineNo">207</span> */<a name="line.207"></a> -<span class="sourceLineNo">208</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.208"></a> -<span class="sourceLineNo">209</span> if (o == this) return true;<a name="line.209"></a> -<span class="sourceLineNo">210</span> if (!(o instanceof ColumnRangeFilter)) return false;<a name="line.210"></a> -<span class="sourceLineNo">211</span><a name="line.211"></a> -<span class="sourceLineNo">212</span> ColumnRangeFilter other = (ColumnRangeFilter)o;<a name="line.212"></a> -<span class="sourceLineNo">213</span> return Bytes.equals(this.getMinColumn(),other.getMinColumn())<a name="line.213"></a> -<span class="sourceLineNo">214</span> && this.getMinColumnInclusive() == other.getMinColumnInclusive()<a name="line.214"></a> -<span class="sourceLineNo">215</span> && Bytes.equals(this.getMaxColumn(), other.getMaxColumn())<a name="line.215"></a> -<span class="sourceLineNo">216</span> && this.getMaxColumnInclusive() == other.getMaxColumnInclusive();<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span><a name="line.218"></a> -<span class="sourceLineNo">219</span> @Override<a name="line.219"></a> -<span class="sourceLineNo">220</span> public Cell getNextCellHint(Cell cell) {<a name="line.220"></a> -<span class="sourceLineNo">221</span> return CellUtil.createFirstOnRowCol(cell, this.minColumn, 0, len(this.minColumn));<a name="line.221"></a> -<span class="sourceLineNo">222</span> }<a name="line.222"></a> -<span class="sourceLineNo">223</span><a name="line.223"></a> -<span class="sourceLineNo">224</span> @Override<a name="line.224"></a> -<span class="sourceLineNo">225</span> public String toString() {<a name="line.225"></a> -<span class="sourceLineNo">226</span> return this.getClass().getSimpleName() + " "<a name="line.226"></a> -<span class="sourceLineNo">227</span> + (this.minColumnInclusive ? "[" : "(") + Bytes.toStringBinary(this.minColumn)<a name="line.227"></a> -<span class="sourceLineNo">228</span> + ", " + Bytes.toStringBinary(this.maxColumn)<a name="line.228"></a> -<span class="sourceLineNo">229</span> + (this.maxColumnInclusive ? "]" : ")");<a name="line.229"></a> -<span class="sourceLineNo">230</span> }<a name="line.230"></a> -<span class="sourceLineNo">231</span>}<a name="line.231"></a> +<span class="sourceLineNo">145</span> if (this.maxColumn == null) {<a name="line.145"></a> +<span class="sourceLineNo">146</span> return ReturnCode.INCLUDE;<a name="line.146"></a> +<span class="sourceLineNo">147</span> }<a name="line.147"></a> +<span class="sourceLineNo">148</span><a name="line.148"></a> +<span class="sourceLineNo">149</span> int cmpMax = CellUtil.compareQualifiers(c, this.maxColumn, 0, this.maxColumn.length);<a name="line.149"></a> +<span class="sourceLineNo">150</span><a name="line.150"></a> +<span class="sourceLineNo">151</span> if (this.maxColumnInclusive && cmpMax <= 0 ||<a name="line.151"></a> +<span class="sourceLineNo">152</span> !this.maxColumnInclusive && cmpMax < 0) {<a name="line.152"></a> +<span class="sourceLineNo">153</span> return ReturnCode.INCLUDE;<a name="line.153"></a> +<span class="sourceLineNo">154</span> }<a name="line.154"></a> +<span class="sourceLineNo">155</span><a name="line.155"></a> +<span class="sourceLineNo">156</span> return ReturnCode.NEXT_ROW;<a name="line.156"></a> +<span class="sourceLineNo">157</span> }<a name="line.157"></a> +<span class="sourceLineNo">158</span><a name="line.158"></a> +<span class="sourceLineNo">159</span> public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {<a name="line.159"></a> +<span class="sourceLineNo">160</span> Preconditions.checkArgument(filterArguments.size() == 4,<a name="line.160"></a> +<span class="sourceLineNo">161</span> "Expected 4 but got: %s", filterArguments.size());<a name="line.161"></a> +<span class="sourceLineNo">162</span> byte [] minColumn = ParseFilter.removeQuotesFromByteArray(filterArguments.get(0));<a name="line.162"></a> +<span class="sourceLineNo">163</span> boolean minColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(1));<a name="line.163"></a> +<span class="sourceLineNo">164</span> byte [] maxColumn = ParseFilter.removeQuotesFromByteArray(filterArguments.get(2));<a name="line.164"></a> +<span class="sourceLineNo">165</span> boolean maxColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(3));<a name="line.165"></a> +<span class="sourceLineNo">166</span><a name="line.166"></a> +<span class="sourceLineNo">167</span> if (minColumn.length == 0)<a name="line.167"></a> +<span class="sourceLineNo">168</span> minColumn = null;<a name="line.168"></a> +<span class="sourceLineNo">169</span> if (maxColumn.length == 0)<a name="line.169"></a> +<span class="sourceLineNo">170</span> maxColumn = null;<a name="line.170"></a> +<span class="sourceLineNo">171</span> return new ColumnRangeFilter(minColumn, minColumnInclusive,<a name="line.171"></a> +<span class="sourceLineNo">172</span> maxColumn, maxColumnInclusive);<a name="line.172"></a> +<span class="sourceLineNo">173</span> }<a name="line.173"></a> +<span class="sourceLineNo">174</span><a name="line.174"></a> +<span class="sourceLineNo">175</span> /**<a name="line.175"></a> +<span class="sourceLineNo">176</span> * @return The filter serialized using pb<a name="line.176"></a> +<span class="sourceLineNo">177</span> */<a name="line.177"></a> +<span class="sourceLineNo">178</span> public byte [] toByteArray() {<a name="line.178"></a> +<span class="sourceLineNo">179</span> FilterProtos.ColumnRangeFilter.Builder builder =<a name="line.179"></a> +<span class="sourceLineNo">180</span> FilterProtos.ColumnRangeFilter.newBuilder();<a name="line.180"></a> +<span class="sourceLineNo">181</span> if (this.minColumn != null) builder.setMinColumn(<a name="line.181"></a> +<span class="sourceLineNo">182</span> UnsafeByteOperations.unsafeWrap(this.minColumn));<a name="line.182"></a> +<span class="sourceLineNo">183</span> builder.setMinColumnInclusive(this.minColumnInclusive);<a name="line.183"></a> +<span class="sourceLineNo">184</span> if (this.maxColumn != null) builder.setMaxColumn(<a name="line.184"></a> +<span class="sourceLineNo">185</span> UnsafeByteOperations.unsafeWrap(this.maxColumn));<a name="line.185"></a> +<span class="sourceLineNo">186</span> builder.setMaxColumnInclusive(this.maxColumnInclusive);<a name="line.186"></a> +<span class="sourceLineNo">187</span> return builder.build().toByteArray();<a name="line.187"></a> +<span class="sourceLineNo">188</span> }<a name="line.188"></a> +<span class="sourceLineNo">189</span><a name="line.189"></a> +<span class="sourceLineNo">190</span> /**<a name="line.190"></a> +<span class="sourceLineNo">191</span> * @param pbBytes A pb serialized {@link ColumnRangeFilter} instance<a name="line.191"></a> +<span class="sourceLineNo">192</span> * @return An instance of {@link ColumnRangeFilter} made from <code>bytes</code><a name="line.192"></a> +<span class="sourceLineNo">193</span> * @throws DeserializationException<a name="line.193"></a> +<span class="sourceLineNo">194</span> * @see #toByteArray<a name="line.194"></a> +<span class="sourceLineNo">195</span> */<a name="line.195"></a> +<span class="sourceLineNo">196</span> public static ColumnRangeFilter parseFrom(final byte [] pbBytes)<a name="line.196"></a> +<span class="sourceLineNo">197</span> throws DeserializationException {<a name="line.197"></a> +<span class="sourceLineNo">198</span> FilterProtos.ColumnRangeFilter proto;<a name="line.198"></a> +<span class="sourceLineNo">199</span> try {<a name="line.199"></a> +<span class="sourceLineNo">200</span> proto = FilterProtos.ColumnRangeFilter.parseFrom(pbBytes);<a name="line.200"></a> +<span class="sourceLineNo">201</span> } catch (InvalidProtocolBufferException e) {<a name="line.201"></a> +<span class="sourceLineNo">202</span> throw new DeserializationException(e);<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span> return new ColumnRangeFilter(proto.hasMinColumn()?proto.getMinColumn().toByteArray():null,<a name="line.204"></a> +<span class="sourceLineNo">205</span> proto.getMinColumnInclusive(),proto.hasMaxColumn()?proto.getMaxColumn().toByteArray():null,<a name="line.205"></a> +<span class="sourceLineNo">206</span> proto.getMaxColumnInclusive());<a name="line.206"></a> +<span class="sourceLineNo">207</span> }<a name="line.207"></a> +<span class="sourceLineNo">208</span><a name="line.208"></a> +<span class="sourceLineNo">209</span> /**<a name="line.209"></a> +<span class="sourceLineNo">210</span> * @param other<a name="line.210"></a> +<span class="sourceLineNo">211</span> * @return true if and only if the fields of the filter that are serialized<a name="line.211"></a> +<span class="sourceLineNo">212</span> * are equal to the corresponding fields in other. Used for testing.<a name="line.212"></a> +<span class="sourceLineNo">213</span> */<a name="line.213"></a> +<span class="sourceLineNo">214</span> boolean areSerializedFieldsEqual(Filter o) {<a name="line.214"></a> +<span class="sourceLineNo">215</span> if (o == this) return true;<a name="line.215"></a> +<span class="sourceLineNo">216</span> if (!(o instanceof ColumnRangeFilter)) return false;<a name="line.216"></a> +<span class="sourceLineNo">217</span><a name="line.217"></a> +<span class="sourceLineNo">218</span> ColumnRangeFilter other = (ColumnRangeFilter)o;<a name="line.218"></a> +<span class="sourceLineNo">219</span> return Bytes.equals(this.getMinColumn(),other.getMinColumn())<a name="line.219"></a> +<span class="sourceLineNo">220</span> && this.getMinColumnInclusive() == other.getMinColumnInclusive()<a name="line.220"></a> +<span class="sourceLineNo">221</span> && Bytes.equals(this.getMaxColumn(), other.getMaxColumn())<a name="line.221"></a> +<span class="sourceLineNo">222</span> && this.getMaxColumnInclusive() == other.getMaxColumnInclusive();<a name="line.222"></a> +<span class="sourceLineNo">223</span> }<a name="line.223"></a> +<span class="sourceLineNo">224</span><a name="line.224"></a> +<span class="sourceLineNo">225</span> @Override<a name="line.225"></a> +<span class="sourceLineNo">226</span> public Cell getNextCellHint(Cell cell) {<a name="line.226"></a> +<span class="sourceLineNo">227</span> return CellUtil.createFirstOnRowCol(cell, this.minColumn, 0, len(this.minColumn));<a name="line.227"></a> +<span class="sourceLineNo">228</span> }<a name="line.228"></a> +<span class="sourceLineNo">229</span><a name="line.229"></a> +<span class="sourceLineNo">230</span> @Override<a name="line.230"></a> +<span class="sourceLineNo">231</span> public String toString() {<a name="line.231"></a> +<span class="sourceLineNo">232</span> return this.getClass().getSimpleName() + " "<a name="line.232"></a> +<span class="sourceLineNo">233</span> + (this.minColumnInclusive ? "[" : "(") + Bytes.toStringBinary(this.minColumn)<a name="line.233"></a> +<span class="sourceLineNo">234</span> + ", " + Bytes.toStringBinary(this.maxColumn)<a name="line.234"></a> +<span class="sourceLineNo">235</span> + (this.maxColumnInclusive ? "]" : ")");<a name="line.235"></a> +<span class="sourceLineNo">236</span> }<a name="line.236"></a> +<span class="sourceLineNo">237</span>}<a name="line.237"></a>