Search in sources :

Example 1 with EndpointType

use of com.apple.foundationdb.record.EndpointType in project fdb-record-layer by FoundationDB.

the class KeySpaceDirectory method getValueRange.

@Nonnull
private CompletableFuture<KeyRange> getValueRange(@Nonnull FDBRecordContext context, @Nullable ValueRange<?> valueRange, @Nonnull Subspace subspace) {
    final byte[] startKey;
    final byte[] stopKey;
    final EndpointType startType;
    final EndpointType stopType;
    if (getValue() == KeySpaceDirectory.ANY_VALUE) {
        if (valueRange != null && valueRange.getLowEndpoint() != EndpointType.TREE_START) {
            if (KeyType.typeOf(valueRange.getLow()) != getKeyType()) {
                throw invalidValueTypeException(KeyType.typeOf(valueRange.getLow()), getKeyType(), getName(), valueRange);
            }
            startKey = subspace.pack(valueRange.getLow());
            startType = valueRange.getLowEndpoint();
            if (startType != EndpointType.RANGE_INCLUSIVE && startType != EndpointType.RANGE_EXCLUSIVE) {
                throw new RecordCoreArgumentException("Endpoint type not supported for directory list", LogMessageKeys.ENDPOINT_TYPE, startType);
            }
        } else {
            final byte[] subspaceBytes = subspace.pack();
            startKey = new byte[subspaceBytes.length + 1];
            System.arraycopy(subspaceBytes, 0, startKey, 0, subspaceBytes.length);
            startKey[subspaceBytes.length] = getKeyType().getTypeLowBounds();
            startType = EndpointType.RANGE_INCLUSIVE;
        }
        if (valueRange != null && valueRange.getHighEndpoint() != EndpointType.TREE_END) {
            if (KeyType.typeOf(valueRange.getHigh()) != getKeyType()) {
                throw invalidValueTypeException(KeyType.typeOf(valueRange.getHigh()), getKeyType(), getName(), valueRange);
            }
            stopKey = subspace.pack(valueRange.getHigh());
            stopType = valueRange.getHighEndpoint();
            if (stopType != EndpointType.RANGE_INCLUSIVE && stopType != EndpointType.RANGE_EXCLUSIVE) {
                throw new RecordCoreArgumentException("Endpoint type not supported for directory list", LogMessageKeys.ENDPOINT_TYPE, stopType);
            }
        } else {
            final byte[] subspaceBytes = subspace.pack();
            stopKey = new byte[subspaceBytes.length + 1];
            System.arraycopy(subspaceBytes, 0, stopKey, 0, subspaceBytes.length);
            stopKey[subspaceBytes.length] = getKeyType().getTypeHighBounds();
            stopType = EndpointType.RANGE_EXCLUSIVE;
        }
        return CompletableFuture.completedFuture(new KeyRange(startKey, startType, stopKey, stopType));
    } else {
        if (valueRange != null) {
            throw new RecordCoreArgumentException("range is not applicable when the subdirectory has a value.", LogMessageKeys.DIR_NAME, getName(), LogMessageKeys.RANGE, valueRange);
        }
        return toTupleValueAsync(context, this.value).thenApply(resolvedValue -> {
            final byte[] key = subspace.pack(Tuple.from(resolvedValue.getResolvedValue()));
            return new KeyRange(key, EndpointType.RANGE_INCLUSIVE, ByteArrayUtil.strinc(key), EndpointType.RANGE_EXCLUSIVE);
        });
    }
}
Also used : KeyRange(com.apple.foundationdb.record.KeyRange) EndpointType(com.apple.foundationdb.record.EndpointType) RecordCoreArgumentException(com.apple.foundationdb.record.RecordCoreArgumentException) Nonnull(javax.annotation.Nonnull)

Example 2 with EndpointType

use of com.apple.foundationdb.record.EndpointType in project fdb-record-layer by FoundationDB.

the class KeySpaceDirectoryTest method listRangeTestCases.

private List<Pair<ValueRange<Object>, List<Tuple>>> listRangeTestCases(List<Tuple> values) {
    values.sort(null);
    // Size >= 1. It is very likely to be 5 (but can be smaller) expect when the key type is NULL or BOOLEAN.
    int size = values.size();
    List<Pair<ValueRange<Object>, List<Tuple>>> testCases = new LinkedList<>();
    testCases.add(Pair.of(null, new ArrayList<>(values)));
    testCases.add(newTestCase(values.get(0), null, EndpointType.RANGE_INCLUSIVE, EndpointType.TREE_END, new ArrayList<>(values)));
    testCases.add(newTestCase(values.get(0), null, EndpointType.RANGE_EXCLUSIVE, EndpointType.TREE_END, new ArrayList<>(values.subList(1, size))));
    testCases.add(newTestCase(null, values.get(size - 1), EndpointType.TREE_START, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values)));
    testCases.add(newTestCase(null, values.get(size - 1), EndpointType.TREE_START, EndpointType.RANGE_EXCLUSIVE, new ArrayList<>(values.subList(0, size - 1))));
    testCases.add(newTestCase(null, null, EndpointType.TREE_START, EndpointType.TREE_END, new ArrayList<>(values)));
    testCases.add(newTestCase(values.get(0), values.get(0), EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values.subList(0, 1))));
    // Only test this for LONG because it might be tricky to modify values for some other types.
    if (KeyType.LONG.isMatch(values.get(0))) {
        Tuple first = values.get(0);
        Tuple justBeforeFirst = Tuple.from((Long) first.get(0) - 1);
        Tuple justAfterFirst = Tuple.from((Long) first.get(0) + 1);
        Tuple last = values.get(size - 1);
        Tuple justBeforeLast = Tuple.from((Long) last.get(0) - 1);
        Tuple justAfterLast = Tuple.from((Long) last.get(0) + 1);
        // Endpoint type does not matters to the values who are not in the collection.
        for (EndpointType endpointType : Arrays.asList(EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_EXCLUSIVE)) {
            testCases.add(newTestCase(justBeforeFirst, null, endpointType, EndpointType.TREE_END, new ArrayList<>(values.subList(0, size))));
            testCases.add(newTestCase(justAfterFirst, null, endpointType, EndpointType.TREE_END, new ArrayList<>(values.subList(1, size))));
            testCases.add(newTestCase(null, justBeforeLast, EndpointType.TREE_START, endpointType, new ArrayList<>(values.subList(0, size - 1))));
            testCases.add(newTestCase(null, justAfterLast, EndpointType.TREE_START, endpointType, new ArrayList<>(values.subList(0, size))));
        }
    }
    if (size >= 2) {
        Tuple first = values.get(0);
        Tuple last = values.get(size - 1);
        testCases.add(newTestCase(first, last, EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values.subList(0, size))));
        testCases.add(newTestCase(first, last, EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_EXCLUSIVE, new ArrayList<>(values.subList(0, size - 1))));
        testCases.add(newTestCase(first, last, EndpointType.RANGE_EXCLUSIVE, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values.subList(1, size))));
        testCases.add(newTestCase(first, last, EndpointType.RANGE_EXCLUSIVE, EndpointType.RANGE_EXCLUSIVE, new ArrayList<>(values.subList(1, size - 1))));
    }
    if (size >= 4) {
        Tuple second = values.get(1);
        Tuple secondLast = values.get(size - 2);
        testCases.add(newTestCase(second, secondLast, EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values.subList(1, size - 1))));
        testCases.add(newTestCase(second, secondLast, EndpointType.RANGE_INCLUSIVE, EndpointType.RANGE_EXCLUSIVE, new ArrayList<>(values.subList(1, size - 2))));
        testCases.add(newTestCase(second, secondLast, EndpointType.RANGE_EXCLUSIVE, EndpointType.RANGE_INCLUSIVE, new ArrayList<>(values.subList(2, size - 1))));
        testCases.add(newTestCase(second, secondLast, EndpointType.RANGE_EXCLUSIVE, EndpointType.RANGE_EXCLUSIVE, new ArrayList<>(values.subList(2, size - 2))));
    }
    return testCases;
}
Also used : ArrayList(java.util.ArrayList) EndpointType(com.apple.foundationdb.record.EndpointType) Tuple(com.apple.foundationdb.tuple.Tuple) LinkedList(java.util.LinkedList) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with EndpointType

use of com.apple.foundationdb.record.EndpointType in project fdb-record-layer by FoundationDB.

the class FDBRecordStore method scanTypedRecords.

@Nonnull
public <M extends Message> RecordCursor<FDBStoredRecord<M>> scanTypedRecords(@Nonnull RecordSerializer<M> typedSerializer, @Nullable final Tuple low, @Nullable final Tuple high, @Nonnull final EndpointType lowEndpoint, @Nonnull final EndpointType highEndpoint, @Nullable byte[] continuation, @Nonnull ScanProperties scanProperties) {
    final RecordMetaData metaData = metaDataProvider.getRecordMetaData();
    final Subspace recordsSubspace = recordsSubspace();
    final SplitHelper.SizeInfo sizeInfo = new SplitHelper.SizeInfo();
    final RecordCursor<FDBRawRecord> rawRecords;
    if (metaData.isSplitLongRecords()) {
        RecordCursor<KeyValue> keyValues = KeyValueCursor.Builder.withSubspace(recordsSubspace).setContext(context).setContinuation(continuation).setLow(low, lowEndpoint).setHigh(high, highEndpoint).setScanProperties(scanProperties.with(ExecuteProperties::clearRowAndTimeLimits).with(ExecuteProperties::clearState)).build();
        rawRecords = new SplitHelper.KeyValueUnsplitter(context, recordsSubspace, keyValues, useOldVersionFormat(), sizeInfo, scanProperties.isReverse(), new CursorLimitManager(context, scanProperties.with(ExecuteProperties::clearReturnedRowLimit))).skip(scanProperties.getExecuteProperties().getSkip()).limitRowsTo(scanProperties.getExecuteProperties().getReturnedRowLimit());
    } else {
        KeyValueCursor.Builder keyValuesBuilder = KeyValueCursor.Builder.withSubspace(recordsSubspace).setContext(context).setContinuation(continuation).setLow(low, lowEndpoint).setHigh(high, highEndpoint);
        if (omitUnsplitRecordSuffix) {
            rawRecords = keyValuesBuilder.setScanProperties(scanProperties).build().map(kv -> {
                sizeInfo.set(kv);
                Tuple primaryKey = SplitHelper.unpackKey(recordsSubspace, kv);
                return new FDBRawRecord(primaryKey, kv.getValue(), null, sizeInfo);
            });
        } else {
            final ScanProperties finalScanProperties = scanProperties.with(executeProperties -> {
                final ExecuteProperties.Builder builder = executeProperties.toBuilder().clearTimeLimit().clearSkipAndAdjustLimit().clearState();
                int returnedRowLimit = builder.getReturnedRowLimitOrMax();
                if (returnedRowLimit != Integer.MAX_VALUE) {
                    // Adjust limit to twice the supplied limit in case there are versions in the records
                    builder.setReturnedRowLimit(2 * returnedRowLimit);
                }
                return builder.build();
            });
            rawRecords = new SplitHelper.KeyValueUnsplitter(context, recordsSubspace, keyValuesBuilder.setScanProperties(finalScanProperties).build(), useOldVersionFormat(), sizeInfo, scanProperties.isReverse(), new CursorLimitManager(context, scanProperties.with(ExecuteProperties::clearReturnedRowLimit))).skip(scanProperties.getExecuteProperties().getSkip()).limitRowsTo(scanProperties.getExecuteProperties().getReturnedRowLimit());
        }
    }
    RecordCursor<FDBStoredRecord<M>> result = rawRecords.mapPipelined(rawRecord -> {
        final Optional<CompletableFuture<FDBRecordVersion>> versionFutureOptional;
        if (useOldVersionFormat()) {
            // Older format versions: do a separate read to get the version.
            versionFutureOptional = loadRecordVersionAsync(rawRecord.getPrimaryKey(), scanProperties.getExecuteProperties().getIsolationLevel().isSnapshot());
        } else {
            // Newer format versions: the version is either in the record or it is not -- do not do another read.
            versionFutureOptional = Optional.empty();
        }
        return deserializeRecord(typedSerializer, rawRecord, metaData, versionFutureOptional);
    }, pipelineSizer.getPipelineSize(PipelineOperation.KEY_TO_RECORD));
    return context.instrument(FDBStoreTimer.Events.SCAN_RECORDS, result);
}
Also used : LogMessageKeys(com.apple.foundationdb.record.logging.LogMessageKeys) UnaryOperator(java.util.function.UnaryOperator) MetaDataException(com.apple.foundationdb.record.metadata.MetaDataException) RecordSerializer(com.apple.foundationdb.record.provider.common.RecordSerializer) Subspace(com.apple.foundationdb.subspace.Subspace) MutationType(com.apple.foundationdb.MutationType) RecordCoreException(com.apple.foundationdb.record.RecordCoreException) Map(java.util.Map) RecordIndexUniquenessViolation(com.apple.foundationdb.record.RecordIndexUniquenessViolation) QueryToKeyMatcher(com.apple.foundationdb.record.query.QueryToKeyMatcher) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Query(com.apple.foundationdb.record.query.expressions.Query) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) Set(java.util.Set) TupleRange(com.apple.foundationdb.record.TupleRange) KeySpacePath(com.apple.foundationdb.record.provider.foundationdb.keyspace.KeySpacePath) ByteOrder(java.nio.ByteOrder) SyntheticRecordType(com.apple.foundationdb.record.metadata.SyntheticRecordType) RecordMetaDataProvider(com.apple.foundationdb.record.RecordMetaDataProvider) RecordStoreState(com.apple.foundationdb.record.RecordStoreState) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) API(com.apple.foundationdb.annotation.API) FunctionNames(com.apple.foundationdb.record.FunctionNames) RecordMetaData(com.apple.foundationdb.record.RecordMetaData) IndexAggregateFunction(com.apple.foundationdb.record.metadata.IndexAggregateFunction) AsyncUtil(com.apple.foundationdb.async.AsyncUtil) RecordQuery(com.apple.foundationdb.record.query.RecordQuery) RangeSet(com.apple.foundationdb.async.RangeSet) RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) Supplier(java.util.function.Supplier) FormerIndex(com.apple.foundationdb.record.metadata.FormerIndex) ArrayList(java.util.ArrayList) ByteScanLimiter(com.apple.foundationdb.record.ByteScanLimiter) ParameterRelationshipGraph(com.apple.foundationdb.record.query.ParameterRelationshipGraph) LoggableException(com.apple.foundationdb.util.LoggableException) CloseableAsyncIterator(com.apple.foundationdb.async.CloseableAsyncIterator) IndexRecordFunction(com.apple.foundationdb.record.metadata.IndexRecordFunction) Nullable(javax.annotation.Nullable) ByteArrayUtil2(com.apple.foundationdb.tuple.ByteArrayUtil2) IsolationLevel(com.apple.foundationdb.record.IsolationLevel) CursorLimitManager(com.apple.foundationdb.record.cursors.CursorLimitManager) ExecuteState(com.apple.foundationdb.record.ExecuteState) AtomicLong(java.util.concurrent.atomic.AtomicLong) RecordType(com.apple.foundationdb.record.metadata.RecordType) Index(com.apple.foundationdb.record.metadata.Index) DynamicMessageRecordSerializer(com.apple.foundationdb.record.provider.common.DynamicMessageRecordSerializer) SyntheticRecordPlanner(com.apple.foundationdb.record.query.plan.synthetic.SyntheticRecordPlanner) IndexEntry(com.apple.foundationdb.record.IndexEntry) LoggerFactory(org.slf4j.LoggerFactory) RecordCoreStorageException(com.apple.foundationdb.record.RecordCoreStorageException) ByteBuffer(java.nio.ByteBuffer) RecordQueryPlanner(com.apple.foundationdb.record.query.plan.RecordQueryPlanner) Transaction(com.apple.foundationdb.Transaction) Tuple(com.apple.foundationdb.tuple.Tuple) Range(com.apple.foundationdb.Range) KeyValueLogMessage(com.apple.foundationdb.record.logging.KeyValueLogMessage) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordMetaDataProto(com.apple.foundationdb.record.RecordMetaDataProto) ByteArrayUtil(com.apple.foundationdb.tuple.ByteArrayUtil) KeyValue(com.apple.foundationdb.KeyValue) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IndexQueryabilityFilter(com.apple.foundationdb.record.query.IndexQueryabilityFilter) AndComponent(com.apple.foundationdb.record.query.expressions.AndComponent) RecordCoreArgumentException(com.apple.foundationdb.record.RecordCoreArgumentException) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) List(java.util.List) EvaluationContext(com.apple.foundationdb.record.EvaluationContext) AggregateFunctionNotSupportedException(com.apple.foundationdb.record.AggregateFunctionNotSupportedException) RecordTypeKeyComparison(com.apple.foundationdb.record.query.expressions.RecordTypeKeyComparison) IndexTypes(com.apple.foundationdb.record.metadata.IndexTypes) Optional(java.util.Optional) MutableRecordStoreState(com.apple.foundationdb.record.MutableRecordStoreState) RecordTypeOrBuilder(com.apple.foundationdb.record.metadata.RecordTypeOrBuilder) SyntheticRecordFromStoredRecordPlan(com.apple.foundationdb.record.query.plan.synthetic.SyntheticRecordFromStoredRecordPlan) SpotBugsSuppressWarnings(com.apple.foundationdb.annotation.SpotBugsSuppressWarnings) Descriptors(com.google.protobuf.Descriptors) AsyncIterator(com.apple.foundationdb.async.AsyncIterator) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) CursorStreamingMode(com.apple.foundationdb.record.CursorStreamingMode) Key(com.apple.foundationdb.record.metadata.Key) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) Suppliers(com.google.common.base.Suppliers) LinkedList(java.util.LinkedList) Nonnull(javax.annotation.Nonnull) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) MoreAsyncUtil(com.apple.foundationdb.async.MoreAsyncUtil) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) IndexState(com.apple.foundationdb.record.IndexState) StoreRecordFunction(com.apple.foundationdb.record.metadata.StoreRecordFunction) ReadTransaction(com.apple.foundationdb.ReadTransaction) AsyncIterable(com.apple.foundationdb.async.AsyncIterable) FDBRecordStoreStateCache(com.apple.foundationdb.record.provider.foundationdb.storestate.FDBRecordStoreStateCache) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) QueryComponent(com.apple.foundationdb.record.query.expressions.QueryComponent) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) RecordMetaData(com.apple.foundationdb.record.RecordMetaData) KeyValue(com.apple.foundationdb.KeyValue) CursorLimitManager(com.apple.foundationdb.record.cursors.CursorLimitManager) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) CompletableFuture(java.util.concurrent.CompletableFuture) ScanProperties(com.apple.foundationdb.record.ScanProperties) Subspace(com.apple.foundationdb.subspace.Subspace) Tuple(com.apple.foundationdb.tuple.Tuple) Nonnull(javax.annotation.Nonnull)

Example 4 with EndpointType

use of com.apple.foundationdb.record.EndpointType in project fdb-record-layer by FoundationDB.

the class RankedSetIndexHelper method rankRangeToScoreRange.

@Nonnull
public static CompletableFuture<TupleRange> rankRangeToScoreRange(@Nonnull IndexMaintainerState state, int groupPrefixSize, @Nonnull Subspace rankSubspace, @Nonnull RankedSet.Config config, @Nonnull TupleRange rankRange) {
    final Tuple prefix = groupPrefix(groupPrefixSize, rankRange, rankSubspace);
    if (prefix != null) {
        rankSubspace = rankSubspace.subspace(prefix);
    }
    // Map low and high ranks to scores and scan main index with those.
    Number lowRankNum = extractRank(groupPrefixSize, rankRange.getLow());
    boolean startFromBeginning = lowRankNum == null || lowRankNum.longValue() < 0L;
    EndpointType lowEndpoint = startFromBeginning ? EndpointType.RANGE_INCLUSIVE : rankRange.getLowEndpoint();
    Number highRankNum = extractRank(groupPrefixSize, rankRange.getHigh());
    EndpointType highEndpoint = rankRange.getHighEndpoint();
    if (highRankNum != null && (highRankNum.longValue() < 0L || highEndpoint == EndpointType.RANGE_EXCLUSIVE && highRankNum.longValue() == 0L)) {
        // This range is below 0, so we know the range is empty without having to look.
        return CompletableFuture.completedFuture(null);
    }
    if (highRankNum != null && highEndpoint == EndpointType.RANGE_EXCLUSIVE && lowEndpoint == EndpointType.RANGE_EXCLUSIVE && highRankNum.equals(lowRankNum)) {
        // This range is exclusively empty.
        return CompletableFuture.completedFuture(null);
    }
    if (startFromBeginning && highRankNum == null) {
        // Scanning whole range, no need to convert any ranks.
        return CompletableFuture.completedFuture(TupleRange.allOf(prefix));
    }
    final RankedSet rankedSet = new InstrumentedRankedSet(state, rankSubspace, config);
    return init(state, rankedSet).thenCompose(v -> {
        CompletableFuture<Tuple> lowScoreFuture = scoreForRank(state, rankedSet, startFromBeginning ? 0L : lowRankNum, null);
        CompletableFuture<Tuple> highScoreFuture = scoreForRank(state, rankedSet, highRankNum, null);
        return lowScoreFuture.thenCombine(highScoreFuture, (lowScore, highScore) -> {
            // from low until the end.
            if (lowScore == null) {
                return null;
            }
            EndpointType adjustedHighEndpoint = highScore != null ? highEndpoint : prefix != null ? EndpointType.RANGE_INCLUSIVE : EndpointType.TREE_END;
            TupleRange scoreRange = new TupleRange(lowScore, highScore, lowEndpoint, adjustedHighEndpoint);
            if (prefix != null) {
                scoreRange = scoreRange.prepend(prefix);
            }
            return scoreRange;
        });
    });
}
Also used : EndpointType(com.apple.foundationdb.record.EndpointType) RankedSet(com.apple.foundationdb.async.RankedSet) TupleRange(com.apple.foundationdb.record.TupleRange) Tuple(com.apple.foundationdb.tuple.Tuple) Nonnull(javax.annotation.Nonnull)

Example 5 with EndpointType

use of com.apple.foundationdb.record.EndpointType in project fdb-record-layer by FoundationDB.

the class TimeWindowLeaderboardIndexMaintainer method negateScoreRange.

/**
 * Negate the score part of the given range, which is after the group prefix and before the timestamp and any
 * other tiebreakers.
 * @param range the range of scores in normal order
 * @return a range with scores negated so that they sort in reverse order
 */
protected TupleRange negateScoreRange(@Nonnull TupleRange range) {
    final int groupPrefixSize = getGroupingCount();
    Tuple low = range.getLow();
    Tuple high = range.getHigh();
    EndpointType lowEndpoint = range.getLowEndpoint();
    EndpointType highEndpoint = range.getHighEndpoint();
    if (low == null || low.size() < groupPrefixSize) {
        if (lowEndpoint == EndpointType.TREE_START) {
            lowEndpoint = EndpointType.TREE_END;
        }
    } else {
        low = negateScoreForHighScoreFirst(low, groupPrefixSize);
    }
    if (high == null || high.size() < groupPrefixSize) {
        if (lowEndpoint == EndpointType.TREE_END) {
            lowEndpoint = EndpointType.TREE_START;
        }
    } else {
        high = negateScoreForHighScoreFirst(high, groupPrefixSize);
    }
    return new TupleRange(high, low, highEndpoint, lowEndpoint);
}
Also used : EndpointType(com.apple.foundationdb.record.EndpointType) TupleRange(com.apple.foundationdb.record.TupleRange) Tuple(com.apple.foundationdb.tuple.Tuple)

Aggregations

EndpointType (com.apple.foundationdb.record.EndpointType)5 Tuple (com.apple.foundationdb.tuple.Tuple)4 TupleRange (com.apple.foundationdb.record.TupleRange)3 Nonnull (javax.annotation.Nonnull)3 RecordCoreArgumentException (com.apple.foundationdb.record.RecordCoreArgumentException)2 KeyValue (com.apple.foundationdb.KeyValue)1 MutationType (com.apple.foundationdb.MutationType)1 Range (com.apple.foundationdb.Range)1 ReadTransaction (com.apple.foundationdb.ReadTransaction)1 Transaction (com.apple.foundationdb.Transaction)1 API (com.apple.foundationdb.annotation.API)1 SpotBugsSuppressWarnings (com.apple.foundationdb.annotation.SpotBugsSuppressWarnings)1 AsyncIterable (com.apple.foundationdb.async.AsyncIterable)1 AsyncIterator (com.apple.foundationdb.async.AsyncIterator)1 AsyncUtil (com.apple.foundationdb.async.AsyncUtil)1 CloseableAsyncIterator (com.apple.foundationdb.async.CloseableAsyncIterator)1 MoreAsyncUtil (com.apple.foundationdb.async.MoreAsyncUtil)1 RangeSet (com.apple.foundationdb.async.RangeSet)1 RankedSet (com.apple.foundationdb.async.RankedSet)1 AggregateFunctionNotSupportedException (com.apple.foundationdb.record.AggregateFunctionNotSupportedException)1