Skip to content

Commit

Permalink
Integrate Metadata Support
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Spörri <psp@zurich.ibm.com>
  • Loading branch information
pspoerri committed Apr 19, 2023
1 parent cea4a88 commit d1ec64e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/com/ibm/geds/hdfs/GEDSInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public GEDSInputStream(GEDSFile file) {
this.tmpbuffer = ByteBuffer.allocate(8);
}

public String metadata() throws IOException {
return file.metadata();
}

public byte[] metadataAsByteArray() throws IOException {
return file.metadataAsByteArray();
}

private long position = 0;
private ByteBuffer tmpbuffer;

Expand Down
34 changes: 33 additions & 1 deletion src/main/java/com/ibm/geds/hdfs/GEDSOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,38 @@ public GEDSOutputStream(GEDSFile file) {
this.file = file;
}

public String metadata() throws IOException {
return file.metadata();
}

public byte[] metadataAsByteArray() throws IOException {
return file.metadataAsByteArray();
}

public void setMetadata(String metadata) throws IOException {
setMetadata(metadata, true);
}

public void setMetadata(String metadata, boolean seal) throws IOException {
file.setMetadata(metadata, seal);
}

public void setMetadata(ByteBuffer buffer) throws IOException {
setMetadata(buffer, true);
}

public void setMetadata(ByteBuffer buffer, boolean seal) throws IOException {
file.setMetadata(buffer, seal);
}

public void setMetadata(byte[] buffer, int offset, int length) throws IOException {
setMetadata(buffer, offset, length, true);
}

public void setMetadata(byte[] buffer, int offset, int length, boolean seal) throws IOException {
file.setMetadata(buffer, offset, length, seal);
}

private void checkOpen() throws IOException {
if (file.isClosed()) {
throw new EOFException("The file is already closed!");
Expand All @@ -33,7 +65,7 @@ private void checkOpen() throws IOException {
public void write(int b) throws IOException {
synchronized (this) {
checkOpen();
singleByteBuffer[0] =(byte) b;
singleByteBuffer[0] = (byte) b;
file.write(position, singleByteBuffer, 0, 1);
position += 1;
}
Expand Down

0 comments on commit d1ec64e

Please sign in to comment.