Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7F0618498 for ; Wed, 18 Nov 2015 07:50:59 +0000 (UTC) Received: (qmail 56861 invoked by uid 500); 18 Nov 2015 07:50:55 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 56688 invoked by uid 500); 18 Nov 2015 07:50:55 -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 51417 invoked by uid 99); 18 Nov 2015 07:50:50 -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; Wed, 18 Nov 2015 07:50:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 615EBE10D0; Wed, 18 Nov 2015 07:50:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: misty@apache.org To: commits@hbase.apache.org Date: Wed, 18 Nov 2015 07:51:19 -0000 Message-Id: <4c28abbfea444066ae977e22554503e1@git.apache.org> In-Reply-To: <6272ebf5b70247d88a951849548fe02a@git.apache.org> References: <6272ebf5b70247d88a951849548fe02a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [31/51] [partial] hbase git commit: Published site at 5ebd7660a94bfb18e6e05b6e46195c76c099eda2. http://git-wip-us.apache.org/repos/asf/hbase/blob/20c64fef/apidocs/src-html/org/apache/hadoop/hbase/client/Scan.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/client/Scan.html b/apidocs/src-html/org/apache/hadoop/hbase/client/Scan.html index 79128a3..cbdb963 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/client/Scan.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/client/Scan.html @@ -256,732 +256,742 @@ 248 for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { 249 setAttribute(attr.getKey(), attr.getValue()); 250 } -251 } -252 -253 /** -254 * Builds a scan object with the same specs as get. -255 * @param get get to model scan after -256 */ -257 public Scan(Get get) { -258 this.startRow = get.getRow(); -259 this.stopRow = get.getRow(); -260 this.filter = get.getFilter(); -261 this.cacheBlocks = get.getCacheBlocks(); -262 this.maxVersions = get.getMaxVersions(); -263 this.storeLimit = get.getMaxResultsPerColumnFamily(); -264 this.storeOffset = get.getRowOffsetPerColumnFamily(); -265 this.tr = get.getTimeRange(); -266 this.familyMap = get.getFamilyMap(); -267 this.getScan = true; -268 this.asyncPrefetch = false; -269 this.consistency = get.getConsistency(); -270 for (Map.Entry<String, byte[]> attr : get.getAttributesMap().entrySet()) { -271 setAttribute(attr.getKey(), attr.getValue()); -272 } -273 } -274 -275 public boolean isGetScan() { -276 return this.getScan || isStartRowAndEqualsStopRow(); -277 } -278 -279 private boolean isStartRowAndEqualsStopRow() { -280 return this.startRow != null && this.startRow.length > 0 && -281 Bytes.equals(this.startRow, this.stopRow); -282 } -283 /** -284 * Get all columns from the specified family. -285 * <p> -286 * Overrides previous calls to addColumn for this family. -287 * @param family family name -288 * @return this -289 */ -290 public Scan addFamily(byte [] family) { -291 familyMap.remove(family); -292 familyMap.put(family, null); -293 return this; -294 } -295 -296 /** -297 * Get the column from the specified family with the specified qualifier. -298 * <p> -299 * Overrides previous calls to addFamily for this family. -300 * @param family family name -301 * @param qualifier column qualifier -302 * @return this -303 */ -304 public Scan addColumn(byte [] family, byte [] qualifier) { -305 NavigableSet<byte []> set = familyMap.get(family); -306 if(set == null) { -307 set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR); -308 } -309 if (qualifier == null) { -310 qualifier = HConstants.EMPTY_BYTE_ARRAY; -311 } -312 set.add(qualifier); -313 familyMap.put(family, set); -314 return this; -315 } -316 -317 /** -318 * Get versions of columns only within the specified timestamp range, -319 * [minStamp, maxStamp). Note, default maximum versions to return is 1. If -320 * your time range spans more than one version and you want all versions -321 * returned, up the number of versions beyond the default. -322 * @param minStamp minimum timestamp value, inclusive -323 * @param maxStamp maximum timestamp value, exclusive -324 * @throws IOException if invalid time range -325 * @see #setMaxVersions() -326 * @see #setMaxVersions(int) -327 * @return this -328 */ -329 public Scan setTimeRange(long minStamp, long maxStamp) -330 throws IOException { -331 tr = new TimeRange(minStamp, maxStamp); -332 return this; -333 } -334 -335 /** -336 * Get versions of columns with the specified timestamp. Note, default maximum -337 * versions to return is 1. If your time range spans more than one version -338 * and you want all versions returned, up the number of versions beyond the -339 * defaut. -340 * @param timestamp version timestamp -341 * @see #setMaxVersions() -342 * @see #setMaxVersions(int) -343 * @return this -344 */ -345 public Scan setTimeStamp(long timestamp) -346 throws IOException { -347 try { -348 tr = new TimeRange(timestamp, timestamp+1); -349 } catch(IOException e) { -350 // This should never happen, unless integer overflow or something extremely wrong... -351 LOG.error("TimeRange failed, likely caused by integer overflow. ", e); -352 throw e; -353 } -354 return this; -355 } -356 -357 /** -358 * Set the start row of the scan. -359 * <p> -360 * If the specified row does not exist, the Scanner will start from the -361 * next closest row after the specified row. -362 * @param startRow row to start scanner at or after -363 * @return this -364 */ -365 public Scan setStartRow(byte [] startRow) { -366 this.startRow = startRow; -367 return this; -368 } -369 -370 /** -371 * Set the stop row of the scan. -372 * @param stopRow row to end at (exclusive) -373 * <p> -374 * The scan will include rows that are lexicographically less than -375 * the provided stopRow. -376 * <p><b>Note:</b> When doing a filter for a rowKey <u>Prefix</u> -377 * use {@link #setRowPrefixFilter(byte[])}. -378 * The 'trailing 0' will not yield the desired result.</p> -379 * @return this -380 */ -381 public Scan setStopRow(byte [] stopRow) { -382 this.stopRow = stopRow; -383 return this; -384 } -385 -386 /** -387 * <p>Set a filter (using stopRow and startRow) so the result set only contains rows where the -388 * rowKey starts with the specified prefix.</p> -389 * <p>This is a utility method that converts the desired rowPrefix into the appropriate values -390 * for the startRow and stopRow to achieve the desired result.</p> -391 * <p>This can safely be used in combination with setFilter.</p> -392 * <p><b>NOTE: Doing a {@link #setStartRow(byte[])} and/or {@link #setStopRow(byte[])} -393 * after this method will yield undefined results.</b></p> -394 * @param rowPrefix the prefix all rows must start with. (Set <i>null</i> to remove the filter.) -395 * @return this -396 */ -397 public Scan setRowPrefixFilter(byte[] rowPrefix) { -398 if (rowPrefix == null) { -399 setStartRow(HConstants.EMPTY_START_ROW); -400 setStopRow(HConstants.EMPTY_END_ROW); -401 } else { -402 this.setStartRow(rowPrefix); -403 this.setStopRow(calculateTheClosestNextRowKeyForPrefix(rowPrefix)); -404 } -405 return this; -406 } -407 -408 /** -409 * <p>When scanning for a prefix the scan should stop immediately after the the last row that -410 * has the specified prefix. This method calculates the closest next rowKey immediately following -411 * the given rowKeyPrefix.</p> -412 * <p><b>IMPORTANT: This converts a rowKey<u>Prefix</u> into a rowKey</b>.</p> -413 * <p>If the prefix is an 'ASCII' string put into a byte[] then this is easy because you can -414 * simply increment the last byte of the array. -415 * But if your application uses real binary rowids you may run into the scenario that your -416 * prefix is something like:</p> -417 * &nbsp;&nbsp;&nbsp;<b>{ 0x12, 0x23, 0xFF, 0xFF }</b><br/> -418 * Then this stopRow needs to be fed into the actual scan<br/> -419 * &nbsp;&nbsp;&nbsp;<b>{ 0x12, 0x24 }</b> (Notice that it is shorter now)<br/> -420 * This method calculates the correct stop row value for this usecase. -421 * -422 * @param rowKeyPrefix the rowKey<u>Prefix</u>. -423 * @return the closest next rowKey immediately following the given rowKeyPrefix. -424 */ -425 private byte[] calculateTheClosestNextRowKeyForPrefix(byte[] rowKeyPrefix) { -426 // Essentially we are treating it like an 'unsigned very very long' and doing +1 manually. -427 // Search for the place where the trailing 0xFFs start -428 int offset = rowKeyPrefix.length; -429 while (offset > 0) { -430 if (rowKeyPrefix[offset - 1] != (byte) 0xFF) { -431 break; -432 } -433 offset--; -434 } -435 -436 if (offset == 0) { -437 // We got an 0xFFFF... (only FFs) stopRow value which is -438 // the last possible prefix before the end of the table. -439 // So set it to stop at the 'end of the table' -440 return HConstants.EMPTY_END_ROW; -441 } -442 -443 // Copy the right length of the original -444 byte[] newStopRow = Arrays.copyOfRange(rowKeyPrefix, 0, offset); -445 // And increment the last one -446 newStopRow[newStopRow.length - 1]++; -447 return newStopRow; -448 } -449 -450 /** -451 * Get all available versions. -452 * @return this -453 */ -454 public Scan setMaxVersions() { -455 this.maxVersions = Integer.MAX_VALUE; -456 return this; -457 } -458 -459 /** -460 * Get up to the specified number of versions of each column. -461 * @param maxVersions maximum versions for each column +251 for (Map.Entry<byte[], TimeRange> entry : scan.getColumnFamilyTimeRange().entrySet()) { +252 TimeRange tr = entry.getValue(); +253 setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax()); +254 } +255 } +256 +257 /** +258 * Builds a scan object with the same specs as get. +259 * @param get get to model scan after +260 */ +261 public Scan(Get get) { +262 this.startRow = get.getRow(); +263 this.stopRow = get.getRow(); +264 this.filter = get.getFilter(); +265 this.cacheBlocks = get.getCacheBlocks(); +266 this.maxVersions = get.getMaxVersions(); +267 this.storeLimit = get.getMaxResultsPerColumnFamily(); +268 this.storeOffset = get.getRowOffsetPerColumnFamily(); +269 this.tr = get.getTimeRange(); +270 this.familyMap = get.getFamilyMap(); +271 this.getScan = true; +272 this.asyncPrefetch = false; +273 this.consistency = get.getConsistency(); +274 for (Map.Entry<String, byte[]> attr : get.getAttributesMap().entrySet()) { +275 setAttribute(attr.getKey(), attr.getValue()); +276 } +277 for (Map.Entry<byte[], TimeRange> entry : get.getColumnFamilyTimeRange().entrySet()) { +278 TimeRange tr = entry.getValue(); +279 setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax()); +280 } +281 } +282 +283 public boolean isGetScan() { +284 return this.getScan || isStartRowAndEqualsStopRow(); +285 } +286 +287 private boolean isStartRowAndEqualsStopRow() { +288 return this.startRow != null && this.startRow.length > 0 && +289 Bytes.equals(this.startRow, this.stopRow); +290 } +291 /** +292 * Get all columns from the specified family. +293 * <p> +294 * Overrides previous calls to addColumn for this family. +295 * @param family family name +296 * @return this +297 */ +298 public Scan addFamily(byte [] family) { +299 familyMap.remove(family); +300 familyMap.put(family, null); +301 return this; +302 } +303 +304 /** +305 * Get the column from the specified family with the specified qualifier. +306 * <p> +307 * Overrides previous calls to addFamily for this family. +308 * @param family family name +309 * @param qualifier column qualifier +310 * @return this +311 */ +312 public Scan addColumn(byte [] family, byte [] qualifier) { +313 NavigableSet<byte []> set = familyMap.get(family); +314 if(set == null) { +315 set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR); +316 } +317 if (qualifier == null) { +318 qualifier = HConstants.EMPTY_BYTE_ARRAY; +319 } +320 set.add(qualifier); +321 familyMap.put(family, set); +322 return this; +323 } +324 +325 /** +326 * Get versions of columns only within the specified timestamp range, +327 * [minStamp, maxStamp). Note, default maximum versions to return is 1. If +328 * your time range spans more than one version and you want all versions +329 * returned, up the number of versions beyond the default. +330 * @param minStamp minimum timestamp value, inclusive +331 * @param maxStamp maximum timestamp value, exclusive +332 * @see #setMaxVersions() +333 * @see #setMaxVersions(int) +334 * @return this +335 */ +336 public Scan setTimeRange(long minStamp, long maxStamp) throws IOException { +337 tr = new TimeRange(minStamp, maxStamp); +338 return this; +339 } +340 +341 /** +342 * Get versions of columns with the specified timestamp. Note, default maximum +343 * versions to return is 1. If your time range spans more than one version +344 * and you want all versions returned, up the number of versions beyond the +345 * defaut. +346 * @param timestamp version timestamp +347 * @see #setMaxVersions() +348 * @see #setMaxVersions(int) +349 * @return this +350 */ +351 public Scan setTimeStamp(long timestamp) +352 throws IOException { +353 try { +354 tr = new TimeRange(timestamp, timestamp+1); +355 } catch(Exception e) { +356 // This should never happen, unless integer overflow or something extremely wrong... +357 LOG.error("TimeRange failed, likely caused by integer overflow. ", e); +358 throw e; +359 } +360 return this; +361 } +362 +363 @Override public Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) { +364 return (Scan) super.setColumnFamilyTimeRange(cf, minStamp, maxStamp); +365 } +366 +367 /** +368 * Set the start row of the scan. +369 * <p> +370 * If the specified row does not exist, the Scanner will start from the +371 * next closest row after the specified row. +372 * @param startRow row to start scanner at or after +373 * @return this +374 */ +375 public Scan setStartRow(byte [] startRow) { +376 this.startRow = startRow; +377 return this; +378 } +379 +380 /** +381 * Set the stop row of the scan. +382 * @param stopRow row to end at (exclusive) +383 * <p> +384 * The scan will include rows that are lexicographically less than +385 * the provided stopRow. +386 * <p><b>Note:</b> When doing a filter for a rowKey <u>Prefix</u> +387 * use {@link #setRowPrefixFilter(byte[])}. +388 * The 'trailing 0' will not yield the desired result.</p> +389 * @return this +390 */ +391 public Scan setStopRow(byte [] stopRow) { +392 this.stopRow = stopRow; +393 return this; +394 } +395 +396 /** +397 * <p>Set a filter (using stopRow and startRow) so the result set only contains rows where the +398 * rowKey starts with the specified prefix.</p> +399 * <p>This is a utility method that converts the desired rowPrefix into the appropriate values +400 * for the startRow and stopRow to achieve the desired result.</p> +401 * <p>This can safely be used in combination with setFilter.</p> +402 * <p><b>NOTE: Doing a {@link #setStartRow(byte[])} and/or {@link #setStopRow(byte[])} +403 * after this method will yield undefined results.</b></p> +404 * @param rowPrefix the prefix all rows must start with. (Set <i>null</i> to remove the filter.) +405 * @return this +406 */ +407 public Scan setRowPrefixFilter(byte[] rowPrefix) { +408 if (rowPrefix == null) { +409 setStartRow(HConstants.EMPTY_START_ROW); +410 setStopRow(HConstants.EMPTY_END_ROW); +411 } else { +412 this.setStartRow(rowPrefix); +413 this.setStopRow(calculateTheClosestNextRowKeyForPrefix(rowPrefix)); +414 } +415 return this; +416 } +417 +418 /** +419 * <p>When scanning for a prefix the scan should stop immediately after the the last row that +420 * has the specified prefix. This method calculates the closest next rowKey immediately following +421 * the given rowKeyPrefix.</p> +422 * <p><b>IMPORTANT: This converts a rowKey<u>Prefix</u> into a rowKey</b>.</p> +423 * <p>If the prefix is an 'ASCII' string put into a byte[] then this is easy because you can +424 * simply increment the last byte of the array. +425 * But if your application uses real binary rowids you may run into the scenario that your +426 * prefix is something like:</p> +427 * &nbsp;&nbsp;&nbsp;<b>{ 0x12, 0x23, 0xFF, 0xFF }</b><br/> +428 * Then this stopRow needs to be fed into the actual scan<br/> +429 * &nbsp;&nbsp;&nbsp;<b>{ 0x12, 0x24 }</b> (Notice that it is shorter now)<br/> +430 * This method calculates the correct stop row value for this usecase. +431 * +432 * @param rowKeyPrefix the rowKey<u>Prefix</u>. +433 * @return the closest next rowKey immediately following the given rowKeyPrefix. +434 */ +435 private byte[] calculateTheClosestNextRowKeyForPrefix(byte[] rowKeyPrefix) { +436 // Essentially we are treating it like an 'unsigned very very long' and doing +1 manually. +437 // Search for the place where the trailing 0xFFs start +438 int offset = rowKeyPrefix.length; +439 while (offset > 0) { +440 if (rowKeyPrefix[offset - 1] != (byte) 0xFF) { +441 break; +442 } +443 offset--; +444 } +445 +446 if (offset == 0) { +447 // We got an 0xFFFF... (only FFs) stopRow value which is +448 // the last possible prefix before the end of the table. +449 // So set it to stop at the 'end of the table' +450 return HConstants.EMPTY_END_ROW; +451 } +452 +453 // Copy the right length of the original +454 byte[] newStopRow = Arrays.copyOfRange(rowKeyPrefix, 0, offset); +455 // And increment the last one +456 newStopRow[newStopRow.length - 1]++; +457 return newStopRow; +458 } +459 +460 /** +461 * Get all available versions. 462 * @return this 463 */ -464 public Scan setMaxVersions(int maxVersions) { -465 this.maxVersions = maxVersions; +464 public Scan setMaxVersions() { +465 this.maxVersions = Integer.MAX_VALUE; 466 return this; 467 } 468 469 /** -470 * Set the maximum number of values to return for each call to next() -471 * @param batch the maximum number of values -472 */ -473 public Scan setBatch(int batch) { -474 if (this.hasFilter() && this.filter.hasFilterRow()) { -475 throw new IncompatibleFilterException( -476 "Cannot set batch on a scan using a filter" + -477 " that returns true for filter.hasFilterRow"); -478 } -479 this.batch = batch; -480 return this; -481 } -482 -483 /** -484 * Set the maximum number of values to return per row per Column Family -485 * @param limit the maximum number of values returned / row / CF -486 */ -487 public Scan setMaxResultsPerColumnFamily(int limit) { -488 this.storeLimit = limit; -489 return this; -490 } -491 -492 /** -493 * Set offset for the row per Column Family. -494 * @param offset is the number of kvs that will be skipped. -495 */ -496 public Scan setRowOffsetPerColumnFamily(int offset) { -497 this.storeOffset = offset; -498 return this; -499 } -500 -501 /** -502 * Set the number of rows for caching that will be passed to scanners. -503 * If not set, the Configuration setting {@link HConstants#HBASE_CLIENT_SCANNER_CACHING} will -504 * apply. -505 * Higher caching values will enable faster scanners but will use more memory. -506 * @param caching the number of rows for caching -507 */ -508 public Scan setCaching(int caching) { -509 this.caching = caching; -510 return this; -511 } -512 -513 /** -514 * @return the maximum result size in bytes. See {@link #setMaxResultSize(long)} -515 */ -516 public long getMaxResultSize() { -517 return maxResultSize; -518 } -519 -520 /** -521 * Set the maximum result size. The default is -1; this means that no specific -522 * maximum result size will be set for this scan, and the global configured -523 * value will be used instead. (Defaults to unlimited). -524 * -525 * @param maxResultSize The maximum result size in bytes. -526 */ -527 public Scan setMaxResultSize(long maxResultSize) { -528 this.maxResultSize = maxResultSize; -529 return this; -530 } -531 -532 @Override -533 public Scan setFilter(Filter filter) { -534 super.setFilter(filter); -535 return this; -536 } -537 -538 /** -539 * Setting the familyMap -540 * @param familyMap map of family to qualifier -541 * @return this -542 */ -543 public Scan setFamilyMap(Map<byte [], NavigableSet<byte []>> familyMap) { -544 this.familyMap = familyMap; +470 * Get up to the specified number of versions of each column. +471 * @param maxVersions maximum versions for each column +472 * @return this +473 */ +474 public Scan setMaxVersions(int maxVersions) { +475 this.maxVersions = maxVersions; +476 return this; +477 } +478 +479 /** +480 * Set the maximum number of values to return for each call to next() +481 * @param batch the maximum number of values +482 */ +483 public Scan setBatch(int batch) { +484 if (this.hasFilter() && this.filter.hasFilterRow()) { +485 throw new IncompatibleFilterException( +486 "Cannot set batch on a scan using a filter" + +487 " that returns true for filter.hasFilterRow"); +488 } +489 this.batch = batch; +490 return this; +491 } +492 +493 /** +494 * Set the maximum number of values to return per row per Column Family +495 * @param limit the maximum number of values returned / row / CF +496 */ +497 public Scan setMaxResultsPerColumnFamily(int limit) { +498 this.storeLimit = limit; +499 return this; +500 } +501 +502 /** +503 * Set offset for the row per Column Family. +504 * @param offset is the number of kvs that will be skipped. +505 */ +506 public Scan setRowOffsetPerColumnFamily(int offset) { +507 this.storeOffset = offset; +508 return this; +509 } +510 +511 /** +512 * Set the number of rows for caching that will be passed to scanners. +513 * If not set, the Configuration setting {@link HConstants#HBASE_CLIENT_SCANNER_CACHING} will +514 * apply. +515 * Higher caching values will enable faster scanners but will use more memory. +516 * @param caching the number of rows for caching +517 */ +518 public Scan setCaching(int caching) { +519 this.caching = caching; +520 return this; +521 } +522 +523 /** +524 * @return the maximum result size in bytes. See {@link #setMaxResultSize(long)} +525 */ +526 public long getMaxResultSize() { +527 return maxResultSize; +528 } +529 +530 /** +531 * Set the maximum result size. The default is -1; this means that no specific +532 * maximum result size will be set for this scan, and the global configured +533 * value will be used instead. (Defaults to unlimited). +534 * +535 * @param maxResultSize The maximum result size in bytes. +536 */ +537 public Scan setMaxResultSize(long maxResultSize) { +538 this.maxResultSize = maxResultSize; +539 return this; +540 } +541 +542 @Override +543 public Scan setFilter(Filter filter) { +544 super.setFilter(filter); 545 return this; 546 } 547 548 /** -549 * Getting the familyMap -550 * @return familyMap -551 */ -552 public Map<byte [], NavigableSet<byte []>> getFamilyMap() { -553 return this.familyMap; -554 } -555 -556 /** -557 * @return the number of families in familyMap -558 */ -559 public int numFamilies() { -560 if(hasFamilies()) { -561 return this.familyMap.size(); -562 } -563 return 0; +549 * Setting the familyMap +550 * @param familyMap map of family to qualifier +551 * @return this +552 */ +553 public Scan setFamilyMap(Map<byte [], NavigableSet<byte []>> familyMap) { +554 this.familyMap = familyMap; +555 return this; +556 } +557 +558 /** +559 * Getting the familyMap +560 * @return familyMap +561 */ +562 public Map<byte [], NavigableSet<byte []>> getFamilyMap() { +563 return this.familyMap; 564 } 565 566 /** -567 * @return true if familyMap is non empty, false otherwise +567 * @return the number of families in familyMap 568 */ -569 public boolean hasFamilies() { -570 return !this.familyMap.isEmpty(); -571 } -572 -573 /** -574 * @return the keys of the familyMap -575 */ -576 public byte[][] getFamilies() { -577 if(hasFamilies()) { -578 return this.familyMap.keySet().toArray(new byte[0][0]); -579 } -580 return null; +569 public int numFamilies() { +570 if(hasFamilies()) { +571 return this.familyMap.size(); +572 } +573 return 0; +574 } +575 +576 /** +577 * @return true if familyMap is non empty, false otherwise +578 */ +579 public boolean hasFamilies() { +580 return !this.familyMap.isEmpty(); 581 } 582 583 /** -584 * @return the startrow +584 * @return the keys of the familyMap 585 */ -586 public byte [] getStartRow() { -587 return this.startRow; -588 } -589 -590 /** -591 * @return the stoprow -592 */ -593 public byte [] getStopRow() { -594 return this.stopRow; -595 } -596 -597 /** -598 * @return the max number of versions to fetch -599 */ -600 public int getMaxVersions() { -601 return this.maxVersions; -602 } -603 -604 /** -605 * @return maximum number of values to return for a single call to next() -606 */ -607 public int getBatch() { -608 return this.batch; -609 } -610 -611 /** -612 * @return maximum number of values to return per row per CF -613 */ -614 public int getMaxResultsPerColumnFamily() { -615 return this.storeLimit; -616 } -617 -618 /** -619 * Method for retrieving the scan's offset per row per column -620 * family (#kvs to be skipped) -621 * @return row offset -622 */ -623 public int getRowOffsetPerColumnFamily() { -624 return this.storeOffset; -625 } -626 -627 /** -628 * @return caching the number of rows fetched when calling next on a scanner -629 */ -630 public int getCaching() { -631 return this.caching; -632 } -633 -634 /** -635 * @return TimeRange -636 */ -637 public TimeRange getTimeRange() { -638 return this.tr; -639 } -640 -641 /** -642 * @return RowFilter -643 */ -644 @Override -645 public Filter getFilter() { -646 return filter; -647 } -648 -649 /** -650 * @return true is a filter has been specified, false if not -651 */ -652 public boolean hasFilter() { -653 return filter != null; -654 } -655 -656 /** -657 * Set whether blocks should be cached for this Scan. -658 * <p> -659 * This is true by default. When true, default settings of the table and -660 * family are used (this will never override caching blocks if the block -661 * cache is disabled for that family or entirely). -662 * -663 * @param cacheBlocks if false, default settings are overridden and blocks -664 * will not be cached -665 */ -666 public Scan setCacheBlocks(boolean cacheBlocks) { -667 this.cacheBlocks = cacheBlocks; -668 return this; -669 } -670 -671 /** -672 * Get whether blocks should be cached for this Scan. -673 * @return true if default caching should be used, false if blocks should not -674 * be cached +586 public byte[][] getFamilies() { +587 if(hasFamilies()) { +588 return this.familyMap.keySet().toArray(new byte[0][0]); +589 } +590 return null; +591 } +592 +593 /** +594 * @return the startrow +595 */ +596 public byte [] getStartRow() { +597 return this.startRow; +598 } +599 +600 /** +601 * @return the stoprow +602 */ +603 public byte [] getStopRow() { +604 return this.stopRow; +605 } +606 +607 /** +608 * @return the max number of versions to fetch +609 */ +610 public int getMaxVersions() { +611 return this.maxVersions; +612 } +613 +614 /** +615 * @return maximum number of values to return for a single call to next() +616 */ +617 public int getBatch() { +618 return this.batch; +619 } +620 +621 /** +622 * @return maximum number of values to return per row per CF +623 */ +624 public int getMaxResultsPerColumnFamily() { +625 return this.storeLimit; +626 } +627 +628 /** +629 * Method for retrieving the scan's offset per row per column +630 * family (#kvs to be skipped) +631 * @return row offset +632 */ +633 public int getRowOffsetPerColumnFamily() { +634 return this.storeOffset; +635 } +636 +637 /** +638 * @return caching the number of rows fetched when calling next on a scanner +639 */ +640 public int getCaching() { +641 return this.caching; +642 } +643 +644 /** +645 * @return TimeRange +646 */ +647 public TimeRange getTimeRange() { +648 return this.tr; +649 } +650 +651 /** +652 * @return RowFilter +653 */ +654 @Override +655 public Filter getFilter() { +656 return filter; +657 } +658 +659 /** +660 * @return true is a filter has been specified, false if not +661 */ +662 public boolean hasFilter() { +663 return filter != null; +664 } +665 +666 /** +667 * Set whether blocks should be cached for this Scan. +668 * <p> +669 * This is true by default. When true, default settings of the table and +670 * family are used (this will never override caching blocks if the block +671 * cache is disabled for that family or entirely). +672 * +673 * @param cacheBlocks if false, default settings are overridden and blocks +674 * will not be cached 675 */ -676 public boolean getCacheBlocks() { -677 return cacheBlocks; -678 } -679 -680 /** -681 * Set whether this scan is a reversed one -682 * <p> -683 * This is false by default which means forward(normal) scan. -684 * -685 * @param reversed if true, scan will be backward order -686 * @return this -687 */ -688 public Scan setReversed(boolean reversed) { -689 this.reversed = reversed; -690 return this; -691 } -692 -693 /** -694 * Get whether this scan is a reversed one. -695 * @return true if backward scan, false if forward(default) scan -696 */ -697 public boolean isReversed() { -698 return reversed; -699 } -700 -701 /** -702 * Setting whether the caller wants to see the partial results that may be returned from the -703 * server. By default this value is false and the complete results will be assembled client side -704 * before being delivered to the caller. -705 * @param allowPartialResults -706 * @return this -707 */ -708 public Scan setAllowPartialResults(final boolean allowPartialResults) { -709 this.allowPartialResults = allowPartialResults; -710 return this; -711 } -712 -713 /** -714 * @return true when the constructor of this scan understands that the results they will see may -715 * only represent a partial portion of a row. The entire row would be retrieved by -716 * subsequent calls to {@link ResultScanner#next()} +676 public Scan setCacheBlocks(boolean cacheBlocks) { +677 this.cacheBlocks = cacheBlocks; +678 return this; +679 } +680 +681 /** +682 * Get whether blocks should be cached for this Scan. +683 * @return true if default caching should be used, false if blocks should not +684 * be cached +685 */ +686 public boolean getCacheBlocks() { +687 return cacheBlocks; +688 } +689 +690 /** +691 * Set whether this scan is a reversed one +692 * <p> +693 * This is false by default which means forward(normal) scan. +694 * +695 * @param reversed if true, scan will be backward order +696 * @return this +697 */ +698 public Scan setReversed(boolean reversed) { +699 this.reversed = reversed; +700 return this; +701 } +702 +703 /** +704 * Get whether this scan is a reversed one. +705 * @return true if backward scan, false if forward(default) scan +706 */ +707 public boolean isReversed() { +708 return reversed; +709 } +710 +711 /** +712 * Setting whether the caller wants to see the partial results that may be returned from the +713 * server. By default this value is false and the complete results will be assembled client side +714 * before being delivered to the caller. +715 * @param allowPartialResults +716 * @return this 717 */ -718 public boolean getAllowPartialResults() { -719 return allowPartialResults; -720 } -721 -722 /** -723 * Set the value indicating whether loading CFs on demand should be allowed (cluster -724 * default is false). On-demand CF loading doesn't load column families until necessary, e.g. -725 * if you filter on one column, the other column family data will be loaded only for the rows -726 * that are included in result, not all rows like in normal case. -727 * With column-specific filters, like SingleColumnValueFilter w/filterIfMissing == true, -728 * this can deliver huge perf gains when there's a cf with lots of data; however, it can -729 * also lead to some inconsistent results, as follows: -730 * - if someone does a concurrent update to both column families in question you may get a row -731 * that never existed, e.g. for { rowKey = 5, { cat_videos =&gt; 1 }, { video =&gt; "my cat" } } -732 * someone puts rowKey 5 with { cat_videos =&gt; 0 }, { video =&gt; "my dog" }, concurrent scan -733 * filtering on "cat_videos == 1" can get { rowKey = 5, { cat_videos =&gt; 1 }, -734 * { video =&gt; "my dog" } }. -735 * - if there's a concurrent split and you have more than 2 column families, some rows may be -736 * missing some column families. -737 */ -738 public Scan setLoadColumnFamiliesOnDemand(boolean value) { -739 this.loadColumnFamiliesOnDemand = value; -740 return this; -741 } -742 -743 /** -744 * Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null. -745 */ -746 public Boolean getLoadColumnFamiliesOnDemandValue() { -747 return this.loadColumnFamiliesOnDemand; -748 } -749 -750 /** -751 * Get the logical value indicating whether on-demand CF loading should be allowed. -752 */ -753 public boolean doLoadColumnFamiliesOnDemand() { -754 return (this.loadColumnFamiliesOnDemand != null) -755 && this.loadColumnFamiliesOnDemand.booleanValue(); -756 } -757 -758 /** -759 * Compile the table and column family (i.e. schema) information -760 * into a String. Useful for parsing and aggregation by debugging, -761 * logging, and administration tools. -762 * @return Map -763 */ -764