You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/10/28 16:26:59 UTC
[1/2] incubator-mnemonic git commit: MNEMONIC-106: Define the
interface of durable in-memory stream
Repository: incubator-mnemonic
Updated Branches:
refs/heads/master 2cec8e9b1 -> fe50f5f2c
MNEMONIC-106: Define the interface of durable in-memory stream
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/c2fd54aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/c2fd54aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/c2fd54aa
Branch: refs/heads/master
Commit: c2fd54aa1d32692a5c44b7ce112b8176259580ad
Parents: 2cec8e9
Author: Xiaojin Jiao <xj...@gmail.com>
Authored: Fri Oct 28 06:06:04 2016 +0000
Committer: Xiaojin Jiao <xj...@gmail.com>
Committed: Fri Oct 28 06:06:04 2016 +0000
----------------------------------------------------------------------
.../java/org/apache/mnemonic/MemStream.java | 126 ++++++++++++++-----
1 file changed, 97 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/c2fd54aa/mnemonic-core/src/main/java/org/apache/mnemonic/MemStream.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/MemStream.java b/mnemonic-core/src/main/java/org/apache/mnemonic/MemStream.java
index f9c1424..134cccd 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/MemStream.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/MemStream.java
@@ -17,51 +17,119 @@
package org.apache.mnemonic;
-import java.io.File;
-
/**
- * a memory file that manages its data on native memory storage. Note: this
- * class depends on PMFS, we suggest that NVM library to support this feature in
- * native layer. In addition, the permission of /mnt/pmfs will be set properly.
- *
+ * This interface to randomly access the in-memory stream.
*
*/
-public class MemStream extends File {
+public interface MemStream {
+
+ /**
+ * This function will close the stream and release any
+ * system resources associated with the stream.
+ *
+ */
+ void close();
+
+ /**
+ * This function retrieves the current offset in this in-memory stream.
+ *
+ * @return the long-type offset value
+ */
+ long getPosition();
- private static final long serialVersionUID = 6579668848729471173L;
- private String uri, id;
+ /**
+ * This function returns the length of this in-memory stream.
+ *
+ * @return the long-type length
+ */
+ long length();
/**
- * initialize the memory file.
+ * This function reads a byte of data from the stream.
*
- * @param uri
- * specify the location of memory file
+ * @return the 1-byte of data, or -1 if reaching the end of stream
+ */
+ int read();
+
+ /**
+ * This function reads up to b.length bytes of data from the stream into
+ * an array of bytes
*
- * @param id
- * specify the id of memory file
+ * @param b
+ * array of bytes into which data is read
+ * @return the total number of bytes read into the array, or -1 if
+ * reaching the end of streamint-type data of one byte
*/
- public MemStream(String uri, String id) {
- super(uri, id);
- this.uri = uri;
- this.id = id;
- }
+ int read(byte[] b);
+
/**
- * retrieve the uri of this memory file.
+ * This function reads up to len bytes of data from the stream into
+ * an array of bytes
*
- * @return the uri of memory file
+ * @param b
+ * array of bytes into which data is read
+ * @param off
+ * the start offset in array b at which the data is written
+ * @param len
+ * the maximum number of bytes read
+ *
+ * @return the total number of bytes read into the array, or -1 if
+ * reaching the end of streamint-type data of one byte
+ */
+
+ int read(byte[] b, int off, int len);
+
+ /**
+ * More read functions can be added, such as readDouble, readLine and so on
+ *
+ */
+
+ /**
+ * This function sets the mem-pointer offset, measured from the beginning
+ * of the stream, which is the starting position for the next read
+ * or write
+ *
+ * @param pos
+ * the offset position, measured from the beginning of the
+ * mem stream
+ * @return the new offset, or -1 if the offset is longer than the length of the mem stream
+ */
+ long seek(long pos);
+
+ /**
+ * This function writes b.length bytes from an array of bytes
+ *
+ * @param b
+ * array of bytes
+ */
+ void write(byte[] b);
+
+ /**
+ * This function writes len bytes from an array of bytes
+ * starting from offset off
+ *
+ * @param b
+ * array of bytes
+ * @param off
+ * the starting offset in array b at which the data is read
+ * @param len
+ * the maximum number of bytes to write
*/
- public String getUri() {
- return this.uri;
- }
+ void write(byte[] b, int off, int len);
/**
- * retrieve the id of this memory file.
+ * This function write byte b into the mem stream
+ *
+ * @param b
+ * the data
*
- * @return the id of memory file
*/
- public String getId() {
- return this.id;
- }
+ void write(int b);
+
+ /**
+ * More write functions can be added
+ *
+ */
}
[2/2] incubator-mnemonic git commit: Merge pull request #28 from
xjjiao/master
Posted by ga...@apache.org.
Merge pull request #28 from xjjiao/master
MNEMONIC-106: Define the interface of durable in-memory stream
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/fe50f5f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/fe50f5f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/fe50f5f2
Branch: refs/heads/master
Commit: fe50f5f2cf8ca1d81a07a7b9082ce26fb7bd38fe
Parents: 2cec8e9 c2fd54a
Author: Wang, Gang <qi...@gmail.com>
Authored: Fri Oct 28 09:22:15 2016 -0700
Committer: GitHub <no...@github.com>
Committed: Fri Oct 28 09:22:15 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/mnemonic/MemStream.java | 126 ++++++++++++++-----
1 file changed, 97 insertions(+), 29 deletions(-)
----------------------------------------------------------------------