Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rdb archive enum #3065

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions services/archive-engine/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-pv"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-pv-ca"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-pv-pva"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-vtype"/>
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011-2020 Oak Ridge National Laboratory.
* Copyright (c) 2011-2024 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -178,11 +178,18 @@ public WriteChannel getChannel(final String name) throws Exception
@Override
public void addSample(final WriteChannel channel, final VType sample) throws Exception
{
final RDBWriteChannel rdb_channel = (RDBWriteChannel) channel;
writeMetaData(rdb_channel, sample);
batchSample(rdb_channel, sample);
batched_channel.add(rdb_channel);
batched_samples.add(sample);
try
{
final RDBWriteChannel rdb_channel = (RDBWriteChannel) channel;
writeMetaData(rdb_channel, sample);
batchSample(rdb_channel, sample);
batched_channel.add(rdb_channel);
batched_samples.add(sample);
}
catch (Exception ex)
{ // Wrap with channel info
throw new Exception("Cannot add sample for " + channel, ex);
}
}

/** Write meta data if it was never written or has changed
Expand All @@ -191,12 +198,33 @@ public void addSample(final WriteChannel channel, final VType sample) throws Exc
*/
private void writeMetaData(final RDBWriteChannel channel, final VType sample) throws Exception
{
// Three cases: String, enum, numeric.
//
// Note that Strings have no meta data. But we don't know at this point
// if it's really a string channel, or of this is just a special
// if it's really a string channel, or if this is just a special
// string value like "disconnected".
// In order to not delete any existing meta data,
// we just do nothing for strings
// we just do nothing for strings.
if (sample instanceof VString)
return;

if (sample instanceof VEnum)
{
final List<String> labels = ((VEnum)sample).getDisplay().getChoices();
if (MetaDataHelper.equals(labels, channel.getMetadata()))
return;

// Clear numeric meta data, set enumerated in RDB
NumericMetaDataHelper.delete(connection, sql, channel);
EnumMetaDataHelper.delete(connection, sql, channel);
EnumMetaDataHelper.insert(connection, sql, channel, labels);
channel.setMetaData(labels);

return;
}

// Note that Display.displayOf(VEnum) or ..(VString) will return a non-null display,
// but we already handled those cases
final Display display = Display.displayOf(sample);
if (display != null)
{
Expand All @@ -209,18 +237,6 @@ private void writeMetaData(final RDBWriteChannel channel, final VType sample) th
NumericMetaDataHelper.insert(connection, sql, channel, display);
channel.setMetaData(display);
}
else if (sample instanceof VEnum)
{
final List<String> labels = ((VEnum)sample).getDisplay().getChoices();
if (MetaDataHelper.equals(labels, channel.getMetadata()))
return;

// Clear numeric meta data, set enumerated in RDB
NumericMetaDataHelper.delete(connection, sql, channel);
EnumMetaDataHelper.delete(connection, sql, channel);
EnumMetaDataHelper.insert(connection, sql, channel, labels);
channel.setMetaData(labels);
}
}

private static Instant getTimestamp(final VType value)
Expand Down
Loading