Hey Ricky,
On Jan 18, 2012, at 10:27 AM, Nguyen, Ricky wrote:
> Hi all,
>
> Suppose I wanted to store a list of episodes in metadata. An episode has 2
> properties: start time and end time. I can think of 2 ways to do this:
>
> 1) use sub-metadata groups
> <key>Episode/1/start</key>
> <val>2011-01-15</val>
> <key>Episode/1/end</key>
> <val>2011-01-16</val>
> <key>Episode/2/start</key>
> <val>2011-01-17</val>
> <key>Episode/2/end</key>
> <val>2011-01-18</val>
>
> 2) declare length, and follow key patterns EpStartN and EpEndN
> <key>NumEpisodes</key>
> <val>2</val>
> <key>EpStart1</key>
> <val>2011-01-15</val>
Here's another way that I think will help with what your intended use
of the metadata is (to query for it in the PGE, for example).
<keyval>
<key>EpisodeStartDateTime</key>
<val>2011-01-17</val>
<val>2011-01-18</val>
</keyval>
<keyval>
<key>EpisodeEndDateTime</key>
<val>TBD</val>
<val>TBD</val>
</keyval>
Then, you just make sure to encode a commensurate number of values
together in each metadata field, then you can basically pick one of the
fields to interrogate and do something like:
Metadata met;
List<String> startDateTimes = met.getAllMetadata("EpsidodeStartDateTime") !=
null ?
met.getAllMetadata("EpsidodeStartDateTime"):new Vector<String>();
List <String> endDateTimes = met.getAllMetadata("EpsidodeEndDateTime") != null
?
met.getAllMetadata("EpsidodeEndDateTime"):new Vector<String>();
for(int i=0; i < startDateTimes.size() ; i++){
// i == the episodeNum?
// if it isn't, then just store an associated EpisodeNum field with the
same
// size as the start/end date time
String startDateTime = startDateTimes.get(i);
String endDateTime = endDateTimes.get(i);
}
Does that help?
>
> So then the next question is, how do I write elements.xml (in FileMgr policy)
> to accommodate the variable number of keys?
No need it assumes that by default, since it's a NoSQL type store :)
>
> And a follow up question is, how do I retrieve/use this information when
> creating PGE config queries? (SQL(Format='$whatgoeshere') SELECT whatgoeshere
> FROM …)
You can query that way and you'll just get back all the values (delimited by
",") and concatenated together.
Cheers,
Chris
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Chris Mattmann, Ph.D.
Senior Computer Scientist
NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA
Office: 171-266B, Mailstop: 171-246
Email: [email protected]
WWW: http://sunset.usc.edu/~mattmann/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adjunct Assistant Professor, Computer Science Department
University of Southern California, Los Angeles, CA 90089 USA
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++