forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-35161][state] Refactor ForStGeneralMultiGetOperation and ForSt…
…WriteBatchOperation
- Loading branch information
Showing
8 changed files
with
279 additions
and
120 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...link-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStDBGetRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.flink.state.forst; | ||
|
||
import org.apache.flink.core.state.InternalStateFuture; | ||
|
||
import org.rocksdb.ColumnFamilyHandle; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The Get access request for ForStDB. | ||
* | ||
* @param <K> The type of key in get access request. | ||
* @param <V> The type of value returned by get request. | ||
*/ | ||
public class ForStDBGetRequest<K, V> { | ||
|
||
private final K key; | ||
private final ForStInnerTable<K, V> table; | ||
private final InternalStateFuture<V> future; | ||
|
||
private ForStDBGetRequest(K key, ForStInnerTable<K, V> table, InternalStateFuture<V> future) { | ||
this.key = key; | ||
this.table = table; | ||
this.future = future; | ||
} | ||
|
||
public byte[] buildSerializedKey() throws IOException { | ||
return table.serializeKey(key); | ||
} | ||
|
||
public ColumnFamilyHandle getColumnFamilyHandle() { | ||
return table.getColumnFamilyHandle(); | ||
} | ||
|
||
public void completeStateFuture(byte[] bytesValue) throws IOException { | ||
if (bytesValue == null) { | ||
future.complete(null); | ||
return; | ||
} | ||
V value = table.deserializeValue(bytesValue); | ||
future.complete(value); | ||
} | ||
|
||
static <K, V> ForStDBGetRequest<K, V> of( | ||
K key, ForStInnerTable<K, V> table, InternalStateFuture<V> future) { | ||
return new ForStDBGetRequest<>(key, table, future); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...link-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStDBPutRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.flink.state.forst; | ||
|
||
import org.apache.flink.core.state.InternalStateFuture; | ||
|
||
import org.rocksdb.ColumnFamilyHandle; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The Put access request for ForStDB. | ||
* | ||
* @param <K> The type of key in put access request. | ||
* @param <V> The type of value in put access request. | ||
*/ | ||
public class ForStDBPutRequest<K, V> { | ||
|
||
private final K key; | ||
@Nullable private final V value; | ||
private final ForStInnerTable<K, V> table; | ||
private final InternalStateFuture<Void> future; | ||
|
||
private ForStDBPutRequest( | ||
K key, V value, ForStInnerTable<K, V> table, InternalStateFuture<Void> future) { | ||
this.key = key; | ||
this.value = value; | ||
this.table = table; | ||
this.future = future; | ||
} | ||
|
||
public boolean valueIsNull() { | ||
return value == null; | ||
} | ||
|
||
public ColumnFamilyHandle getColumnFamilyHandle() { | ||
return table.getColumnFamilyHandle(); | ||
} | ||
|
||
public byte[] buildSerializedKey() throws IOException { | ||
return table.serializeKey(key); | ||
} | ||
|
||
public byte[] buildSerializedValue() throws IOException { | ||
assert value != null; | ||
return table.serializeValue(value); | ||
} | ||
|
||
public void completeStateFuture() { | ||
future.complete(null); | ||
} | ||
|
||
/** | ||
* If the value of the ForStDBPutRequest is null, then the request will signify the deletion of | ||
* the data associated with that key. | ||
*/ | ||
static <K, V> ForStDBPutRequest<K, V> of( | ||
K key, | ||
@Nullable V value, | ||
ForStInnerTable<K, V> table, | ||
InternalStateFuture<Void> future) { | ||
return new ForStDBPutRequest<>(key, value, table, future); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.