Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-11 15:18:24 +0000
committerMatthew Khouzam2013-12-11 16:32:48 +0000
commit4517bf2a5bdc355ba2dad9921e5606a4f210a4aa (patch)
tree091ed70f52444c7de6cd1963e147a33fbc90357a
parentfc9d8c3290b28f27fdf26b4a6846411ab3a4704d (diff)
downloadorg.eclipse.linuxtools-4517bf2a5bdc355ba2dad9921e5606a4f210a4aa.tar.gz
org.eclipse.linuxtools-4517bf2a5bdc355ba2dad9921e5606a4f210a4aa.tar.xz
org.eclipse.linuxtools-4517bf2a5bdc355ba2dad9921e5606a4f210a4aa.zip
ctf: isolate the abstraction of memory map byte-buffer.
The concept of the memory map mechanism should not be exposed outside the StreamInput. This is internal to StreamInput. The API should exposed : give me a byte buffer (I don't care how). Change-Id: I832d2776845a07173f4ef7cb47fd9c75c7db73bf Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Reviewed-on: https://git.eclipse.org/r/19652 IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java9
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java21
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java8
3 files changed, 11 insertions, 27 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java
index f9d0c79a75..8a7c877233 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java
@@ -69,15 +69,6 @@ public class StreamInputTest {
}
/**
- * Run the FileChannel getFileChannel() method test.
- */
- @Test
- public void testGetFileChannel() {
- FileChannel result = fixture.getFileChannel();
- assertNull(result);
- }
-
- /**
* Run the String getFilename() method test.
*/
@Test
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
index 3ee9963ed4..dc982605d3 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
@@ -14,7 +14,7 @@ package org.eclipse.linuxtools.ctf.core.trace;
import java.io.File;
import java.io.IOException;
-import java.nio.MappedByteBuffer;
+import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.UUID;
@@ -125,15 +125,6 @@ public class StreamInput implements IDefinitionScope {
}
/**
- * Gets the filechannel of the streamInput. This is a limited Java resource.
- *
- * @return the filechannel
- */
- public FileChannel getFileChannel() {
- return fileChannel;
- }
-
- /**
* Gets the filename of the streamInput file.
*
* @return the filename of the streaminput file.
@@ -299,6 +290,10 @@ public class StreamInput implements IDefinitionScope {
+ ((packetIndex.getPacketSizeBits() + 7) / 8);
}
+ ByteBuffer getByteBufferAt(long position, long size) throws IOException {
+ return fileChannel.map(MapMode.READ_ONLY, position, size);
+ }
+
/**
* @param fileSizeBytes
* @param packetOffsetBytes
@@ -307,7 +302,7 @@ public class StreamInput implements IDefinitionScope {
* @return
* @throws CTFReaderException
*/
- private MappedByteBuffer createPacketBitBuffer(long fileSizeBytes,
+ private ByteBuffer createPacketBitBuffer(long fileSizeBytes,
long packetOffsetBytes, StreamInputPacketIndexEntry packetIndex,
BitBuffer bitBuffer) throws CTFReaderException {
/*
@@ -328,10 +323,10 @@ public class StreamInput implements IDefinitionScope {
/*
* Map the packet.
*/
- MappedByteBuffer bb;
+ ByteBuffer bb;
try {
- bb = fileChannel.map(MapMode.READ_ONLY, packetOffsetBytes, mapSize);
+ bb = getByteBufferAt(packetOffsetBytes, mapSize);
} catch (IOException e) {
throw new CTFReaderException(e);
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
index f0a5d46bbf..1e01df9666 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
@@ -12,8 +12,7 @@
package org.eclipse.linuxtools.ctf.core.trace;
import java.io.IOException;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel.MapMode;
+import java.nio.ByteBuffer;
import java.util.Collection;
import org.eclipse.linuxtools.ctf.core.CTFStrings;
@@ -216,10 +215,9 @@ public class StreamInputPacketReader implements IDefinitionScope {
/*
* Change the map of the BitBuffer.
*/
- MappedByteBuffer bb = null;
+ ByteBuffer bb = null;
try {
- bb = streamInputReader.getStreamInput().getFileChannel()
- .map(MapMode.READ_ONLY,
+ bb = streamInputReader.getStreamInput().getByteBufferAt(
this.currentPacket.getOffsetBytes(),
(this.currentPacket.getPacketSizeBits() + 7) / 8);
} catch (IOException e) {

Back to the top