org.apache.accumulo.core.data.Range.getStartKey()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.accumulo.core.data.Range.getStartKey方法的一些代码示例,展示了Range.getStartKey的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.getStartKey方法的具体详情如下:
包路径:org.apache.accumulo.core.data.Range
类名称:Range
方法名:getStartKey

Range.getStartKey介绍

[英]Gets the start key, or null if the start is negative infinity.
[中]获取开始键,如果开始为负无穷大,则为null。

代码示例

代码示例来源:origin: prestodb/presto

private Collection<Range> splitByTabletBoundaries(String tableName, Collection<Range> ranges)
    throws org.apache.accumulo.core.client.TableNotFoundException, AccumuloException, AccumuloSecurityException
{
  ImmutableSet.Builder<Range> rangeBuilder = ImmutableSet.builder();
  for (Range range : ranges) {
    // if start and end key are equivalent, no need to split the range
    if (range.getStartKey() != null && range.getEndKey() != null && range.getStartKey().equals(range.getEndKey())) {
      rangeBuilder.add(range);
    }
    else {
      // Call out to Accumulo to split the range on tablets
      rangeBuilder.addAll(connector.tableOperations().splitRangeByTablets(tableName, range, Integer.MAX_VALUE));
    }
  }
  return rangeBuilder.build();
}

代码示例来源:origin: prestodb/presto

private static boolean isExact(Range range)
{
  return !range.isInfiniteStartKey() && !range.isInfiniteStopKey() &&
      range.getStartKey().followingKey(PartialKey.ROW).equals(range.getEndKey());
}

代码示例来源:origin: prestodb/presto

tabletSplits.add(new TabletSplitMetadata(getTabletLocation(tableName, range.getStartKey()), ImmutableList.of(range)));

代码示例来源:origin: apache/accumulo

@Override
public Key transform(Range range) {
 if (isRangeInBloomFilter(range, PartialKey.ROW)) {
  return transform(range.getStartKey());
 }
 return null;
}

代码示例来源:origin: apache/accumulo

@Override
public Key transform(Range range) {
 if (RowFunctor.isRangeInBloomFilter(range, kDepth)) {
  return transform(range.getStartKey());
 }
 return null;
}

代码示例来源:origin: apache/accumulo

@Override
public Key transform(Range range) {
 if (RowFunctor.isRangeInBloomFilter(range, PartialKey.ROW_COLFAM_COLQUAL)) {
  return transform(range.getStartKey());
 }
 return null;
}

代码示例来源:origin: apache/accumulo

public static long getRangeLength(Range range) {
 Text startRow = range.isInfiniteStartKey() ? new Text(new byte[] {Byte.MIN_VALUE})
   : range.getStartKey().getRow();
 Text stopRow = range.isInfiniteStopKey() ? new Text(new byte[] {Byte.MAX_VALUE})
   : range.getEndKey().getRow();
 int maxCommon = Math.min(7, Math.min(startRow.getLength(), stopRow.getLength()));
 long diff = 0;
 byte[] start = startRow.getBytes();
 byte[] stop = stopRow.getBytes();
 for (int i = 0; i < maxCommon; ++i) {
  diff |= 0xff & (start[i] ^ stop[i]);
  diff <<= Byte.SIZE;
 }
 if (startRow.getLength() != stopRow.getLength())
  diff |= 0xff;
 return diff + 1;
}

代码示例来源:origin: apache/accumulo

static boolean isRangeInBloomFilter(Range range, PartialKey keyDepth) {

  if (range.getStartKey() == null || range.getEndKey() == null) {
   return false;
  }

  if (range.getStartKey().equals(range.getEndKey(), keyDepth))
   return true;

  // include everything but the deleted flag in the comparison...
  return range.getStartKey().followingKey(keyDepth).equals(range.getEndKey(),
    PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME) && !range.isEndKeyInclusive();
 }
}

代码示例来源:origin: apache/accumulo

public static Range maximizeStartKeyTimeStamp(Range range) {
 Range seekRange = range;
 if (range.getStartKey() != null) {
  Key seekKey = range.getStartKey();
  if (range.getStartKey().getTimestamp() != Long.MAX_VALUE) {
   seekKey = new Key(seekRange.getStartKey());
   seekKey.setTimestamp(Long.MAX_VALUE);
   seekRange = new Range(seekKey, true, range.getEndKey(), range.isEndKeyInclusive());
  } else if (!range.isStartKeyInclusive()) {
   seekRange = new Range(seekKey, true, range.getEndKey(), range.isEndKeyInclusive());
  }
 }
 return seekRange;
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 if (columnFamilies.size() != 0 || inclusive) {
  throw new IllegalArgumentException("I do not know how to filter column families");
 }
 if (range == null)
  throw new IllegalArgumentException("Cannot seek to null range");
 if (interruptFlag != null && interruptFlag.get())
  throw new IterationInterruptedException();
 Key key = range.getStartKey();
 if (key == null) {
  key = new Key();
 }
 reader.seek(key);
 while (hasTop() && range.beforeStartKey(getTopKey())) {
  next();
 }
}

代码示例来源:origin: apache/accumulo

private RowRange toClippedExtent(Range r) {
 r = clipRange.clip(r);
 Text startRow = removeTrailingZeroFromRow(r.getStartKey());
 Text endRow = removeTrailingZeroFromRow(r.getEndKey());
 return new RowRange(startRow, endRow);
}

代码示例来源:origin: apache/accumulo

public static Range minimizeEndKeyTimeStamp(Range range) {
 Range seekRange = range;
 if (range.getEndKey() != null) {
  Key seekKey = seekRange.getEndKey();
  if (range.getEndKey().getTimestamp() != Long.MIN_VALUE) {
   seekKey = new Key(seekRange.getEndKey());
   seekKey.setTimestamp(Long.MIN_VALUE);
   seekRange = new Range(range.getStartKey(), range.isStartKeyInclusive(), seekKey, true);
  } else if (!range.isEndKeyInclusive()) {
   seekRange = new Range(range.getStartKey(), range.isStartKeyInclusive(), seekKey, true);
  }
 }
 return seekRange;
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 // do not want to seek to the middle of a row
 Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
 source.seek(seekRange, columnFamilies, inclusive);
 findTop();
 if (range.getStartKey() != null) {
  while (source.hasTop() && source.getTopKey().compareTo(range.getStartKey(),
    PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME) < 0) {
   next();
  }
  while (hasTop() && range.beforeStartKey(getTopKey())) {
   next();
  }
 }
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 super.seek(range, columnFamilies, inclusive);
 if (hasTop())
  getTopKeyVal();
 Key k = range.getStartKey();
 if (k instanceof MemKey && hasTop()) {
  while (hasTop() && currKey.compareTo(k) < 0)
   next();
 }
}

代码示例来源:origin: apache/accumulo

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
  throws Exception {
 final String tableName = OptUtil.getTableOpt(cl, shellState);
 final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
 final Range range = getRange(cl, interpeter);
 final Authorizations auths = getAuths(cl, shellState);
 final Text startRow = range.getStartKey() == null ? null : range.getStartKey().getRow();
 final Text endRow = range.getEndKey() == null ? null : range.getEndKey().getRow();
 try {
  final Text max = shellState.getAccumuloClient().tableOperations().getMaxRow(tableName, auths,
    startRow, range.isStartKeyInclusive(), endRow, range.isEndKeyInclusive());
  if (max != null) {
   shellState.getReader().println(max.toString());
  }
 } catch (Exception e) {
  log.debug("Could not get shell state.", e);
 }
 return 0;
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 // do not want to seek to the middle of a row
 Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
 this.range = seekRange;
 this.columnFamilies = columnFamilies;
 this.inclusive = inclusive;
 super.seek(seekRange, columnFamilies, inclusive);
 resetVersionCount();
 if (range.getStartKey() != null)
  while (hasTop() && range.beforeStartKey(getTopKey()))
   next();
}

代码示例来源:origin: apache/accumulo

/**
 * Converts the given {@code Range} into the correct {@code Range} for this TermSource (per this
 * expected table structure) and then seeks this TermSource's SKVI.
 */
public void seek(Range originalRange) throws IOException {
 // the infinite start key is equivalent to a null startKey on the Range.
 if (!originalRange.isInfiniteStartKey()) {
  Key originalStartKey = originalRange.getStartKey();
  // Pivot the provided range into the range for this term
  Key newKey = new Key(originalStartKey.getRow(), term, originalStartKey.getColumnQualifier(),
    originalStartKey.getTimestamp());
  // Construct the new range, preserving the other attributes on the provided range.
  currentRange = new Range(newKey, originalRange.isStartKeyInclusive(),
    originalRange.getEndKey(), originalRange.isEndKeyInclusive());
 } else {
  currentRange = originalRange;
 }
 LOG.trace("Seeking {} to {}", this, currentRange);
 iter.seek(currentRange, seekColfams, true);
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 // save parameters for future internal seeks
 latestRange = range;
 latestColumnFamilies = columnFamilies;
 latestInclusive = inclusive;
 lastRowFound = null;
 Key startKey = range.getStartKey();
 Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow()), true,
   range.getEndKey(), range.isEndKeyInclusive());
 super.seek(seekRange, columnFamilies, inclusive);
 finished = false;
 if (getSource().hasTop()) {
  lastRowFound = getSource().getTopKey().getRow();
  if (range.beforeStartKey(getSource().getTopKey()))
   consume();
 }
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 topKey = null;
 topValue = null;
 Key sk = range.getStartKey();
 if (sk != null && sk.getColumnQualifierData().length() == 0
   && sk.getColumnVisibilityData().length() == 0 && sk.getTimestamp() == Long.MAX_VALUE
   && !range.isStartKeyInclusive()) {
  // assuming that we are seeking using a key previously returned by
  // this iterator
  // therefore go to the next row/cf
  Key followingRowKey = sk.followingKey(PartialKey.ROW_COLFAM);
  if (range.getEndKey() != null && followingRowKey.compareTo(range.getEndKey()) > 0)
   return;
  range = new Range(sk.followingKey(PartialKey.ROW_COLFAM), true, range.getEndKey(),
    range.isEndKeyInclusive());
 }
 sourceIter.seek(range, columnFamilies, inclusive);
 prepKeys();
}

代码示例来源:origin: apache/accumulo

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 topKey = null;
 topValue = null;
 Key sk = range.getStartKey();
 if (sk != null && sk.getColumnFamilyData().length() == 0
   && sk.getColumnQualifierData().length() == 0 && sk.getColumnVisibilityData().length() == 0
   && sk.getTimestamp() == Long.MAX_VALUE && !range.isStartKeyInclusive()) {
  // assuming that we are seeking using a key previously returned by this iterator
  // therefore go to the next row
  Key followingRowKey = sk.followingKey(PartialKey.ROW);
  if (range.getEndKey() != null && followingRowKey.compareTo(range.getEndKey()) > 0)
   return;
  range = new Range(sk.followingKey(PartialKey.ROW), true, range.getEndKey(),
    range.isEndKeyInclusive());
 }
 sourceIter.seek(range, columnFamilies, inclusive);
 prepKeys();
}

相关文章