forked from apache/paimon
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Introduce VectoredReadable to SeekableInputStream (apache#3369)
- Loading branch information
1 parent
8791c5d
commit 245cbad
Showing
13 changed files
with
1,562 additions
and
61 deletions.
There are no files selected for viewing
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
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
83 changes: 83 additions & 0 deletions
83
paimon-common/src/main/java/org/apache/paimon/fs/FileRange.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,83 @@ | ||
/* | ||
* 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.paimon.fs; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/* This file is based on source code from the Hadoop Project (http://hadoop.apache.org/), licensed by the Apache | ||
* Software Foundation (ASF) under the Apache License, Version 2.0. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. */ | ||
|
||
/** A byte range of a file. */ | ||
public interface FileRange { | ||
|
||
/** Get the starting offset of the range. */ | ||
long getOffset(); | ||
|
||
/** Get the length of the range. */ | ||
int getLength(); | ||
|
||
/** Get the future data for this range. */ | ||
CompletableFuture<byte[]> getData(); | ||
|
||
/** | ||
* Factory method to create a FileRange object. | ||
* | ||
* @param offset starting offset of the range. | ||
* @param length length of the range. | ||
* @return a new instance of FileRangeImpl. | ||
*/ | ||
static FileRange createFileRange(long offset, int length) { | ||
return new FileRangeImpl(offset, length); | ||
} | ||
|
||
/** An implementation for {@link FileRange}. */ | ||
class FileRangeImpl implements FileRange { | ||
|
||
private final long offset; | ||
private final int length; | ||
private final CompletableFuture<byte[]> reader; | ||
|
||
public FileRangeImpl(long offset, int length) { | ||
this.offset = offset; | ||
this.length = length; | ||
this.reader = new CompletableFuture<>(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "range[" + offset + "," + (offset + length) + ")"; | ||
} | ||
|
||
@Override | ||
public long getOffset() { | ||
return offset; | ||
} | ||
|
||
@Override | ||
public int getLength() { | ||
return length; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<byte[]> getData() { | ||
return reader; | ||
} | ||
} | ||
} |
Oops, something went wrong.