Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
nblintao committed Feb 10, 2022
1 parent 486ca41 commit 8d15e58
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ endif()
add_subdirectory(fdbbackup)
add_subdirectory(contrib)
add_subdirectory(tests)
add_subdirectory(flowbench EXCLUDE_FROM_ALL)
#add_subdirectory(flowbench EXCLUDE_FROM_ALL)
if(WITH_PYTHON AND WITH_C_BINDING)
add_subdirectory(bindings)
endif()
Expand Down
1 change: 1 addition & 0 deletions bindings/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(JAVA_BINDING_SRCS
src/main/com/apple/foundationdb/JNIUtil.java
src/main/com/apple/foundationdb/KeySelector.java
src/main/com/apple/foundationdb/KeyValue.java
src/main/com/apple/foundationdb/KeyValueAndMappedReqAndResult.java
src/main/com/apple/foundationdb/LocalityUtil.java
src/main/com/apple/foundationdb/NativeFuture.java
src/main/com/apple/foundationdb/NativeObjectWrapper.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public interface RangeQueryWithIndex {
RangeQueryWithIndex rangeQueryAndFlatMap = (int begin, int end, Database db) -> db.run(tr -> {
try {
tr.options().setReadYourWritesDisable();
List<KeyValue> kvs =
List<KeyValueAndMappedReqAndResult> kvs =
tr.snapshot()
.getRangeAndFlatMap(KeySelector.firstGreaterOrEqual(indexEntryKey(begin)),
KeySelector.firstGreaterOrEqual(indexEntryKey(end)), MAPPER,
Expand Down Expand Up @@ -221,7 +221,7 @@ void rangeAndFlatMapQueryOverMultipleRows() throws Exception {
tr.options().setReadYourWritesDisable();

// getRangeAndFlatMap is only supported with snapshot.
Iterator<KeyValue> kvs =
Iterator<KeyValueAndMappedReqAndResult> kvs =
tr.snapshot()
.getRangeAndFlatMap(KeySelector.firstGreaterOrEqual(indexEntryKey(0)),
KeySelector.firstGreaterThan(indexEntryKey(1)), MAPPER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public CompletableFuture<KeyArrayResult> getRangeSplitPoints(Range range, long c
}

@Override
public AsyncIterable<KeyValue> getRangeAndFlatMap(KeySelector begin, KeySelector end, byte[] mapper, int limit,
boolean reverse, StreamingMode mode) {
public AsyncIterable<KeyValueAndMappedReqAndResult> getRangeAndFlatMap(KeySelector begin, KeySelector end,
byte[] mapper, int limit,
boolean reverse, StreamingMode mode) {
if (mapper == null) {
throw new IllegalArgumentException("Mapper must be non-null");
}
Expand Down Expand Up @@ -348,8 +349,9 @@ public CompletableFuture<KeyArrayResult> getRangeSplitPoints(Range range, long c
}

@Override
public AsyncIterable<KeyValue> getRangeAndFlatMap(KeySelector begin, KeySelector end, byte[] mapper, int limit,
boolean reverse, StreamingMode mode) {
public AsyncIterable<KeyValueAndMappedReqAndResult> getRangeAndFlatMap(KeySelector begin, KeySelector end,
byte[] mapper, int limit, boolean reverse,
StreamingMode mode) {
throw new UnsupportedOperationException("getRangeAndFlatMap is only supported in snapshot");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* KeyValue.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.apple.foundationdb;

import java.util.Objects;

public class KeyValueAndMappedReqAndResult extends KeyValue {
interface MappedReqAndResult {}

static class GetValueReqAndResult implements MappedReqAndResult {
// Value is nullable, which meaning the key does not exist.
private KeyValue keyValue; // Nonnull

public GetValueReqAndResult(KeyValue keyValue) { this.keyValue = keyValue; }

public KeyValue getKeyValue() { return keyValue; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GetValueReqAndResult that = (GetValueReqAndResult)o;
return keyValue.equals(that.keyValue);
}

@Override
public int hashCode() {
return Objects.hash(keyValue);
}
}

static class GetRangeReqAndResult implements MappedReqAndResult {
private RangeResult result; // Nonnull

public GetRangeReqAndResult(RangeResult result) { this.result = result; }

public RangeResult getResult() { return result; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GetRangeReqAndResult that = (GetRangeReqAndResult)o;
return result.equals(that.result);
}

@Override
public int hashCode() {
return Objects.hash(result);
}
}

MappedReqAndResult mappedReqAndResult; // Nonnull

public KeyValueAndMappedReqAndResult(byte[] key, // Nonnull
byte[] value, // Nullable
MappedReqAndResult mappedReqAndResult // Nonnull
) {
super(key, value);
this.mappedReqAndResult = mappedReqAndResult;
}

public MappedReqAndResult getMappedReqAndResult() { return mappedReqAndResult; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
KeyValueAndMappedReqAndResult that = (KeyValueAndMappedReqAndResult)o;
return mappedReqAndResult.equals(that.mappedReqAndResult);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), mappedReqAndResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ AsyncIterable<KeyValue> getRange(Range range,
* </p>
* @return a handle to access the results of the asynchronous call
*/
AsyncIterable<KeyValue> getRangeAndFlatMap(KeySelector begin, KeySelector end, byte[] mapper, int limit,
boolean reverse, StreamingMode mode);
AsyncIterable<KeyValueAndMappedReqAndResult> getRangeAndFlatMap(KeySelector begin, KeySelector end, byte[] mapper,
int limit, boolean reverse, StreamingMode mode);

/**
* Gets an estimate for the number of bytes stored in the given range.
Expand Down
2 changes: 1 addition & 1 deletion cmake/CompileBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if(WIN32)
return()
endif()

find_package(Boost 1.78.0 EXACT QUIET COMPONENTS context CONFIG PATHS ${BOOST_HINT_PATHS})
find_package(Boost 1.76.0 EXACT QUIET COMPONENTS context CONFIG PATHS ${BOOST_HINT_PATHS})
set(FORCE_BOOST_BUILD OFF CACHE BOOL "Forces cmake to build boost and ignores any installed boost")

if(Boost_FOUND AND NOT FORCE_BOOST_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion cmake/FDBComponents.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ else()
find_package(Java 1.8 COMPONENTS Development)
# leave FreeBSD JVM compat for later
if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND AND NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") AND WITH_C_BINDING)
set(WITH_JAVA_BINDING ON)
# set(WITH_JAVA_BINDING ON)
include(UseJava)
enable_language(Java)
else()
Expand Down

0 comments on commit 8d15e58

Please sign in to comment.