Skip to content

Commit

Permalink
feat: making more code public in tsv query interface (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Oct 17, 2023
1 parent 7850973 commit dd4eecc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/tsv/cli/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ pub fn query_for_variant(
variant: &spdi::Var,
meta: &Meta,
db: &Arc<rocksdb::DBWithThreadMode<rocksdb::MultiThreaded>>,
cf_data: Arc<rocksdb::BoundColumnFamily>,
ctx: coding::Context,
cf_data: &Arc<rocksdb::BoundColumnFamily>,
ctx: &coding::Context,
) -> Result<Vec<serde_json::Value>, anyhow::Error> {
// Split off the genome release (checked) and convert to key as used in database.
let query = spdi::Var {
Expand All @@ -161,7 +161,7 @@ pub fn query_for_variant(
let var: keys::Var = query.into();
let key: Vec<u8> = var.into();
let raw_value = db
.get_cf(&cf_data, key)?
.get_cf(cf_data, key)?
.ok_or_else(|| anyhow::anyhow!("could not find variant in database"))?;
let line = std::str::from_utf8(raw_value.as_slice())?;
let values = ctx.line_to_values(line)?;
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn run(common: &common::cli::Args, args: &Args) -> Result<(), anyhow::Error>
&mut out_writer,
args.out_format,
&meta,
query_for_variant(variant, &meta, &db, cf_data, ctx)?,
query_for_variant(variant, &meta, &db, &cf_data, &ctx)?,
)?;
} else {
let (start, stop) = if let Some(position) = args.query.position.as_ref() {
Expand Down
6 changes: 3 additions & 3 deletions src/tsv/coding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::{common, error};
use super::schema;

/// Encapsulate the coding and decoding of character-separated lines.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Context {
/// The configuration that was used for schema inference.
config: schema::infer::Config,
pub config: schema::infer::Config,
/// The schema to use for the coding and decoding.
schema: schema::FileSchema,
pub schema: schema::FileSchema,
}

impl Context {
Expand Down

0 comments on commit dd4eecc

Please sign in to comment.