aerospike-client-go icon indicating copy to clipboard operation
aerospike-client-go copied to clipboard

add inline annotation

Open clanstyles opened this issue 9 years ago • 6 comments

In mgo's driver they have an inline annotation (http://bazaar.launchpad.net/+branch/mgo/v2/view/head:/bson/bson.go#L442)

I propose this is added. The issue is otherwise an added structure is treated like a json object and you can't add a second query to any of it.

clanstyles avatar Oct 28 '15 03:10 clanstyles

Thanks for your suggestion. Will look into it.

khaf avatar Nov 11 '15 11:11 khaf

So you're proposing that:

type Foo struct {
    FooA int
    FooB Bar    `aerospike:",inline"`
    FooC string `aerospike:"ccc"`
}
type Bar struct {
    A int
    B string
}

Results in the bins:

  • FooA
  • FooB.A
  • FooB.B
  • ccc

That does sound interesting!

GeertJohan avatar Jul 21 '16 07:07 GeertJohan

Or could also become the bins:

  • FooA
  • A
  • B
  • ccc

But I like that less. It will cause a conflict when a field named A is added to the Foo struct.

GeertJohan avatar Jul 21 '16 07:07 GeertJohan

It's the latter, and that's why this issue is on the back burner.

khaf avatar Jul 21 '16 07:07 khaf

I'd like to +1 on the issue.

Current API seems a bit wasteful in 100% of our cases: the aerospike-client returns BinMaps, that're map[string]interface{}, and we convert them into strictly typed objects.

As an example, being able to pass a zero-value struct that implements, a hypothetical BinSerDer, to read-methods, will reduce the number of temporal allocations.

narqo avatar Feb 03 '19 20:02 narqo

@narqo I'm working on a solution along those lines, but with a dash of code generation. Does that sound good to you?

khaf avatar Apr 25 '19 18:04 khaf