Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:45
    eolivelli commented #4914
  • Jan 31 2019 22:07
    samsartor starred google/flatbuffers
  • Jan 31 2019 21:28
    marang starred google/flatbuffers
  • Jan 31 2019 20:51
    thyrlian starred google/flatbuffers
  • Jan 31 2019 19:19
    harshshah903 commented #5144
  • Jan 31 2019 19:19
    harshshah903 commented #5144
  • Jan 31 2019 18:56
    aardappel commented #4914
  • Jan 31 2019 18:54
    aardappel commented #5144
  • Jan 31 2019 18:51
    aardappel commented #5141
  • Jan 31 2019 18:51
    aardappel commented #5145
  • Jan 31 2019 18:51
    krojew commented #5142
  • Jan 31 2019 18:49
    krojew commented #5142
  • Jan 31 2019 18:48
    gabyx edited #5142
  • Jan 31 2019 18:48
    gabyx edited #5142
  • Jan 31 2019 18:47
    gabyx commented #5142
  • Jan 31 2019 18:47
    aardappel commented #5002
  • Jan 31 2019 18:43
    gabyx commented #5142
  • Jan 31 2019 18:43
    krojew commented #5142
  • Jan 31 2019 18:43
    aardappel commented #5143
  • Jan 31 2019 18:42
    gabyx commented #5142
Max Burke
@maxburke

I have a type

table foo { obj: [ubyte]; }

where the contents of obj are Yet Another Flatbuffer. with the rust library is there any way to force the embedded bytes of obj to be aligned to the minimum necessary for the flatbuffer library?

right now it seems like it's getting minimum u8 alignment, and when-all-the-stars-align and I do something like flatbuffers::size_prefixed_root(foo_instance.obj()) I get an error that my object is unaligned

Gopi M Tatiraju
@heisenbuug

I have a usage-related question.
This is my schema

namespace Client;

enum Gender:byte {Female = 0, Male = 1}

enum Type:byte {Person = 0, Group = 1}

table Person
{
  name: string;
  age: short;
  weight: double;
  gender: Gender; // Enum
}

table Group
{
  group_name: string;
  average_age: double;
  average_weight: double;
  names: [string];
}

union Foo {Person, Group}

table Data

Now I have to store multiple Persons or Groups in a single flatbuffer

One way is to make a vector and keep appending to it.
Is there any other way?
Is FinishSizePrefix() useful in this case, I can't find much documentation about it or any example.
I am creating flatbuffer in C++ and reading it in Python
Wouter van Oortmerssen
@aardappel
@maxburke does it help if you add (nested_flatbuffer: RootTableType) to the obj field? if not that is a bug in the Rust generator, would open an issue on github
@heisenbuug you could use a vector of unions in the root type, but I am not sure if they are supported in Python yet. A simpler alternative may be simply a vector of Person and a separate vector of Group.
Gopi M Tatiraju
@heisenbuug
Hii
I have another questions
Lets consider I have a simple Schema named Person which has name, age...
  flatbuffers::FlatBufferBuilder builder(1024);

  // Create Person.
   WritePerson0(builder);

  // Create Group.
  WritePerson(builder);

  // Getting ready to the write buffer to a file.
  uint8_t *buf = builder.GetBufferPointer();
  int size = builder.GetSize();

  // Writing to a file.
  std::ofstream writer("fb_bytes.bin", std::ios::binary);
  writer.write((char*)buf, size);
  writer.close();
Now I am writing 2 Persons like this
When I am trying to access this, how should I access the second entry
I am doing this, but you can see that this is not possible for every case
with open("fb_bytes.bin", "rb") as f:
    buf = f.read()

foo = Client.Person.Person.GetRootAs(buf)
print(foo.Name().decode('utf-8'), end = ", ")
print(str(foo.Age()), end = ", ")
print(str(foo.Weight()))

buf = buf[48:]   

foo0 = Client.Person.Person.GetRootAs(buf1)
print(foo0.Name().decode('utf-8'), end = ", ")
print(str(foo0.Age()), end = ", ")
print(str(foo0.Weight()))
I checked the size usinglen() by writing only one Person and thus sliced the buf
But I want to automate this fot n number of Persons
Gopi M Tatiraju
@heisenbuug
@aardappel am I doing something wrong while writing to file? The file is being written as I want I just have an issue while reading it, how can I know the size of the message which is being written.
Wouter van Oortmerssen
@aardappel
@heisenbuug that code is not legal.. every buffer should end with builder.Finish() which you can only do one time
if you have serialized other objects which are not reachable from that root, you can't access them.. you'd have to invent a new root type that includes them both somehow
also, if you run such code, you should get asserts indicating the problem.. if you're not getting asserts, make sure you have them on during development (debug mode)
like I said above, use a vector of objects
Gopi M Tatiraju
@heisenbuug
Okay, so even though this might work but it's not the correct way.
Wouter van Oortmerssen
@aardappel
or if you could serialize each object in its own (size prefixed) buffer, and write a list of those to your file.. but that likely takes more space
Gopi M Tatiraju
@heisenbuug
Both functions look like this, just different values
  auto pName = builder.CreateString("BiasdasdgFoot");
  auto pAge = 91;
  auto pWeight = 123.5;

  auto Person = CreatePerson(builder, pName, pAge, pWeight, Gender_Male);

  // builder.FinishSizePrefixed(Person);
  builder.Finish(Person);
Wouter van Oortmerssen
@aardappel
yes, like I said, you must not have asserts on, because the second time you call Finish you should get an error
Gopi M Tatiraju
@heisenbuug
Oh...
But then how can we create multiple Person without using vector?
Can't I just keep creating Person and keep appending to the file?
Maybe I am not able to explain my use case properly.
What I understood is, we can only use Finish once.
In my code I am not getting any errors because asserts are off.
Wouter van Oortmerssen
@aardappel
again, you can't do it using vector
please read what I typed above again
and turn asserts on
Gopi M Tatiraju
@heisenbuug
How to turn on asserts?
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG
Building like this will turn on asserts?
Wouter van Oortmerssen
@aardappel
it should, yes
Gopi M Tatiraju
@heisenbuug
Thank you.
Now I am clearing the buffer using builder.Clear() and reusing it.
Gopi M Tatiraju
@heisenbuug
@aardappel Thank you soo much. It worked. And since this time assets were turned on and I got no errors, I am assuming I did everything right.
Although I need to explore more to understand things better, I am off to a good start. I might even try contributing to the project.
Wouter van Oortmerssen
@aardappel
cool :)
hustqy
@hustqy
guys, i need to use flatbuffer with grpc , when i use flatc --grpc --cpp ./greeter.fbs in /grpc/samples/greeters, only 3 files added, greeter_generated.grpc.fb.cc greeter_generated.grpc.fb.h greeter_generated.h, and file greeter.grpc.fb.h not found which is used in server.cpp . any one can help ?
Wouter van Oortmerssen
@aardappel
@hustqy thanks for reporting, looks like that was broken by the recent PR google/flatbuffers#6954
for now you may have to rename them manually to make it build, or fix the code/Makefile
kai
@kai:nasnotfound.de
[m]
I like the FlatBuffers IDL and want to use it with a custom wire format. I figured, using the intermediate representation is a good start. Is there a way to use some code generation infrastructure from flatc for this use case, maybe by writing a plugin for it?
Wouter van Oortmerssen
@aardappel
@kai:nasnotfound.de you're in luck, flatc is able to write out a binary version of a parsed schema.. using FlatBuffers itself! This data is perfect for writing external code generators. You can easily read this data in any language that FlatBuffers already supports. The option is --bfbs I believe, and the schema for the data is in reflection/ .. see also some github issues where we talk more about using this for external code generators @dbaileychess
Bodie
@bsolomon-bw
has anyone compared the parsing performance of simdjson to flatbuffers' JSON parser? I'd love to see that added to the performance breakdown on the landing page