<?php require_once( dirname(dirname(dirname( __FILE__ ))) . '/wp-load.php' ); ?>
<!-- START of header -->
<?php get_header(); ?>
<!-- END of header -->

<!-- warapper -->

<div class="docs-content">
<!-- START of page navigation -->
<?php get_template_part( 'docs_navigation' ); ?>
<!-- END of page navigation -->
<!-- START of pusher -->
<div class="docs-content-body">
<div id="content" class="docs-content-body__inner">

<h1 class="title">5.1.15 TimeSeries Container Modification</h1>
<h2 id="overview">Overview</h2>
<p>This chapter describes the changing the schema of a TimeSeries container. Changing the index is same as changing the index as with a collection, please refer the <a href="5-1-11_collection-modify.php">Collection Modification</a> chapter for details on that process.</p>
<p><br/></p>
<h2>Schema Modification</h2>
<p>Like you can with Collections, you can add or remove columns after creating a TimeSeriescontainer. Create a new class with the modified columns. The following AnotherInstrumentLog class shows an example of sch a change.</p>
<strong>List.1 Modified class</strong> (AnotherInstrumentLog.java)
<pre class="prettyprint linenums">
package sample.row;

import java.sql.Blob;
import java.util.Date;

import com.toshiba.mwcloud.gs.RowKey;

public class AnotherInstrumentLog {
/ **
* Timestamp of log
* /
@RowKey
public Date timestamp;

/ **
* ID of WeatherStation
* /
public String weatherStationId;

/ **
* Temperature of the measurement result
* /
public float temperture;

/ **
* Image data obtained by photographing the sky
* /
public Blob liveImage;

/ **
* Added field to InstrumentLog
* /
public String description;
}
</pre>
<ul>
<li>L.33: The new field added to the <code>InstrumentLog</code> class.</li>
</ul>
<p>While normally <code>GridStore.putTimeSeries (String, Class)</code> would be used but with the modified schema, we need to change the pparameters and use <code>GridStore.putTimeSeries (String, Class, TimeSeriesProperties, boolean)</code> method.</p>
<strong>List.2 putTimeSeries Parameters</strong>
<pre class="prettyprint linenums">
&Lt; R &gt; TimeSeries &lt; R &gt; putTimeSeries (java.lang.String name,
                              java.lang.Class &lt; R &gt; rowType,
                              TimeSeriesProperties props,
                              boolean modifiable)
                              throws GSException
</pre>
<p>The descriptions of each parameter are the same as when used with collections, please refer to the <a href="5-1-11_collection-modify.php">modifying collections</a> chapter for more details.</P>

<strong>List 3.Creating a TimeSeries Container with the new Column</strong> (TimeSeriesModify.java)
<pre class="prettyprint linenums:36">
// Modify another schema TimeSeries Container
TimeSeriesProperties timeProp=new TimeSeriesProperties ();
TimeSeries &lt; AnotherInstrumentLog &gt; anotherTs=store.putTimeSeries("weather_station_1",
    AnotherInstrumentLog.class, timeProp, <span style="font-weight: bold"> true </ span>);
</pre>
<ul>
<li>L.37: In order to use the <code>putTimeSeries (String, Class, TimeSeriesProperties, boolean)</code> method with the new class, you have to create a new instance of TimeSeriesProperties</code>. See the <a href="5-1-22-metainfo.php">meta-information</a> section for more information about TimeSeriesProperties.</li>
<li>L.39: Specify <code>true</code> for the <code>modifiable</code> parameter.</li>
</ul>
<p><br/></p>
<h2 id="complete-source-code">Complete source code</h2>
<p>Complete source code used in this sample can be downloaded from the following.</p>
<p>Download: <a href="img/timeseries-modify.zip">timeseries-modify.zip</a></p>
<p><br/></p>
</div>
</div>
</div>

</div>

</div>
<!-- / main -->

<?php get_footer(); ?>
