/** * Returns a Range that covers all rows beginning with a prefix. * * @param rowPrefix * prefix of rows to cover */ public static Range prefix(Text rowPrefix) { Text fp = followingPrefix(rowPrefix); return new Range(new Key(rowPrefix), true, fp == null ? null : new Key(fp), false); }
/** * Returns a Range that covers all column families beginning with a prefix within a given row. * * @param row * row to cover * @param cfPrefix * prefix of column families to cover */ public static Range prefix(Text row, Text cfPrefix) { Text fp = followingPrefix(cfPrefix); return new Range(new Key(row, cfPrefix), true, fp == null ? new Key(row).followingKey(PartialKey.ROW) : new Key(row, fp), false); }
/** * Returns a Range that covers all column qualifiers beginning with a prefix within a given row * and column family. * * @param row * row to cover * @param cf * column family to cover * @param cqPrefix * prefix of column qualifiers to cover */ public static Range prefix(Text row, Text cf, Text cqPrefix) { Text fp = followingPrefix(cqPrefix); return new Range(new Key(row, cf, cqPrefix), true, fp == null ? new Key(row, cf).followingKey(PartialKey.ROW_COLFAM) : new Key(row, cf, fp), false); }
/** * Returns a Range that covers all column visibilities beginning with a prefix within a given row, * column family, and column qualifier. * * @param row * row to cover * @param cf * column family to cover * @param cq * column qualifier to cover * @param cvPrefix * prefix of column visibilities to cover */ public static Range prefix(Text row, Text cf, Text cq, Text cvPrefix) { Text fp = followingPrefix(cvPrefix); return new Range(new Key(row, cf, cq, cvPrefix), true, fp == null ? new Key(row, cf, cq).followingKey(PartialKey.ROW_COLFAM_COLQUAL) : new Key(row, cf, cq, fp), false); }
@Override public Range getRange(final KeyParts keyParts) { final Text start = Range.followingPrefix(keyParts.getQueryKey()); // <-- specific logic Text endAt = null; // no constraints // <-- specific logic if (keyParts.constraintPrefix != null ) { endAt = Range.followingPrefix(keyParts.constraintPrefix); } //System.out.println("Scanning queryInstantAfterInstant from after:" + KeyParts.toHumanString(start) + " up to:" + KeyParts.toHumanString(endAt)); return new Range(start, true, endAt, false); } };
@Override public Range getRange(final KeyParts keyParts) { final Text start = Range.followingPrefix(keyParts.getQueryKey()); // <-- specific logic Text endAt = null; // no constraints // <-- specific logic if (keyParts.constraintPrefix != null ) { endAt = Range.followingPrefix(keyParts.constraintPrefix); } //System.out.println("Scanning queryInstantAfterInstant from after:" + KeyParts.toHumanString(start) + " up to:" + KeyParts.toHumanString(endAt)); return new Range(start, true, endAt, false); } };
/** * Makes each input term into a prefix range. * "v1,v5," => "v1,:,v1\255,v5,:,v5\255," */ public static String singletonsAsPrefix(Collection<Text> vktexts, char sep) { StringBuilder sb = new StringBuilder(); for (Text vktext : vktexts) { sb.append(vktext.toString()).append(sep) .append(':').append(sep) .append(prevRow(Range.followingPrefix(new Text(vktext)).toString())) .append(sep); } return sb.toString(); }
Text after = Range.followingPrefix(pt); return prefix + sep + ':' + sep + after.toString() + sep; } else {
@Override public Range getRange(final KeyParts keyParts) { final Text start = Range.followingPrefix(new Text(keyParts.getQueryKey(queryInterval.getHasBeginning()))); final Text endAt = new Text(keyParts.getQueryKey(queryInterval.getHasEnd())); // <-- end specific logic //System.out.println("Scanning queryInstantInsideInterval: from excluding:" + KeyParts.toHumanString(start) + " up to:" + KeyParts.toHumanString(endAt)); return new Range(start, false, endAt, false); } };
@Override public Range getRange(final KeyParts keyParts) { final Text start = Range.followingPrefix(new Text(keyParts.getQueryKey(queryInterval.getHasBeginning()))); final Text endAt = new Text(keyParts.getQueryKey(queryInterval.getHasEnd())); // <-- end specific logic //System.out.println("Scanning queryInstantInsideInterval: from excluding:" + KeyParts.toHumanString(start) + " up to:" + KeyParts.toHumanString(endAt)); return new Range(start, false, endAt, false); } };
sb.append(vktext).append(sep) .append(':').append(sep) .append(prevRow(Range.followingPrefix(new Text(vktext)).toString())) .append(sep);
/** * Interval after given interval. Find intervals that begin after the endings of the given interval. * Use the special following prefix mechanism to avoid matching the beginning date. * Indexing Intervals will probably change or be removed. * Currently predicate and subject and context constraints are filtered on the client. */ @Override public CloseableIteration<Statement, QueryEvaluationException> queryIntervalAfter( final TemporalInterval queryInterval, final StatementConstraints constraints) throws QueryEvaluationException { final Scanner scanner = getScanner(); if (scanner != null) { // get rows where the start date is greater than the queryInterval.getEnd() final Range range = new Range(new Key(Range.followingPrefix(new Text(queryInterval.getHasEnd().getAsKeyBytes()))), false, null, true); scanner.setRange(range); if (constraints.hasContext()) { scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_BEGIN)); } else { scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_BEGIN)); } } // TODO currently predicate, subject and context constraints are filtered on the clients return getIteratorWrapper(scanner); } // --
/** * Interval after given interval. Find intervals that begin after the endings of the given interval. * Use the special following prefix mechanism to avoid matching the beginning date. * Indexing Intervals will probably change or be removed. * Currently predicate and subject and context constraints are filtered on the client. */ @Override public CloseableIteration<Statement, QueryEvaluationException> queryIntervalAfter( final TemporalInterval queryInterval, final StatementConstraints constraints) throws QueryEvaluationException { final Scanner scanner = getScanner(); if (scanner != null) { // get rows where the start date is greater than the queryInterval.getEnd() final Range range = new Range(new Key(Range.followingPrefix(new Text(queryInterval.getHasEnd().getAsKeyBytes()))), false, null, true); scanner.setRange(range); if (constraints.hasContext()) { scanner.fetchColumn(new Text(constraints.getContext().toString()), new Text(KeyParts.CQ_BEGIN)); } else { scanner.fetchColumn(new Text(""), new Text(KeyParts.CQ_BEGIN)); } } // TODO currently predicate, subject and context constraints are filtered on the clients return getIteratorWrapper(scanner); } // --
/** * Returns a Range that covers all rows beginning with a prefix. * * @param rowPrefix * prefix of rows to cover */ public static Range prefix(Text rowPrefix) { Text fp = followingPrefix(rowPrefix); return new Range(new Key(rowPrefix), true, fp == null ? null : new Key(fp), false); }
true, Range.followingPrefix(degColumnText).toString(), false); bs.addScanIterator(itset);
/** * Pad a range with a prefix, so the new range points to entries * that begin with the prefix and then satisfy the original range. * Only uses the Row field of the original Range; discards the rest. * @param pre The prefix * @param rold The original Range * @return New Range of the prefix plus the original */ public static Range prependPrefixToRange(String pre, Range rold) { if (pre == null || pre.isEmpty()) return rold; if (rold.isInfiniteStopKey() && rold.isInfiniteStartKey()) return Range.prefix(pre); if (rold.isInfiniteStartKey()) return new Range(pre, true, pre+normalizeEndRow(rold), true); if (rold.isInfiniteStopKey()) return new Range(pre+normalizeStartRow(rold), true, Range.followingPrefix(new Text(pre)).toString(), false); return new Range(pre+normalizeStartRow(rold), true, pre+normalizeEndRow(rold), true); }
/** * Returns a Range that covers all column families beginning with a prefix within a given row. * * @param row * row to cover * @param cfPrefix * prefix of column families to cover */ public static Range prefix(Text row, Text cfPrefix) { Text fp = followingPrefix(cfPrefix); return new Range(new Key(row, cfPrefix), true, fp == null ? new Key(row).followingKey(PartialKey.ROW) : new Key(row, fp), false); }
/** * Returns a Range that covers all column qualifiers beginning with a prefix within a given row * and column family. * * @param row * row to cover * @param cf * column family to cover * @param cqPrefix * prefix of column qualifiers to cover */ public static Range prefix(Text row, Text cf, Text cqPrefix) { Text fp = followingPrefix(cqPrefix); return new Range(new Key(row, cf, cqPrefix), true, fp == null ? new Key(row, cf).followingKey(PartialKey.ROW_COLFAM) : new Key(row, cf, fp), false); }
/** * Returns a Range that covers all column visibilities beginning with a prefix within a given row, * column family, and column qualifier. * * @param row * row to cover * @param cf * column family to cover * @param cq * column qualifier to cover * @param cvPrefix * prefix of column visibilities to cover */ public static Range prefix(Text row, Text cf, Text cq, Text cvPrefix) { Text fp = followingPrefix(cvPrefix); return new Range(new Key(row, cf, cq, cvPrefix), true, fp == null ? new Key(row, cf, cq).followingKey(PartialKey.ROW_COLFAM_COLQUAL) : new Key(row, cf, cq, fp), false); }
if (singletonsArePrefix) rngset.add(com.google.common.collect.Range.closedOpen( stringToByteSequence(pi.peekFirst()), stringToByteSequence(Range.followingPrefix(new Text(pi.peekFirst())).toString()) )); else if (singletonsArePrefix) rngset.add(com.google.common.collect.Range.closedOpen( stringToByteSequence(pi.peekFirst()), stringToByteSequence(Range.followingPrefix(new Text(pi.peekFirst())).toString()) )); else