本文整理汇总了Java中com.google.flatbuffers.FlatBufferBuilder.finish方法的典型用法代码示例。如果您正苦于以下问题:Java FlatBufferBuilder.finish方法的具体用法?Java FlatBufferBuilder.finish怎么用?Java FlatBufferBuilder.finish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.flatbuffers.FlatBufferBuilder
的用法示例。
在下文中一共展示了FlatBufferBuilder.finish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Setup
public void setup() throws JsonProcessingException {
//FlatBuffers
ByteBuffer byteBuff = ByteBuffer.allocate(128);
fbb = new FlatBufferBuilder(byteBuff);
Person.createPhoneBookVector(fbb, data);
int nameOffset = fbb.createString(name);
int emailOffset = fbb.createString(email);
Person.createPhoneBookVector(fbb, data);
Person.startPerson(fbb);
Person.addName(fbb, nameOffset);
Person.addId(fbb, id);
Person.addEmail(fbb, emailOffset);
int bla = Person.endPerson(fbb);
fbb.finish(bla);
msgFlatBuffer = fbb.sizedByteArray();
}
示例2: SerializationFlatBuffers
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Benchmark
//@BenchmarkMode(Mode.AverageTime)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
//@Fork(1)
public byte[] SerializationFlatBuffers() {
ByteBuffer byteBuff = ByteBuffer.allocate(128);
fbb = new FlatBufferBuilder(byteBuff);
int nameOffset = fbb.createString(name);
int emailOffset = fbb.createString(email);
Person.createPhoneBookVector(fbb, data);
Person.startPerson(fbb);
Person.addName(fbb, nameOffset);
Person.addId(fbb, id);
Person.addEmail(fbb, emailOffset);
int bla = Person.endPerson(fbb);
fbb.finish(bla);
return fbb.sizedByteArray();
}
示例3: encodeRecord
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
protected void encodeRecord(RecordContext ctx, FlatBufferBuilder fbb, int baseOffset) {
int orderIdOffset = fbb.createString(getOrderId());
OrderReceivedEventRecord.startOrderReceivedEventRecord(fbb);
OrderReceivedEventRecord.addBase(fbb, baseOffset);
OrderReceivedEventRecord.addOrderId(fbb, orderIdOffset);
OrderReceivedEventRecord.addOrderId(fbb, orderIdOffset);
if (getSize() != null) {
OrderReceivedEventRecord.addSize(fbb, getSize().doubleValue());
}
if (getFunds() != null) {
OrderReceivedEventRecord.addFunds(fbb, getFunds().doubleValue());
}
OrderReceivedEventRecord.addOrderType(fbb, orderType == OrderType.LIMIT ? GdaxOrderType.Limit : GdaxOrderType.Market);
int offset = OrderReceivedEventRecord.endOrderReceivedEventRecord(fbb);
fbb.finish(offset);
}
示例4: encodeRecord
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
protected void encodeRecord(RecordContext ctx, FlatBufferBuilder fbb, int baseOffset) {
int orderIdOffset = fbb.createString(getOrderId());
int reasonOffset = fbb.createString(getReason());
OrderDoneEventRecord.startOrderDoneEventRecord(fbb);
OrderDoneEventRecord.addBase(fbb, baseOffset);
OrderDoneEventRecord.addOrderId(fbb, orderIdOffset);
if (getRemainingSize() != null) {
OrderDoneEventRecord.addRemainingSize(fbb, getRemainingSize().doubleValue());
}
OrderDoneEventRecord.addReason(fbb, reasonOffset);
int offset = OrderDoneEventRecord.endOrderDoneEventRecord(fbb);
fbb.finish(offset);
}
示例5: FragmentWritableBatch
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
public FragmentWritableBatch(
final QueryId queryId,
final int sendMajorFragmentId,
final int sendMinorFragmentId,
final int receiveMajorFragmentId,
ArrowRecordBatch recordBatch,
final int... receiveMinorFragmentId){
this.buffers = recordBatch.getBuffers().toArray(new ByteBuf[0]);
this.recordCount = recordBatch.getLength();
FlatBufferBuilder fbbuilder = new FlatBufferBuilder();
fbbuilder.finish(recordBatch.writeTo(fbbuilder));
ByteBuffer arrowRecordBatch = fbbuilder.dataBuffer();
final FragmentRecordBatch.Builder builder = FragmentRecordBatch.newBuilder()
.setArrowRecordBatch(ByteString.copyFrom(arrowRecordBatch))
.setQueryId(queryId)
.setReceivingMajorFragmentId(receiveMajorFragmentId)
.setSendingMajorFragmentId(sendMajorFragmentId)
.setSendingMinorFragmentId(sendMinorFragmentId);
for(final int i : receiveMinorFragmentId){
builder.addReceivingMinorFragmentId(i);
}
this.header = builder.build();
}
示例6: testDataSetSchema
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Test
public void testDataSetSchema() throws Exception {
try(
final KVStoreProvider kvstore = new LocalKVStoreProvider(DremioTest.CLASSPATH_SCAN_RESULT, null, true, false);
) {
kvstore.start();
final NamespaceService ns = new NamespaceServiceImpl(kvstore);
Field field1 = new Field("a", true, new Int(32, true), null);
Field child1 = new Field("c", true, Utf8.INSTANCE, null);
Field field2 = new Field("b", true, Struct.INSTANCE, ImmutableList.of(child1));
Schema schema = new Schema(ImmutableList.of(field1, field2));
FlatBufferBuilder builder = new FlatBufferBuilder();
schema.getSchema(builder);
builder.finish(schema.getSchema(builder));
addSource(ns, "s");
addPhysicalDS(ns, "s.foo", builder.sizedByteArray());
ByteBuffer bb = ByteBuffer.wrap(DatasetHelper.getSchemaBytes(ns.getDataset(new NamespaceKey(PathUtils.parseFullPath("s.foo")))).toByteArray());
Schema returnedSchema = Schema.convertSchema(org.apache.arrow.flatbuf.Schema.getRootAsSchema(bb));
assertEquals(schema, returnedSchema);
}
}
示例7: encodeRecord
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
protected void encodeRecord(RecordContext ctx, FlatBufferBuilder fbb, int baseOffset) {
int orderIdOffset = fbb.createString(getOrderId());
OrderChangeEventRecord.startOrderChangeEventRecord(fbb);
OrderChangeEventRecord.addOrderId(fbb, orderIdOffset);
OrderChangeEventRecord.addNewSize(fbb, getNewSize().doubleValue());
int offset = OrderChangeEventRecord.endOrderChangeEventRecord(fbb);
fbb.finish(offset);
}
示例8: encodeRecord
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
protected void encodeRecord(RecordContext ctx, FlatBufferBuilder fbb, int baseOffset) {
int orderIdOffset = fbb.createString(getOrderId());
OrderOpenEventRecord.startOrderOpenEventRecord(fbb);
OrderOpenEventRecord.addBase(fbb, baseOffset);
OrderOpenEventRecord.addOrderId(fbb, orderIdOffset);
if (getRemainingSize() != null) {
OrderOpenEventRecord.addRemainingSize(fbb, getRemainingSize().doubleValue());
}
int offset = OrderOpenEventRecord.endOrderOpenEventRecord(fbb);
fbb.finish(offset);
}
示例9: encodeRecord
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
protected void encodeRecord(RecordContext ctx, FlatBufferBuilder fbb, int baseOffset) {
int makerIdOffset = fbb.createString(getMakerOrderId());
int takerIdOffset = fbb.createString(getTakerOrderId());
OrderMatchEventRecord.startOrderMatchEventRecord(fbb);
OrderMatchEventRecord.addBase(fbb, baseOffset);
OrderMatchEventRecord.addTradeId(fbb, tradeId);
OrderMatchEventRecord.addMakerOrderId(fbb, makerIdOffset);
OrderMatchEventRecord.addTakerOrderId(fbb, takerIdOffset);
OrderMatchEventRecord.addSize(fbb, getSize().doubleValue());
int offset = OrderMatchEventRecord.endOrderMatchEventRecord(fbb);
fbb.finish(offset);
}
示例10: serialize
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
public byte[] serialize() {
FlatBufferBuilder builder = new FlatBufferBuilder();
builder.finish(serialize(builder));
return builder.sizedByteArray();
}
示例11: finishUserBuffer
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
public static void finishUserBuffer(FlatBufferBuilder builder, int offset) {
builder.finish(offset);
}
示例12: encode
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
public int encode(ByteBuffer buffer) {
FlatBufferBuilder builder = new FlatBufferBuilder(buffer);
int[] fooBars = new int[vecLen];
for (int i = 0; i < vecLen; i++) {
int name = builder.createString("Hello, World!");
FooBar.startFooBar(builder);
FooBar.addName(builder, name);
FooBar.addRating(builder, 3.1415432432445543543 + i);
FooBar.addPostfix(builder, (byte) ('!' + i));
int bar = Bar.createBar(builder,
// Foo fields (nested struct)
0xABADCAFEABADCAFEL + i,
(short) (10000 + i),
(byte) ('@' + i),
1000000 + i,
// Bar fields
123456 + i,
3.14159f + i,
(short) (10000 + i));
FooBar.addSibling(builder, bar);
int fooBar = FooBar.endFooBar(builder);
fooBars[i] = fooBar;
}
int list = FooBarContainer.createListVector(builder, fooBars);
int loc = builder.createString(location);
FooBarContainer.startFooBarContainer(builder);
FooBarContainer.addLocation(builder, loc);
FooBarContainer.addInitialized(builder, initialized);
FooBarContainer.addFruit(builder, anEnum);
FooBarContainer.addLocation(builder, loc);
FooBarContainer.addList(builder, list);
int fooBarContainer = FooBarContainer.endFooBarContainer(builder);
builder.finish(fooBarContainer);
return buffer.position();
}
示例13: testScalarEncoding
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Test
public void testScalarEncoding() {
val scalar = Nd4j.trueScalar(2.0f);
FlatBufferBuilder bufferBuilder = new FlatBufferBuilder(0);
val fb = scalar.toFlatArray(bufferBuilder);
bufferBuilder.finish(fb);
val db = bufferBuilder.dataBuffer();
val flat = FlatArray.getRootAsFlatArray(db);
val restored = Nd4j.createFromFlatArray(flat);
assertEquals(scalar, restored);
}
示例14: testVectorEncoding
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Test
public void testVectorEncoding() {
val scalar = Nd4j.trueVector(new float[]{1, 2, 3, 4, 5});
FlatBufferBuilder bufferBuilder = new FlatBufferBuilder(0);
val fb = scalar.toFlatArray(bufferBuilder);
bufferBuilder.finish(fb);
val db = bufferBuilder.dataBuffer();
val flat = FlatArray.getRootAsFlatArray(db);
val restored = Nd4j.createFromFlatArray(flat);
assertEquals(scalar, restored);
}
示例15: finishPeopleListBuffer
import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
public static void finishPeopleListBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }