From commits-return-69245-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Thu Mar 8 15:54:20 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4F03A1807A1 for ; Thu, 8 Mar 2018 15:54:19 +0100 (CET) Received: (qmail 52474 invoked by uid 500); 8 Mar 2018 14:53:58 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 52255 invoked by uid 99); 8 Mar 2018 14:53:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2018 14:53:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 14066F6507; Thu, 8 Mar 2018 14:53:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Thu, 08 Mar 2018 14:54:15 -0000 Message-Id: <0c0963020f494212aeac8f7eee703f6d@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [21/25] hbase-site git commit: Published site at a03d09abd72789bbf9364d8a9b2c54d0e9351af9. http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e9a81b89/apidocs/src-html/org/apache/hadoop/hbase/filter/RegexStringComparator.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/RegexStringComparator.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/RegexStringComparator.html index ce6ff26..577439c 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/RegexStringComparator.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/RegexStringComparator.html @@ -77,353 +77,354 @@ 069 * @see java.util.regex.Pattern 070 */ 071@InterfaceAudience.Public -072public class RegexStringComparator extends ByteArrayComparable { -073 -074 private static final Logger LOG = LoggerFactory.getLogger(RegexStringComparator.class); -075 -076 private Engine engine; -077 -078 /** Engine implementation type (default=JAVA) */ -079 @InterfaceAudience.Public -080 public enum EngineType { -081 JAVA, -082 JONI -083 } -084 -085 /** -086 * Constructor -087 * Adds Pattern.DOTALL to the underlying Pattern -088 * @param expr a valid regular expression -089 */ -090 public RegexStringComparator(String expr) { -091 this(expr, Pattern.DOTALL); -092 } -093 -094 /** -095 * Constructor -096 * Adds Pattern.DOTALL to the underlying Pattern -097 * @param expr a valid regular expression -098 * @param engine engine implementation type -099 */ -100 public RegexStringComparator(String expr, EngineType engine) { -101 this(expr, Pattern.DOTALL, engine); -102 } -103 -104 /** -105 * Constructor -106 * @param expr a valid regular expression -107 * @param flags java.util.regex.Pattern flags -108 */ -109 public RegexStringComparator(String expr, int flags) { -110 this(expr, flags, EngineType.JAVA); -111 } -112 -113 /** -114 * Constructor -115 * @param expr a valid regular expression -116 * @param flags java.util.regex.Pattern flags -117 * @param engine engine implementation type -118 */ -119 public RegexStringComparator(String expr, int flags, EngineType engine) { -120 super(Bytes.toBytes(expr)); -121 switch (engine) { -122 case JAVA: -123 this.engine = new JavaRegexEngine(expr, flags); -124 break; -125 case JONI: -126 this.engine = new JoniRegexEngine(expr, flags); -127 break; -128 } -129 } -130 -131 /** -132 * Specifies the {@link Charset} to use to convert the row key to a String. -133 * <p> -134 * The row key needs to be converted to a String in order to be matched -135 * against the regular expression. This method controls which charset is -136 * used to do this conversion. -137 * <p> -138 * If the row key is made of arbitrary bytes, the charset {@code ISO-8859-1} -139 * is recommended. -140 * @param charset The charset to use. -141 */ -142 public void setCharset(final Charset charset) { -143 engine.setCharset(charset.name()); -144 } -145 -146 @Override -147 public int compareTo(byte[] value, int offset, int length) { -148 return engine.compareTo(value, offset, length); -149 } -150 -151 /** -152 * @return The comparator serialized using pb -153 */ -154 @Override -155 public byte [] toByteArray() { -156 return engine.toByteArray(); -157 } -158 -159 /** -160 * @param pbBytes A pb serialized {@link RegexStringComparator} instance -161 * @return An instance of {@link RegexStringComparator} made from <code>bytes</code> -162 * @throws DeserializationException -163 * @see #toByteArray -164 */ -165 public static RegexStringComparator parseFrom(final byte [] pbBytes) -166 throws DeserializationException { -167 ComparatorProtos.RegexStringComparator proto; -168 try { -169 proto = ComparatorProtos.RegexStringComparator.parseFrom(pbBytes); -170 } catch (InvalidProtocolBufferException e) { -171 throw new DeserializationException(e); -172 } -173 RegexStringComparator comparator; -174 if (proto.hasEngine()) { -175 EngineType engine = EngineType.valueOf(proto.getEngine()); -176 comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags(), -177 engine); -178 } else { -179 comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags()); -180 } -181 String charset = proto.getCharset(); -182 if (charset.length() > 0) { -183 try { -184 comparator.getEngine().setCharset(charset); -185 } catch (IllegalCharsetNameException e) { -186 LOG.error("invalid charset", e); -187 } -188 } -189 return comparator; -190 } -191 -192 /** -193 * @param other -194 * @return true if and only if the fields of the comparator that are serialized -195 * are equal to the corresponding fields in other. Used for testing. -196 */ -197 @Override -198 boolean areSerializedFieldsEqual(ByteArrayComparable other) { -199 if (other == this) return true; -200 if (!(other instanceof RegexStringComparator)) return false; -201 RegexStringComparator comparator = (RegexStringComparator)other; -202 return super.areSerializedFieldsEqual(comparator) -203 && engine.getClass().isInstance(comparator.getEngine()) -204 && engine.getPattern().equals(comparator.getEngine().getPattern()) -205 && engine.getFlags() == comparator.getEngine().getFlags() -206 && engine.getCharset().equals(comparator.getEngine().getCharset()); -207 } -208 -209 Engine getEngine() { -210 return engine; -211 } -212 -213 /** -214 * This is an internal interface for abstracting access to different regular -215 * expression matching engines. -216 */ -217 static interface Engine { -218 /** -219 * Returns the string representation of the configured regular expression -220 * for matching -221 */ -222 String getPattern(); -223 -224 /** -225 * Returns the set of configured match flags, a bit mask that may include -226 * {@link Pattern} flags -227 */ -228 int getFlags(); -229 -230 /** -231 * Returns the name of the configured charset -232 */ -233 String getCharset(); -234 -235 /** -236 * Set the charset used when matching -237 * @param charset the name of the desired charset for matching -238 */ -239 void setCharset(final String charset); -240 -241 /** -242 * Return the serialized form of the configured matcher -243 */ -244 byte [] toByteArray(); -245 -246 /** -247 * Match the given input against the configured pattern -248 * @param value the data to be matched -249 * @param offset offset of the data to be matched -250 * @param length length of the data to be matched -251 * @return 0 if a match was made, 1 otherwise -252 */ -253 int compareTo(byte[] value, int offset, int length); -254 } -255 -256 /** -257 * Implementation of the Engine interface using Java's Pattern. -258 * <p> -259 * This is the default engine. -260 */ -261 static class JavaRegexEngine implements Engine { -262 private Charset charset = Charset.forName("UTF-8"); -263 private Pattern pattern; -264 -265 public JavaRegexEngine(String regex, int flags) { -266 this.pattern = Pattern.compile(regex, flags); -267 } -268 -269 @Override -270 public String getPattern() { -271 return pattern.toString(); -272 } -273 -274 @Override -275 public int getFlags() { -276 return pattern.flags(); -277 } -278 -279 @Override -280 public String getCharset() { -281 return charset.name(); -282 } -283 -284 @Override -285 public void setCharset(String charset) { -286 this.charset = Charset.forName(charset); -287 } -288 -289 @Override -290 public int compareTo(byte[] value, int offset, int length) { -291 // Use find() for subsequence match instead of matches() (full sequence -292 // match) to adhere to the principle of least surprise. -293 String tmp; -294 if (length < value.length / 2) { -295 // See HBASE-9428. Make a copy of the relevant part of the byte[], -296 // or the JDK will copy the entire byte[] during String decode -297 tmp = new String(Arrays.copyOfRange(value, offset, offset + length), charset); -298 } else { -299 tmp = new String(value, offset, length, charset); -300 } -301 return pattern.matcher(tmp).find() ? 0 : 1; -302 } -303 -304 @Override -305 public byte[] toByteArray() { -306 ComparatorProtos.RegexStringComparator.Builder builder = -307 ComparatorProtos.RegexStringComparator.newBuilder(); -308 builder.setPattern(pattern.pattern()); -309 builder.setPatternFlags(pattern.flags()); -310 builder.setCharset(charset.name()); -311 builder.setEngine(EngineType.JAVA.name()); -312 return builder.build().toByteArray(); -313 } -314 } -315 -316 /** -317 * Implementation of the Engine interface using Jruby's joni regex engine. -318 * <p> -319 * This engine operates on byte arrays directly so is expected to be more GC -320 * friendly, and reportedly is twice as fast as Java's Pattern engine. -321 * <p> -322 * NOTE: Only the {@link Pattern} flags CASE_INSENSITIVE, DOTALL, and -323 * MULTILINE are supported. -324 */ -325 static class JoniRegexEngine implements Engine { -326 private Encoding encoding = UTF8Encoding.INSTANCE; -327 private String regex; -328 private Regex pattern; -329 -330 public JoniRegexEngine(String regex, int flags) { -331 this.regex = regex; -332 byte[] b = Bytes.toBytes(regex); -333 this.pattern = new Regex(b, 0, b.length, patternToJoniFlags(flags), encoding, Syntax.Java); -334 } -335 -336 @Override -337 public String getPattern() { -338 return regex; -339 } -340 -341 @Override -342 public int getFlags() { -343 return pattern.getOptions(); -344 } -345 -346 @Override -347 public String getCharset() { -348 return encoding.getCharsetName(); -349 } -350 -351 @Override -352 public void setCharset(String name) { -353 setEncoding(name); -354 } -355 -356 @Override -357 public int compareTo(byte[] value, int offset, int length) { -358 // Use subsequence match instead of full sequence match to adhere to the -359 // principle of least surprise. -360 Matcher m = pattern.matcher(value); -361 return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0; -362 } -363 -364 @Override -365 public byte[] toByteArray() { -366 ComparatorProtos.RegexStringComparator.Builder builder = -367 ComparatorProtos.RegexStringComparator.newBuilder(); -368 builder.setPattern(regex); -369 builder.setPatternFlags(joniToPatternFlags(pattern.getOptions())); -370 builder.setCharset(encoding.getCharsetName()); -371 builder.setEngine(EngineType.JONI.name()); -372 return builder.build().toByteArray(); -373 } -374 -375 private int patternToJoniFlags(int flags) { -376 int newFlags = 0; -377 if ((flags & Pattern.CASE_INSENSITIVE) != 0) { -378 newFlags |= Option.IGNORECASE; -379 } -380 if ((flags & Pattern.DOTALL) != 0) { -381 // This does NOT mean Pattern.MULTILINE -382 newFlags |= Option.MULTILINE; -383 } -384 if ((flags & Pattern.MULTILINE) != 0) { -385 // This is what Java 8's Nashorn engine does when using joni and -386 // translating Pattern's MULTILINE flag -387 newFlags &= ~Option.SINGLELINE; -388 newFlags |= Option.NEGATE_SINGLELINE; -389 } -390 return newFlags; -391 } -392 -393 private int joniToPatternFlags(int flags) { -394 int newFlags = 0; -395 if ((flags & Option.IGNORECASE) != 0) { -396 newFlags |= Pattern.CASE_INSENSITIVE; -397 } -398 // This does NOT mean Pattern.MULTILINE, this is equivalent to Pattern.DOTALL -399 if ((flags & Option.MULTILINE) != 0) { -400 newFlags |= Pattern.DOTALL; -401 } -402 // This means Pattern.MULTILINE. Nice -403 if ((flags & Option.NEGATE_SINGLELINE) != 0) { -404 newFlags |= Pattern.MULTILINE; -405 } -406 return newFlags; -407 } -408 -409 private void setEncoding(String name) { -410 EncodingDB.Entry e = EncodingDB.getEncodings().get(Bytes.toBytes(name)); -411 if (e != null) { -412 encoding = e.getEncoding(); -413 } else { -414 throw new IllegalCharsetNameException(name); -415 } -416 } -417 } -418} +072@SuppressWarnings("ComparableType") // Should this move to Comparator usage? +073public class RegexStringComparator extends ByteArrayComparable { +074 +075 private static final Logger LOG = LoggerFactory.getLogger(RegexStringComparator.class); +076 +077 private Engine engine; +078 +079 /** Engine implementation type (default=JAVA) */ +080 @InterfaceAudience.Public +081 public enum EngineType { +082 JAVA, +083 JONI +084 } +085 +086 /** +087 * Constructor +088 * Adds Pattern.DOTALL to the underlying Pattern +089 * @param expr a valid regular expression +090 */ +091 public RegexStringComparator(String expr) { +092 this(expr, Pattern.DOTALL); +093 } +094 +095 /** +096 * Constructor +097 * Adds Pattern.DOTALL to the underlying Pattern +098 * @param expr a valid regular expression +099 * @param engine engine implementation type +100 */ +101 public RegexStringComparator(String expr, EngineType engine) { +102 this(expr, Pattern.DOTALL, engine); +103 } +104 +105 /** +106 * Constructor +107 * @param expr a valid regular expression +108 * @param flags java.util.regex.Pattern flags +109 */ +110 public RegexStringComparator(String expr, int flags) { +111 this(expr, flags, EngineType.JAVA); +112 } +113 +114 /** +115 * Constructor +116 * @param expr a valid regular expression +117 * @param flags java.util.regex.Pattern flags +118 * @param engine engine implementation type +119 */ +120 public RegexStringComparator(String expr, int flags, EngineType engine) { +121 super(Bytes.toBytes(expr)); +122 switch (engine) { +123 case JAVA: +124 this.engine = new JavaRegexEngine(expr, flags); +125 break; +126 case JONI: +127 this.engine = new JoniRegexEngine(expr, flags); +128 break; +129 } +130 } +131 +132 /** +133 * Specifies the {@link Charset} to use to convert the row key to a String. +134 * <p> +135 * The row key needs to be converted to a String in order to be matched +136 * against the regular expression. This method controls which charset is +137 * used to do this conversion. +138 * <p> +139 * If the row key is made of arbitrary bytes, the charset {@code ISO-8859-1} +140 * is recommended. +141 * @param charset The charset to use. +142 */ +143 public void setCharset(final Charset charset) { +144 engine.setCharset(charset.name()); +145 } +146 +147 @Override +148 public int compareTo(byte[] value, int offset, int length) { +149 return engine.compareTo(value, offset, length); +150 } +151 +152 /** +153 * @return The comparator serialized using pb +154 */ +155 @Override +156 public byte [] toByteArray() { +157 return engine.toByteArray(); +158 } +159 +160 /** +161 * @param pbBytes A pb serialized {@link RegexStringComparator} instance +162 * @return An instance of {@link RegexStringComparator} made from <code>bytes</code> +163 * @throws DeserializationException +164 * @see #toByteArray +165 */ +166 public static RegexStringComparator parseFrom(final byte [] pbBytes) +167 throws DeserializationException { +168 ComparatorProtos.RegexStringComparator proto; +169 try { +170 proto = ComparatorProtos.RegexStringComparator.parseFrom(pbBytes); +171 } catch (InvalidProtocolBufferException e) { +172 throw new DeserializationException(e); +173 } +174 RegexStringComparator comparator; +175 if (proto.hasEngine()) { +176 EngineType engine = EngineType.valueOf(proto.getEngine()); +177 comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags(), +178 engine); +179 } else { +180 comparator = new RegexStringComparator(proto.getPattern(), proto.getPatternFlags()); +181 } +182 String charset = proto.getCharset(); +183 if (charset.length() > 0) { +184 try { +185 comparator.getEngine().setCharset(charset); +186 } catch (IllegalCharsetNameException e) { +187 LOG.error("invalid charset", e); +188 } +189 } +190 return comparator; +191 } +192 +193 /** +194 * @param other +195 * @return true if and only if the fields of the comparator that are serialized +196 * are equal to the corresponding fields in other. Used for testing. +197 */ +198 @Override +199 boolean areSerializedFieldsEqual(ByteArrayComparable other) { +200 if (other == this) return true; +201 if (!(other instanceof RegexStringComparator)) return false; +202 RegexStringComparator comparator = (RegexStringComparator)other; +203 return super.areSerializedFieldsEqual(comparator) +204 && engine.getClass().isInstance(comparator.getEngine()) +205 && engine.getPattern().equals(comparator.getEngine().getPattern()) +206 && engine.getFlags() == comparator.getEngine().getFlags() +207 && engine.getCharset().equals(comparator.getEngine().getCharset()); +208 } +209 +210 Engine getEngine() { +211 return engine; +212 } +213 +214 /** +215 * This is an internal interface for abstracting access to different regular +216 * expression matching engines. +217 */ +218 static interface Engine { +219 /** +220 * Returns the string representation of the configured regular expression +221 * for matching +222 */ +223 String getPattern(); +224 +225 /** +226 * Returns the set of configured match flags, a bit mask that may include +227 * {@link Pattern} flags +228 */ +229 int getFlags(); +230 +231 /** +232 * Returns the name of the configured charset +233 */ +234 String getCharset(); +235 +236 /** +237 * Set the charset used when matching +238 * @param charset the name of the desired charset for matching +239 */ +240 void setCharset(final String charset); +241 +242 /** +243 * Return the serialized form of the configured matcher +244 */ +245 byte [] toByteArray(); +246 +247 /** +248 * Match the given input against the configured pattern +249 * @param value the data to be matched +250 * @param offset offset of the data to be matched +251 * @param length length of the data to be matched +252 * @return 0 if a match was made, 1 otherwise +253 */ +254 int compareTo(byte[] value, int offset, int length); +255 } +256 +257 /** +258 * Implementation of the Engine interface using Java's Pattern. +259 * <p> +260 * This is the default engine. +261 */ +262 static class JavaRegexEngine implements Engine { +263 private Charset charset = Charset.forName("UTF-8"); +264 private Pattern pattern; +265 +266 public JavaRegexEngine(String regex, int flags) { +267 this.pattern = Pattern.compile(regex, flags); +268 } +269 +270 @Override +271 public String getPattern() { +272 return pattern.toString(); +273 } +274 +275 @Override +276 public int getFlags() { +277 return pattern.flags(); +278 } +279 +280 @Override +281 public String getCharset() { +282 return charset.name(); +283 } +284 +285 @Override +286 public void setCharset(String charset) { +287 this.charset = Charset.forName(charset); +288 } +289 +290 @Override +291 public int compareTo(byte[] value, int offset, int length) { +292 // Use find() for subsequence match instead of matches() (full sequence +293 // match) to adhere to the principle of least surprise. +294 String tmp; +295 if (length < value.length / 2) { +296 // See HBASE-9428. Make a copy of the relevant part of the byte[], +297 // or the JDK will copy the entire byte[] during String decode +298 tmp = new String(Arrays.copyOfRange(value, offset, offset + length), charset); +299 } else { +300 tmp = new String(value, offset, length, charset); +301 } +302 return pattern.matcher(tmp).find() ? 0 : 1; +303 } +304 +305 @Override +306 public byte[] toByteArray() { +307 ComparatorProtos.RegexStringComparator.Builder builder = +308 ComparatorProtos.RegexStringComparator.newBuilder(); +309 builder.setPattern(pattern.pattern()); +310 builder.setPatternFlags(pattern.flags()); +311 builder.setCharset(charset.name()); +312 builder.setEngine(EngineType.JAVA.name()); +313 return builder.build().toByteArray(); +314 } +315 } +316 +317 /** +318 * Implementation of the Engine interface using Jruby's joni regex engine. +319 * <p> +320 * This engine operates on byte arrays directly so is expected to be more GC +321 * friendly, and reportedly is twice as fast as Java's Pattern engine. +322 * <p> +323 * NOTE: Only the {@link Pattern} flags CASE_INSENSITIVE, DOTALL, and +324 * MULTILINE are supported. +325 */ +326 static class JoniRegexEngine implements Engine { +327 private Encoding encoding = UTF8Encoding.INSTANCE; +328 private String regex; +329 private Regex pattern; +330 +331 public JoniRegexEngine(String regex, int flags) { +332 this.regex = regex; +333 byte[] b = Bytes.toBytes(regex); +334 this.pattern = new Regex(b, 0, b.length, patternToJoniFlags(flags), encoding, Syntax.Java); +335 } +336 +337 @Override +338 public String getPattern() { +339 return regex; +340 } +341 +342 @Override +343 public int getFlags() { +344 return pattern.getOptions(); +345 } +346 +347 @Override +348 public String getCharset() { +349 return encoding.getCharsetName(); +350 } +351 +352 @Override +353 public void setCharset(String name) { +354 setEncoding(name); +355 } +356 +357 @Override +358 public int compareTo(byte[] value, int offset, int length) { +359 // Use subsequence match instead of full sequence match to adhere to the +360 // principle of least surprise. +361 Matcher m = pattern.matcher(value); +362 return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0; +363 } +364 +365 @Override +366 public byte[] toByteArray() { +367 ComparatorProtos.RegexStringComparator.Builder builder = +368 ComparatorProtos.RegexStringComparator.newBuilder(); +369 builder.setPattern(regex); +370 builder.setPatternFlags(joniToPatternFlags(pattern.getOptions())); +371 builder.setCharset(encoding.getCharsetName()); +372 builder.setEngine(EngineType.JONI.name()); +373 return builder.build().toByteArray(); +374 } +375 +376 private int patternToJoniFlags(int flags) { +377 int newFlags = 0; +378 if ((flags & Pattern.CASE_INSENSITIVE) != 0) { +379 newFlags |= Option.IGNORECASE; +380 } +381 if ((flags & Pattern.DOTALL) != 0) { +382 // This does NOT mean Pattern.MULTILINE +383 newFlags |= Option.MULTILINE; +384 } +385 if ((flags & Pattern.MULTILINE) != 0) { +386 // This is what Java 8's Nashorn engine does when using joni and +387 // translating Pattern's MULTILINE flag +388 newFlags &= ~Option.SINGLELINE; +389 newFlags |= Option.NEGATE_SINGLELINE; +390 } +391 return newFlags; +392 } +393 +394 private int joniToPatternFlags(int flags) { +395 int newFlags = 0; +396 if ((flags & Option.IGNORECASE) != 0) { +397 newFlags |= Pattern.CASE_INSENSITIVE; +398 } +399 // This does NOT mean Pattern.MULTILINE, this is equivalent to Pattern.DOTALL +400 if ((flags & Option.MULTILINE) != 0) { +401 newFlags |= Pattern.DOTALL; +402 } +403 // This means Pattern.MULTILINE. Nice +404 if ((flags & Option.NEGATE_SINGLELINE) != 0) { +405 newFlags |= Pattern.MULTILINE; +406 } +407 return newFlags; +408 } +409 +410 private void setEncoding(String name) { +411 EncodingDB.Entry e = EncodingDB.getEncodings().get(Bytes.toBytes(name)); +412 if (e != null) { +413 encoding = e.getEncoding(); +414 } else { +415 throw new IllegalCharsetNameException(name); +416 } +417 } +418 } +419} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e9a81b89/apidocs/src-html/org/apache/hadoop/hbase/filter/SubstringComparator.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/filter/SubstringComparator.html b/apidocs/src-html/org/apache/hadoop/hbase/filter/SubstringComparator.html index 2fd419e..3ec71cf 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/filter/SubstringComparator.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/filter/SubstringComparator.html @@ -51,74 +51,75 @@ 043 * </pre> 044 */ 045@InterfaceAudience.Public -046public class SubstringComparator extends ByteArrayComparable { -047 -048 private String substr; -049 -050 /** -051 * Constructor -052 * @param substr the substring -053 */ -054 public SubstringComparator(String substr) { -055 super(Bytes.toBytes(substr.toLowerCase(Locale.ROOT))); -056 this.substr = substr.toLowerCase(Locale.ROOT); -057 } -058 -059 @Override -060 public byte[] getValue() { -061 return Bytes.toBytes(substr); -062 } -063 -064 @Override -065 public int compareTo(byte[] value, int offset, int length) { -066 return Bytes.toString(value, offset, length).toLowerCase(Locale.ROOT).contains(substr) ? 0 -067 : 1; -068 } -069 -070 /** -071 * @return The comparator serialized using pb -072 */ -073 @Override -074 public byte [] toByteArray() { -075 ComparatorProtos.SubstringComparator.Builder builder = -076 ComparatorProtos.SubstringComparator.newBuilder(); -077 builder.setSubstr(this.substr); -078 return builder.build().toByteArray(); -079 } -080 -081 /** -082 * @param pbBytes A pb serialized {@link SubstringComparator} instance -083 * @return An instance of {@link SubstringComparator} made from <code>bytes</code> -084 * @throws DeserializationException -085 * @see #toByteArray -086 */ -087 public static SubstringComparator parseFrom(final byte [] pbBytes) -088 throws DeserializationException { -089 ComparatorProtos.SubstringComparator proto; -090 try { -091 proto = ComparatorProtos.SubstringComparator.parseFrom(pbBytes); -092 } catch (InvalidProtocolBufferException e) { -093 throw new DeserializationException(e); -094 } -095 return new SubstringComparator(proto.getSubstr()); -096 } -097 -098 /** -099 * @param other -100 * @return true if and only if the fields of the comparator that are serialized -101 * are equal to the corresponding fields in other. Used for testing. -102 */ -103 @Override -104 boolean areSerializedFieldsEqual(ByteArrayComparable other) { -105 if (other == this) return true; -106 if (!(other instanceof SubstringComparator)) return false; -107 -108 SubstringComparator comparator = (SubstringComparator)other; -109 return super.areSerializedFieldsEqual(comparator) -110 && this.substr.equals(comparator.substr); -111 } -112 -113} +046@SuppressWarnings("ComparableType") // Should this move to Comparator usage? +047public class SubstringComparator extends ByteArrayComparable { +048 +049 private String substr; +050 +051 /** +052 * Constructor +053 * @param substr the substring +054 */ +055 public SubstringComparator(String substr) { +056 super(Bytes.toBytes(substr.toLowerCase(Locale.ROOT))); +057 this.substr = substr.toLowerCase(Locale.ROOT); +058 } +059 +060 @Override +061 public byte[] getValue() { +062 return Bytes.toBytes(substr); +063 } +064 +065 @Override +066 public int compareTo(byte[] value, int offset, int length) { +067 return Bytes.toString(value, offset, length).toLowerCase(Locale.ROOT).contains(substr) ? 0 +068 : 1; +069 } +070 +071 /** +072 * @return The comparator serialized using pb +073 */ +074 @Override +075 public byte [] toByteArray() { +076 ComparatorProtos.SubstringComparator.Builder builder = +077 ComparatorProtos.SubstringComparator.newBuilder(); +078 builder.setSubstr(this.substr); +079 return builder.build().toByteArray(); +080 } +081 +082 /** +083 * @param pbBytes A pb serialized {@link SubstringComparator} instance +084 * @return An instance of {@link SubstringComparator} made from <code>bytes</code> +085 * @throws DeserializationException +086 * @see #toByteArray +087 */ +088 public static SubstringComparator parseFrom(final byte [] pbBytes) +089 throws DeserializationException { +090 ComparatorProtos.SubstringComparator proto; +091 try { +092 proto = ComparatorProtos.SubstringComparator.parseFrom(pbBytes); +093 } catch (InvalidProtocolBufferException e) { +094 throw new DeserializationException(e); +095 } +096 return new SubstringComparator(proto.getSubstr()); +097 } +098 +099 /** +100 * @param other +101 * @return true if and only if the fields of the comparator that are serialized +102 * are equal to the corresponding fields in other. Used for testing. +103 */ +104 @Override +105 boolean areSerializedFieldsEqual(ByteArrayComparable other) { +106 if (other == this) return true; +107 if (!(other instanceof SubstringComparator)) return false; +108 +109 SubstringComparator comparator = (SubstringComparator)other; +110 return super.areSerializedFieldsEqual(comparator) +111 && this.substr.equals(comparator.substr); +112 } +113 +114} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e9a81b89/book.html ---------------------------------------------------------------------- diff --git a/book.html b/book.html index 7373777..4145b34 100644 --- a/book.html +++ b/book.html @@ -37286,7 +37286,7 @@ The server will return cellblocks compressed using this same compressor as long http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e9a81b89/bulk-loads.html ---------------------------------------------------------------------- diff --git a/bulk-loads.html b/bulk-loads.html index fe3a7d7..46b5112 100644 --- a/bulk-loads.html +++ b/bulk-loads.html @@ -7,7 +7,7 @@ - + Apache HBase – Bulk Loads in Apache HBase (TM) @@ -299,7 +299,7 @@ under the License. --> <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved. - <li id="publishDate" class="pull-right">Last Published: 2018-03-07</li> + <li id="publishDate" class="pull-right">Last Published: 2018-03-08</li> </p> </div>