cassandra-server
Version:
A thin Javascript wrapper around Apache Cassandra to provide out of the box server support
476 lines (472 loc) • 23.3 kB
HTML
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_67) on Sun Sep 07 15:29:31 CEST 2014 -->
<title>CQLSSTableWriter (apache-cassandra API)</title>
<meta name="date" content="2014-09-07">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="CQLSSTableWriter (apache-cassandra API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CQLSSTableWriter.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><a href="../../../../../org/apache/cassandra/io/sstable/CorruptSSTableException.html" title="class in org.apache.cassandra.io.sstable"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.Builder.html" title="class in org.apache.cassandra.io.sstable"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/cassandra/io/sstable/CQLSSTableWriter.html" target="_top">Frames</a></li>
<li><a href="CQLSSTableWriter.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All 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>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li><a href="#nested_class_summary">Nested</a> | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.cassandra.io.sstable</div>
<h2 title="Class CQLSSTableWriter" class="title">Class CQLSSTableWriter</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.cassandra.io.sstable.CQLSSTableWriter</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">CQLSSTableWriter</span>
extends java.lang.Object</pre>
<div class="block">Utility to write SSTables.
<p>
Typical usage looks like:
<pre>
String schema = "CREATE TABLE myKs.myTable ("
+ " k int PRIMARY KEY,"
+ " v1 text,"
+ " v2 int"
+ ")";
String insert = "INSERT INTO myKs.myTable (k, v1, v2) VALUES (?, ?, ?)";
// Creates a new writer. You need to provide at least the directory where to write the created sstable,
// the schema for the sstable to write and a (prepared) insert statement to use. If you do not use the
// default partitioner (Murmur3Partitioner), you will also need to provide the partitioner in use, see
// CQLSSTableWriter.Builder for more details on the available options.
CQLSSTableWriter writer = CQLSSTableWriter.builder()
.inDirectory("path/to/directory")
.forTable(schema)
.using(insert).build();
// Adds a nember of rows to the resulting sstable
writer.addRow(0, "test1", 24);
writer.addRow(1, "test2", null);
writer.addRow(2, "test3", 42);
// Close the writer, finalizing the sstable
writer.close();
</pre></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested_class_summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class </code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.Builder.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter.Builder</a></strong></code>
<div class="block">A Builder for a CQLSSTableWriter object.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#addRow(java.util.List)">addRow</a></strong>(java.util.List<java.lang.Object> values)</code>
<div class="block">Adds a new row to the writer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#addRow(java.util.Map)">addRow</a></strong>(java.util.Map<java.lang.String,java.lang.Object> values)</code>
<div class="block">Adds a new row to the writer.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#addRow(java.lang.Object...)">addRow</a></strong>(java.lang.Object... values)</code>
<div class="block">Adds a new row to the writer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.Builder.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter.Builder</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#builder()">builder</a></strong>()</code>
<div class="block">Returns a new builder for a CQLSSTableWriter.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#close()">close</a></strong>()</code>
<div class="block">Close this writer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#rawAddRow(java.nio.ByteBuffer...)">rawAddRow</a></strong>(java.nio.ByteBuffer... values)</code>
<div class="block">Adds a new row to the writer given already serialized values.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#rawAddRow(java.util.List)">rawAddRow</a></strong>(java.util.List<java.nio.ByteBuffer> values)</code>
<div class="block">Adds a new row to the writer given already serialized values.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#rawAddRow(java.util.Map)">rawAddRow</a></strong>(java.util.Map<java.lang.String,java.nio.ByteBuffer> values)</code>
<div class="block">Adds a new row to the writer given already serialized values.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="builder()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>builder</h4>
<pre>public static <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.Builder.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter.Builder</a> builder()</pre>
<div class="block">Returns a new builder for a CQLSSTableWriter.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the new builder.</dd></dl>
</li>
</ul>
<a name="addRow(java.lang.Object...)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> addRow(java.lang.Object... values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer.
<p>
This is a shortcut for <code>addRow(Arrays.asList(values))</code>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the row values (corresponding to the bind variables of the
insertion statement used when creating by this writer).</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="addRow(java.util.List)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> addRow(java.util.List<java.lang.Object> values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer.
<p>
Each provided value type should correspond to the types of the CQL column
the value is for. The correspondance between java type and CQL type is the
same one than the one documented at
www.datastax.com/drivers/java/2.0/apidocs/com/datastax/driver/core/DataType.Name.html#asJavaClass().
<p>
If you prefer providing the values directly as binary, use
<a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html#rawAddRow(java.nio.ByteBuffer...)"><code>rawAddRow(java.nio.ByteBuffer...)</code></a> instead.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the row values (corresponding to the bind variables of the
insertion statement used when creating by this writer).</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="addRow(java.util.Map)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> addRow(java.util.Map<java.lang.String,java.lang.Object> values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer.
<p>
This is equivalent to the other addRow methods, but takes a map whose
keys are the names of the columns to add instead of taking a list of the
values in the order of the insert statement used during construction of
this write.
<p>
Please note that the column names in the map keys must be in lowercase unless
the declared column name is a
<a href="http://cassandra.apache.org/doc/cql3/CQL.html#identifiers">case-sensitive quoted identifier</a>
(in which case the map key must use the exact case of the column).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - a map of colum name to column values representing the new
row to add. Note that if a column is not part of the map, it's value will
be <code>null</code>. If the map contains keys that does not correspond to one
of the column of the insert statement used when creating this writer, the
the corresponding value is ignored.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="rawAddRow(java.nio.ByteBuffer...)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>rawAddRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> rawAddRow(java.nio.ByteBuffer... values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer given already serialized values.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the row values (corresponding to the bind variables of the
insertion statement used when creating by this writer) as binary.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="rawAddRow(java.util.List)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>rawAddRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> rawAddRow(java.util.List<java.nio.ByteBuffer> values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer given already serialized values.
<p>
This is a shortcut for <code>rawAddRow(Arrays.asList(values))</code>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - the row values (corresponding to the bind variables of the
insertion statement used when creating by this writer) as binary.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="rawAddRow(java.util.Map)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>rawAddRow</h4>
<pre>public <a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.html" title="class in org.apache.cassandra.io.sstable">CQLSSTableWriter</a> rawAddRow(java.util.Map<java.lang.String,java.nio.ByteBuffer> values)
throws <a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a>,
java.io.IOException</pre>
<div class="block">Adds a new row to the writer given already serialized values.
<p>
This is equivalent to the other rawAddRow methods, but takes a map whose
keys are the names of the columns to add instead of taking a list of the
values in the order of the insert statement used during construction of
this write.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>values</code> - a map of colum name to column values representing the new
row to add. Note that if a column is not part of the map, it's value will
be <code>null</code>. If the map contains keys that does not correspond to one
of the column of the insert statement used when creating this writer, the
the corresponding value is ignored.</dd>
<dt><span class="strong">Returns:</span></dt><dd>this writer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/cassandra/exceptions/InvalidRequestException.html" title="class in org.apache.cassandra.exceptions">InvalidRequestException</a></code></dd>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="close()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>close</h4>
<pre>public void close()
throws java.io.IOException</pre>
<div class="block">Close this writer.
<p>
This method should be called, otherwise the produced sstables are not
guaranteed to be complete (and won't be in practice).</div>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CQLSSTableWriter.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><a href="../../../../../org/apache/cassandra/io/sstable/CorruptSSTableException.html" title="class in org.apache.cassandra.io.sstable"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/cassandra/io/sstable/CQLSSTableWriter.Builder.html" title="class in org.apache.cassandra.io.sstable"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/cassandra/io/sstable/CQLSSTableWriter.html" target="_top">Frames</a></li>
<li><a href="CQLSSTableWriter.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All 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>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li><a href="#nested_class_summary">Nested</a> | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2014 The Apache Software Foundation</small></p>
</body>
</html>