Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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