当前位置: 首页>>代码示例>>Java>>正文


Java FlatBufferBuilder.createString方法代码示例

本文整理汇总了Java中com.google.flatbuffers.FlatBufferBuilder.createString方法的典型用法代码示例。如果您正苦于以下问题:Java FlatBufferBuilder.createString方法的具体用法?Java FlatBufferBuilder.createString怎么用?Java FlatBufferBuilder.createString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.flatbuffers.FlatBufferBuilder的用法示例。


在下文中一共展示了FlatBufferBuilder.createString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();

}
 
开发者ID:rafamonteiro,项目名称:SerializationProtocolsBenchMark,代码行数:19,代码来源:FlatBuffersBenchmark.java

示例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();
}
 
开发者ID:rafamonteiro,项目名称:SerializationProtocolsBenchMark,代码行数:21,代码来源:FlatBuffersBenchmark.java

示例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);
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:20,代码来源:MutableOrderReceivedEvent.java

示例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);
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:17,代码来源:MutableOrderDoneEvent.java

示例5: encodeRecord

import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
@Override
public byte[] encodeRecord(RecordContext ctx) {
    FlatBufferBuilder fbb = new FlatBufferBuilder(16);

    int productIdOffset = fbb.createString(productId.getURN());

    OrderUpdateEventRecord.startOrderUpdateEventRecord(fbb);
    OrderUpdateEventRecord.addSide(fbb, side == Side.BUY ? GdaxSide.Buy : GdaxSide.Sell);
    if (price != null) {
        OrderUpdateEventRecord.addPrice(fbb, price.doubleValue());
    }
    OrderUpdateEventRecord.addProductId(fbb, productIdOffset);

    int baseOffset = OrderUpdateEventRecord.endOrderUpdateEventRecord(fbb);

    encodeRecord(ctx, fbb, baseOffset);
    return fbb.sizedByteArray();
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:19,代码来源:AbstractOrderBookUpdateEvent.java

示例6: asFlatNode

import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
protected int asFlatNode(String name, @NonNull SameDiff scope, @NonNull FlatBufferBuilder bufferBuilder) {
    int scopeName = bufferBuilder.createString(name);

    int flatNode = FlatNode.createFlatNode(bufferBuilder,
            scopeName,
            scopeName,
            OpType.LOGIC,
            10, // hardcoded value
            0,
            0,
            0,
            (byte) 0,
            0,
            0,
            0,
            0,
            -1,
            0.0f, 0, 0);

    return flatNode;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:22,代码来源:SameDiff.java

示例7: asFlatProperties

import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
/**
 * This method converts this FunctionProperties instance to FlatBuffers representation
 * @param bufferBuilder
 * @return
 */
public int asFlatProperties(FlatBufferBuilder bufferBuilder) {
    int iname = bufferBuilder.createString(name);
    int ii = FlatProperties.createIVector(bufferBuilder, Ints.toArray(i));
    int il = FlatProperties.createLVector(bufferBuilder, Longs.toArray(l));
    int id = FlatProperties.createDVector(bufferBuilder, Doubles.toArray(d));

    int arrays[] = new int[a.size()];
    int cnt = 0;
    for (val array: a) {
        int off = array.toFlatArray(bufferBuilder);
        arrays[cnt++] = off;
    }

    int ia = FlatProperties.createAVector(bufferBuilder, arrays);

    return FlatProperties.createFlatProperties(bufferBuilder, iname, ii, il, id, ia);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:23,代码来源:FunctionProperties.java

示例8: 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);
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:12,代码来源:MutableOrderChangeEvent.java

示例9: 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);
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:15,代码来源:MutableOrderOpenEvent.java

示例10: 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);
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:16,代码来源:MutableOrderMatchEvent.java

示例11: createMetric

import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
private int createMetric(FlatBufferBuilder builder, String name, long timestamp, double value,
        Map<String, String> tags) {
    int n = builder.createString(name);
    int[] t = new int[tags.size()];
    int i = 0;
    for (Entry<String, String> e : tags.entrySet()) {
        t[i] = timely.api.flatbuffer.Tag.createTag(builder, builder.createString(e.getKey()),
                builder.createString(e.getValue()));
        i++;
    }
    return timely.api.flatbuffer.Metric.createMetric(builder, n, timestamp, value,
            timely.api.flatbuffer.Metric.createTagsVector(builder, t));
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:14,代码来源:MetricsBufferDecoderTest.java

示例12: sendCommand

import com.google.flatbuffers.FlatBufferBuilder; //导入方法依赖的package包/类
/**
 * send command to osmcore
 * @param[in] category command type
 * @param[in] arguments arguments for command
 */
public void sendCommand(byte category, Object... arguments) {
  FlatBufferBuilder cmdFlatBuffer = new FlatBufferBuilder(1);
  
  // prepare arguments of commandInfo
  int commandArgsIndex = 0;
  int [] commandArgs = new int[arguments.length];
  for (Object argument: arguments) {
    if (String.class.isInstance(argument)) 
      commandArgs[commandArgsIndex] = cmdFlatBuffer.createString((String) argument);
    else
      commandArgs[commandArgsIndex] = cmdFlatBuffer.createString(argument.toString());
    commandArgsIndex++;
  }

  // prepare commandInfo
  int commandArgsList = commandInfo.createArgumentsVector(cmdFlatBuffer, commandArgs);
  int commandInfoObject = commandInfo.createcommandInfo(cmdFlatBuffer, commandArgsList);
  commandInfo.finishcommandInfoBuffer(cmdFlatBuffer, commandInfoObject);

  // prepare the payload of ipcMessage
  FlatBufferBuilder flatbuffer = new FlatBufferBuilder(1);
  int commandPayLoad = ipcData.createPayloadVector(flatbuffer, cmdFlatBuffer.sizedByteArray());

  // prepare an ipcMessage
  int [] cmdDataArray = new int[1];
  cmdDataArray[0] = ipcData.createipcData(flatbuffer, category, commandPayLoad);
  int cmdDataList = ipcMessage.createDataVector(flatbuffer, cmdDataArray);
  int cmdMessage = ipcMessage.createipcMessage(flatbuffer, ipcType.COMMAND, cmdDataList);
  ipcMessage.finishipcMessageBuffer(flatbuffer, cmdMessage);

  // send
  try {
    OutputStream outputStream = client.getOutputStream();
    outputStream.write(flatbuffer.sizedByteArray());
  } catch (IOException e) {}

}
 
开发者ID:eolwral,项目名称:OSMonitor,代码行数:43,代码来源:IpcService.java

示例13: 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();
}
 
开发者ID:ennerf,项目名称:flatbuffers-java-benchmark,代码行数:45,代码来源:FlatBench.java


注:本文中的com.google.flatbuffers.FlatBufferBuilder.createString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。