/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object right_obj) { if (right_obj instanceof byte []) { return compareTo((byte [])right_obj) == 0; } if (right_obj instanceof ImmutableBytesWritable) { return compareTo((ImmutableBytesWritable)right_obj) == 0; } return false; }
/** * Verify that the result and key have expected values. * * @param r * @param key * @param expectedKey * @param expectedValue * @return */ static boolean checkResult(Result r, ImmutableBytesWritable key, byte[] expectedKey, byte[] expectedValue) { assertEquals(0, key.compareTo(expectedKey)); Map<byte[], byte[]> vals = r.getFamilyMap(FAMILY); byte[] value = vals.values().iterator().next(); assertTrue(Arrays.equals(value, expectedValue)); return true; // if succeed }
/** * Verify that the result and key have expected values. * * @param r * @param key * @param expectedKey * @param expectedValue * @return */ static boolean checkResult(Result r, ImmutableBytesWritable key, byte[] expectedKey, byte[] expectedValue) { assertEquals(0, key.compareTo(expectedKey)); Map<byte[], byte[]> vals = r.getFamilyMap(FAMILY); byte[] value = vals.values().iterator().next(); assertTrue(Arrays.equals(value, expectedValue)); return true; // if succeed }
@Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { try { // first, finish any hash batches that end before the scanned row while (nextSourceKey != null && key.compareTo(nextSourceKey) >= 0) { moveToNextBatch(context); } // next, add the scanned row (as long as we've reached the first batch) if (targetHasher.isBatchStarted()) { targetHasher.hashResult(value); } } catch (Throwable t) { mapperException = t; Throwables.propagateIfInstanceOf(t, IOException.class); Throwables.propagateIfInstanceOf(t, InterruptedException.class); Throwables.propagate(t); } }
@Override public int compareTo(JoinKey other) { for (int i = 0; i < keys.size(); i++) { int comp = this.keys.get(i).compareTo(other.keys.get(i)); if (comp != 0) return comp; } return 0; } }
@Override public int compareTo(TableRowkeyPair other) { String otherTableName = other.getTableName(); if(this.tableName.equals(otherTableName)) { return this.rowkey.compareTo(other.getRowkey()); } else { return this.tableName.compareTo(otherTableName); } }
private boolean continueAggregating(Tuple previous, Tuple next) { if (next == null) { return false; } next.getKey(currentKey); previous.getKey(previousKey); return (currentKey.compareTo(previousKey) == 0); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null) { return false; } if (o.getClass() != this.getClass()) { return false; } ResultEntry that = (ResultEntry) o; for (ColumnProjector column : rowProjector.getColumnProjectors()) { Expression e = column.getExpression(); boolean isNull1 = !e.evaluate(this.result, ptr1); boolean isNull2 = !e.evaluate(that.result, ptr2); if (isNull1 && isNull2) { return true; } if (isNull1 || isNull2) { return false; } if (ptr1.compareTo(ptr2) != 0) { return false; } } return true; }
@Override public boolean matchingFamily(KeyValue other) { if(other == null) { return false; } if(other instanceof ClientKeyValue) { ClientKeyValue kv = (ClientKeyValue)other; return this.family.compareTo(kv.family) == 0; } return matchingFamily(other.getBuffer(), other.getFamilyOffset(), other.getFamilyLength()); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o == null) { return false; } if (o.getClass() != this.getClass()) { return false; } ResultEntry that = (ResultEntry) o; for (ColumnProjector column : rowProjector.getColumnProjectors()) { Expression e = column.getExpression(); boolean isNull1 = !e.evaluate(this.result, ptr1); boolean isNull2 = !e.evaluate(that.result, ptr2); if (isNull1 && isNull2) { return true; } if (isNull1 || isNull2) { return false; } if (ptr1.compareTo(ptr2) != 0) { return false; } } return true; }
@Override public boolean matchingQualifier(KeyValue other) { if (other == null) { return false; } if (other instanceof ClientKeyValue) { ClientKeyValue kv = (ClientKeyValue) other; return this.row.compareTo(kv.row) == 0; } return matchingQualifier(other.getBuffer(), other.getQualifierOffset(), other.getQualifierLength()); }
/** * Track a new guide post * @param row number of rows in the guidepost * @param byteCount number of bytes in the guidepost * @param updateTimestamp time at which guidepost was created/updated. * @throws IOException */ public boolean trackGuidePost(ImmutableBytesWritable row, long byteCount, long rowCount, long updateTimestamp) { if (row.getLength() != 0 && lastRow.compareTo(row) < 0) { try { encoder.encode(output, row.get(), row.getOffset(), row.getLength()); rowCounts.add(rowCount); byteCounts.add(byteCount); guidePostsTimestamps.add(updateTimestamp); this.guidePostsCount++; this.maxLength = encoder.getMaxLength(); lastRow = row; return true; } catch (IOException e) { return false; } } return false; }
if (lowerPtr.compareTo(upperPtr) != 0) { if (newSlots != null) { newSlots.addAll(slots.subList(i+1, slots.size()));
@Override protected int compare(Tuple t1, Tuple t2) { for (int i = 0; i < orderByColumns.size(); i++) { OrderByExpression order = orderByColumns.get(i); Expression orderExpr = order.getExpression(); boolean isNull1 = !orderExpr.evaluate(t1, ptr1) || ptr1.getLength() == 0; boolean isNull2 = !orderExpr.evaluate(t2, ptr2) || ptr2.getLength() == 0; if (isNull1 && isNull2) { continue; } else if (isNull1) { return order.isNullsLast() ? 1 : -1; } else if (isNull2) { return order.isNullsLast() ? -1 : 1; } int cmp = ptr1.compareTo(ptr2); if (cmp == 0) { continue; } return order.isAscending() ? cmp : -cmp; } return 0; }
@Override protected int compare(Tuple t1, Tuple t2) { for (int i = 0; i < orderByColumns.size(); i++) { OrderByExpression order = orderByColumns.get(i); Expression orderExpr = order.getExpression(); boolean isNull1 = !orderExpr.evaluate(t1, ptr1) || ptr1.getLength() == 0; boolean isNull2 = !orderExpr.evaluate(t2, ptr2) || ptr2.getLength() == 0; if (isNull1 && isNull2) { continue; } else if (isNull1) { return order.isNullsLast() ? 1 : -1; } else if (isNull2) { return order.isNullsLast() ? -1 : 1; } int cmp = ptr1.compareTo(ptr2); if (cmp == 0) { continue; } return order.isAscending() ? cmp : -cmp; } return 0; }
result.setKeyValues(kvs); key = TupleUtil.getConcatenatedValue(result, expressions); aggBoundary = currentKey != null && currentKey.compareTo(key) != 0; if (!aggBoundary) { aggregators.aggregate(rowAggregators, result);
int c; while ((c=currentKey.compareTo(currentGuidePost = PrefixByteCodec.decode(decoder, input))) >= 0) { if (!gpsForFirstRegion && firstRegionStartKey.compareTo(currentGuidePost) <= 0) { gpsForFirstRegion = true; int gpsComparedToEndKey = -1; boolean everNotDelayed = false; while (intersectWithGuidePosts && (endKey.length == 0 || (gpsComparedToEndKey=currentGuidePost.compareTo(endKey)) <= 0)) { Scan newScan = scanRanges.intersectScan(scan, currentKeyBytes, currentGuidePostBytes, keyOffset, false); currentGuidePost.compareTo(endRegionKey) < 0) ) ); if (gpsAfterStopKey) {
@Override public int compareTo(TableRowkeyPair other) { String otherTableName = other.getTableName(); if(this.tableName.equals(otherTableName)) { return this.rowkey.compareTo(other.getRowkey()); } else { return this.tableName.compareTo(otherTableName); } }
private boolean continueAggregating(Tuple previous, Tuple next) { if (next == null) { return false; } next.getKey(currentKey); previous.getKey(previousKey); return (currentKey.compareTo(previousKey) == 0); }