Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Use Rc for TypedValue and Variable. (#395) r=nalexander#397

Closed
rnewman wants to merge 2 commits into
rustfrom
rnewman/rc
Closed

Use Rc for TypedValue and Variable. (#395) r=nalexander#397
rnewman wants to merge 2 commits into
rustfrom
rnewman/rc

Conversation

@rnewman

@rnewman rnewman commented Mar 31, 2017

Copy link
Copy Markdown
Collaborator

Part 1, core: use Rc for String and Keyword.
Part 2, query: use Rc for Variable.
Part 3, sql: use Rc for args in SQLiteQueryBuilder.
Part 4, query-algebrizer: use Rc.
Part 5, db: use Rc.
Part 6, query-parser: use Rc.
Part 7, query-projector: use Rc.
Part 8, query-translator: use Rc.
Part 9, top level: use Rc.

@rnewman rnewman self-assigned this Mar 31, 2017

@rnewman rnewman left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a surprisingly small amount of non-test code here.

We shall see how this looks with a little interning.

@ncalexan, let me know in the morning if you think you'll get your parser stuff landed sooner rather than later; there's a little bitrotting, and I suspect it'll be more painful for you.

Comment thread db/src/db.rs
(5, rusqlite::types::Value::Integer(x)) => Ok(TypedValue::Long(x)),
(5, rusqlite::types::Value::Real(x)) => Ok(TypedValue::Double(x.into())),
(10, rusqlite::types::Value::Text(x)) => Ok(TypedValue::String(x)),
(10, rusqlite::types::Value::Text(x)) => Ok(TypedValue::String(Rc::new(x))),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if from_sql_value_pair should take an InternSet<String>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, more generally, a transforming function.

Comment thread db/src/db.rs
&Value::Float(ref x) => Some(TypedValue::Double(x.clone())),
&Value::Text(ref x) => Some(TypedValue::String(x.clone())),
&Value::NamespacedKeyword(ref x) => Some(TypedValue::Keyword(x.clone())),
&Value::Text(ref x) => Some(TypedValue::String(Rc::new(x.clone()))),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And likewise.

Comment thread db/src/db.rs
&TypedValue::Double(x) => (Value::Float(x), ValueType::Double),
&TypedValue::String(ref x) => (Value::Text(x.clone()), ValueType::String),
&TypedValue::Keyword(ref x) => (Value::NamespacedKeyword(x.clone()), ValueType::Keyword),
&TypedValue::String(ref x) => (Value::Text(x.as_ref().clone()), ValueType::String),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make edn::Value use Rc, we can avoid ballooning the stream — strings would be pseudo-unique.

Comment thread db/src/db.rs
}
if let TypedValue::Keyword(keyword) = typed_value {
Ok((keyword, e))
Ok((keyword.as_ref().clone(), e))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that the keys of the map are unique, so there's no value in having IdentMap use Rc.

} else {
// It must be a keyword.
self.constrain_column_to_constant(col.clone(), DatomsColumn::Value, TypedValue::Keyword(kw.clone()));
self.constrain_column_to_constant(col.clone(), DatomsColumn::Value, TypedValue::Keyword(Rc::new(kw.clone())));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interning needs to be added here, or in the query parser itself.

rnewman added 2 commits March 31, 2017 09:33
Part 1, core: use Rc for String and Keyword.
Part 2, query: use Rc for Variable.
Part 3, sql: use Rc for args in SQLiteQueryBuilder.
Part 4, query-algebrizer: use Rc.
Part 5, db: use Rc.
Part 6, query-parser: use Rc.
Part 7, query-projector: use Rc.
Part 8, query-translator: use Rc.
Part 9, top level: use Rc.
@rnewman

rnewman commented Apr 3, 2017

Copy link
Copy Markdown
Collaborator Author

Slipped in interning of PatternNonValuePlace::Ident and PatternValuePlace::IdentOrKeyword, too.

a5023c7

@rnewman rnewman closed this Apr 3, 2017
@rnewman rnewman deleted the rnewman/rc branch April 3, 2017 04:41
@rnewman rnewman mentioned this pull request Apr 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant