Skip to content

Commit c77bc5f

Browse files
committed
rebase fallout
1 parent fe90cdc commit c77bc5f

File tree

2 files changed

+0
-151
lines changed

2 files changed

+0
-151
lines changed

fdb-extensions/src/main/java/com/apple/foundationdb/async/MoreAsyncUtil.java

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,93 +1144,6 @@ public static <T, U> CompletableFuture<List<U>> forEach(@Nonnull final Iterable<
11441144
}, executor).thenApply(ignored -> Arrays.asList((U[])resultArray));
11451145
}
11461146

1147-
/**
1148-
* Method that provides the functionality of a for loop, however, in an asynchronous way. The result of this method
1149-
* is a {@link CompletableFuture} that represents the result of the last iteration of the loop body.
1150-
* @param startI an integer analogous to the starting value of a loop variable in a for loop
1151-
* @param startU an object of some type {@code U} that represents some initial state that is passed to the loop's
1152-
* initial state
1153-
* @param conditionPredicate a predicate on the loop variable that must be true before the next iteration is
1154-
* entered; analogous to the condition in a for loop
1155-
* @param stepFunction a unary operator used for modifying the loop variable after each iteration
1156-
* @param body a bi-function to be called for each iteration; this function is initially invoked using
1157-
* {@code startI} and {@code startU}; the result of the body is then passed into the next iterator's body
1158-
* together with a new value for the loop variable. In this way callers can access state inside an iteration
1159-
* that was computed in a previous iteration.
1160-
* @param executor the executor
1161-
* @param <U> the type of the result of the body {@link BiFunction}
1162-
* @return a {@link CompletableFuture} containing the result of the last iteration's body invocation.
1163-
*/
1164-
@Nonnull
1165-
public static <U> CompletableFuture<U> forLoop(final int startI, @Nullable final U startU,
1166-
@Nonnull final IntPredicate conditionPredicate,
1167-
@Nonnull final IntUnaryOperator stepFunction,
1168-
@Nonnull final BiFunction<Integer, U, CompletableFuture<U>> body,
1169-
@Nonnull final Executor executor) {
1170-
final AtomicInteger loopVariableAtomic = new AtomicInteger(startI);
1171-
final AtomicReference<U> lastResultAtomic = new AtomicReference<>(startU);
1172-
return whileTrue(() -> {
1173-
final int loopVariable = loopVariableAtomic.get();
1174-
if (!conditionPredicate.test(loopVariable)) {
1175-
return AsyncUtil.READY_FALSE;
1176-
}
1177-
return body.apply(loopVariable, lastResultAtomic.get())
1178-
.thenApply(result -> {
1179-
loopVariableAtomic.set(stepFunction.applyAsInt(loopVariable));
1180-
lastResultAtomic.set(result);
1181-
return true;
1182-
});
1183-
}, executor).thenApply(ignored -> lastResultAtomic.get());
1184-
}
1185-
1186-
/**
1187-
* Method to iterate over some items, for each of which a body is executed asynchronously. The result of each such
1188-
* executed is then collected in a list and returned as a {@link CompletableFuture} over that list.
1189-
* @param items the items to iterate over
1190-
* @param body a function to be called for each item
1191-
* @param parallelism the maximum degree of parallelism this method should use
1192-
* @param executor the executor
1193-
* @param <T> the type of item
1194-
* @param <U> the type of the result
1195-
* @return a {@link CompletableFuture} containing a list of results collected from the individual body invocations
1196-
*/
1197-
@Nonnull
1198-
@SuppressWarnings("unchecked")
1199-
public static <T, U> CompletableFuture<List<U>> forEach(@Nonnull final Iterable<T> items,
1200-
@Nonnull final Function<T, CompletableFuture<U>> body,
1201-
final int parallelism,
1202-
@Nonnull final Executor executor) {
1203-
// this deque is only modified by once upon creation
1204-
final ArrayDeque<T> toBeProcessed = new ArrayDeque<>();
1205-
for (final T item : items) {
1206-
toBeProcessed.addLast(item);
1207-
}
1208-
1209-
final List<CompletableFuture<Void>> working = Lists.newArrayList();
1210-
final AtomicInteger indexAtomic = new AtomicInteger(0);
1211-
final Object[] resultArray = new Object[toBeProcessed.size()];
1212-
1213-
return whileTrue(() -> {
1214-
working.removeIf(CompletableFuture::isDone);
1215-
1216-
while (working.size() <= parallelism) {
1217-
final T currentItem = toBeProcessed.pollFirst();
1218-
if (currentItem == null) {
1219-
break;
1220-
}
1221-
1222-
final int index = indexAtomic.getAndIncrement();
1223-
working.add(body.apply(currentItem)
1224-
.thenAccept(result -> resultArray[index] = result));
1225-
}
1226-
1227-
if (working.isEmpty()) {
1228-
return AsyncUtil.READY_FALSE;
1229-
}
1230-
return whenAny(working).thenApply(ignored -> true);
1231-
}, executor).thenApply(ignored -> Arrays.asList((U[])resultArray));
1232-
}
1233-
12341147
/**
12351148
* A {@code Boolean} function that is always true.
12361149
* @param <T> the type of the (ignored) argument to the function

fdb-extensions/src/main/java/com/apple/foundationdb/half/HalfConstants.java

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -62,67 +62,3 @@ private HalfConstants() {
6262
/* Hidden Constructor */
6363
}
6464
}
65-
/*
66-
* Copyright 2023 Christian Heina
67-
*
68-
* Licensed under the Apache License, Version 2.0 (the "License");
69-
* you may not use this file except in compliance with the License.
70-
* You may obtain a copy of the License at
71-
*
72-
* http://www.apache.org/licenses/LICENSE-2.0
73-
*
74-
* Unless required by applicable law or agreed to in writing, software
75-
* distributed under the License is distributed on an "AS IS" BASIS,
76-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77-
* See the License for the specific language governing permissions and
78-
* limitations under the License.
79-
*
80-
* Modifications Copyright 2015-2025 Apple Inc. and the FoundationDB project authors.
81-
* This source file is part of the FoundationDB open source project
82-
*/
83-
84-
package com.apple.foundationdb.half;
85-
86-
/**
87-
* This class contains additional constants documenting limits of {@code Half}.
88-
* <p>
89-
* {@code HalfConstants} is implemented to provide, as much as possible, the same interface as
90-
* {@code jdk.internal.math.FloatConsts}.
91-
*
92-
* @author Christian Heina ([email protected])
93-
*/
94-
public class HalfConstants {
95-
/**
96-
* The number of logical bits in the significand of a {@code half} number, including the implicit bit.
97-
*/
98-
public static final int SIGNIFICAND_WIDTH = 11;
99-
100-
/**
101-
* The exponent the smallest positive {@code half} subnormal value would have if it could be normalized.
102-
*/
103-
public static final int MIN_SUB_EXPONENT = Half.MIN_EXPONENT - (SIGNIFICAND_WIDTH - 1);
104-
105-
/**
106-
* Bias used in representing a {@code half} exponent.
107-
*/
108-
public static final int EXP_BIAS = 15;
109-
110-
/**
111-
* Bit mask to isolate the sign bit of a {@code half}.
112-
*/
113-
public static final int SIGN_BIT_MASK = 0x8000;
114-
115-
/**
116-
* Bit mask to isolate the exponent field of a {@code half}.
117-
*/
118-
public static final int EXP_BIT_MASK = 0x7C00;
119-
120-
/**
121-
* Bit mask to isolate the significand field of a {@code half}.
122-
*/
123-
public static final int SIGNIF_BIT_MASK = 0x03FF;
124-
125-
private HalfConstants() {
126-
/* Hidden Constructor */
127-
}
128-
}

0 commit comments

Comments
 (0)