blob: 6c5b60fab69e18e4f0cbfb42330967ec2ce3e246 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_121) on Wed Mar 29 10:00:26 PDT 2017 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>com.yahoo.memory (com.yahoo.datasketches:memory 0.9.9-SNAPSHOT API)</title>
<meta name="date" content="2017-03-29">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="com.yahoo.memory (com.yahoo.datasketches:memory 0.9.9-SNAPSHOT API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="../../../com/yahoo/memory/package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Package</li>
<li>Next&nbsp;Package</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/yahoo/memory/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package&nbsp;com.yahoo.memory</h1>
<div class="docSummary">
<div class="block">The goal of this package is to provide high performance access to native memory for primitives
and primitive arrays.</div>
</div>
<p>See:&nbsp;<a href="#package.description">Description</a></p>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation">
<caption><span>Interface Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/MemoryRequest.html" title="interface in com.yahoo.memory">MemoryRequest</a></td>
<td class="colLast">
<div class="block">The MemoryRequest is a callback interface provides a means for a WritableMemory object to
request more memory from the WritableMemoryDirectHandler.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/Buffer.html" title="class in com.yahoo.memory">Buffer</a></td>
<td class="colLast">
<div class="block">Provides read-only, positional primitive and primitive array methods to any of the four resources
mentioned in the package level documentation.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/Memory.html" title="class in com.yahoo.memory">Memory</a></td>
<td class="colLast">
<div class="block">Provides read-only primitive and primitive array methods to any of the four resources
mentioned in the package level documentation.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/MemoryMapHandler.html" title="class in com.yahoo.memory">MemoryMapHandler</a></td>
<td class="colLast">
<div class="block">Gets a Memory for a memory-mapped, read-only file resource, It is highly recommended that this be created inside a
<i>try-with-resources</i> statement.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/UnsafeUtil.html" title="class in com.yahoo.memory">UnsafeUtil</a></td>
<td class="colLast">
<div class="block">Provides access to the sun.misc.Unsafe class and its key static fields.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/WritableBuffer.html" title="class in com.yahoo.memory">WritableBuffer</a></td>
<td class="colLast">
<div class="block">Provides read and write, positional primitive and primitive array access to any of the four
resources mentioned at the package level.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/WritableMemory.html" title="class in com.yahoo.memory">WritableMemory</a></td>
<td class="colLast">
<div class="block">Provides read and write primitive and primitive array access to any of the four resources
mentioned at the package level.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/WritableMemoryDirectHandler.html" title="class in com.yahoo.memory">WritableMemoryDirectHandler</a></td>
<td class="colLast">
<div class="block">Gets a WritableMemory for a writable direct memory resource.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/WritableMemoryMapHandler.html" title="class in com.yahoo.memory">WritableMemoryMapHandler</a></td>
<td class="colLast">
<div class="block">Gets a WritableMemory for a writable memory-mapped file resource.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation">
<caption><span>Exception Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../com/yahoo/memory/ReadOnlyException.html" title="class in com.yahoo.memory">ReadOnlyException</a></td>
<td class="colLast">
<div class="block">The exception thrown when attempting to write into a read-only Resource.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<a name="package.description">
<!-- -->
</a>
<h2 title="Package com.yahoo.memory Description">Package com.yahoo.memory Description</h2>
<div class="block">The goal of this package is to provide high performance access to native memory for primitives
and primitive arrays. It also provides consistent views into heap-based arrays,
Java ByteBuffers and memory mapped files. This package is general purpose, has no external
dependencies and can be used in any application that needs to manage data structures outside
the Java heap.
<p>More specifically, this package provides access to four different types of resources using
the same API:
<ul><li>Native (or Direct) Memory allocated by the user.</li>
<li><code>ByteBuffers</code>, both heap-based and direct, writable and read-only.</li>
<li>Memory-mapped files, both writable and read-only.</li>
<li>Heap-based primitive arrays</li>
</ul>
The features of this design are as follows:
<ul><li>The writable and read-only APIs are separated to make them compile time detectable.</li>
<li>Converting a writable instance into a read-only instance is a simple up-cast.
For example: <pre><code>
WritableMemory wMem = ...
Memory mem = wMem;
</code></pre>
</li>
<li>The native memory and the memory mapped file resources implement <code>AutoCloseable</code> so
that these resources are automatically closed if wrapped in a try-with-resources (TRW) block.
These resources are acquired using simple handlers that implement the <code>close()</code>
method: <pre><code>
try (WritableMemoryMapHandler handler = WritableResource.map(File file)) {
WritableMemory wMem = handler.get();
// read and write to memory mapped file.
}
</code></pre>
Where it is desirable to pass ownership of the resource (and the <code>close()</code> responsibility)
one can not use the TWR block. Instead:<pre><code>
WritableMemoryMapHandler handler = WritableResource.map(File file);
...
doWorkAndClose(handler); //passes the handler to downstream object that closes the resource.
</code></pre>
</li>
<li>This package offers both a direct offset access API (<i>Memory</i>) and a positional API
(<i>Buffer</i>). Moving back and forth between these two views of the same resource is simple:
<pre><code>
Memory mem = ...
Buffer buf = mem.asBuffer();
...
Memory mem2 = buf.asMemory();
...
</code></pre>
</li>
<li>With asserts enabled in the JVM, all methods are checked for bounds and
use-after-close violations.</li>
<li>Hierarchical memory regions can be easily created:<pre><code>
WritableMemory wMem = ...
WritableMemory wReg = wMem.writableRegion(offset, length); //OR
Memory reg = wMem.region(offset, length);
</code></pre>
</li>
</ul></div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Lee Rhodes</dd>
</dl>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="../../../com/yahoo/memory/package-summary.html">Package</a></li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Package</li>
<li>Next&nbsp;Package</li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?com/yahoo/memory/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2015&#x2013;2017 <a href="https://www.yahoo.com">Yahoo! Inc.</a>. All rights reserved.</small></p>
</body>
</html>