• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ArrayValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.msgpack.value.ArrayValue的典型用法代码示例。如果您正苦于以下问题:Java ArrayValue类的具体用法?Java ArrayValue怎么用?Java ArrayValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArrayValue类属于org.msgpack.value包,在下文中一共展示了ArrayValue类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: processPacket

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
public byte[] processPacket(Pair<SphinxHeader, byte[]> packet, BigInteger privk)
        throws SphinxException, IOException, CryptoException {
    SphinxProcessData sphinxProcessData = packer.decryptSphinxPacket(packet, privk);
    byte routingFlag = sphinxProcessData.routing[0];
    if (routingFlag == SphinxClient.DEST_FLAG) {
        Value value = packer.handleReceivedForward(sphinxProcessData.delta);
        ArrayValue outerTuple = value.asArrayValue();
        ArrayValue destination = outerTuple.get(0).asArrayValue();
        byte[] message = outerTuple.get(1).asBinaryValue().asByteArray();
        if (isDestinationSelf(destination)) {
            return message;
        } else {
            throw new RuntimeException("Received message not meant for us");
        }
    }
    throw new RuntimeException("Processed non-destination packet");
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:18,代码来源:ClientCore.java


示例2: downloadPreviewRows

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
static void downloadPreviewRows(TDJobOperator j, String description, TaskState state, DurationInterval retryInterval)
{
    StringWriter out = new StringWriter();

    try {
        addCsvHeader(out, j.getResultColumnNames());

        List<ArrayValue> rows = downloadFirstResults(j, PREVIEW_ROWS, state, PREVIEW, retryInterval);
        if (rows.isEmpty()) {
            logger.info("preview of {}: (no results)", description, j.getJobId());
            return;
        }
        for (ArrayValue row : rows) {
            addCsvRow(out, row);
        }
    }
    catch (Exception ex) {
        logger.warn("Getting rows for preview failed. Ignoring this error.", ex);
        return;
    }

    logger.info("preview of {}:\r\n{}", description, out.toString());
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:24,代码来源:TdOperatorFactory.java


示例3: fetchJobResult

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private boolean fetchJobResult(TDJobOperator job)
{
    Optional<ArrayValue> firstRow = pollingRetryExecutor(state, RESULT)
            .retryUnless(TDOperator::isDeterministicClientException)
            .withErrorMessage("Failed to download result of job '%s'", job.getJobId())
            .run(s -> job.getResult(
                    ite -> ite.hasNext()
                            ? Optional.of(ite.next())
                            : Optional.absent()));

    // There must be at least one row in the result for the wait condition to be fulfilled.
    if (!firstRow.isPresent()) {
        return false;
    }

    ArrayValue row = firstRow.get();
    if (row.size() < 1) {
        throw new TaskExecutionException("Got empty row in result of query");
    }

    Value firstCol = row.get(0);
    return isTruthy(firstCol);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:24,代码来源:TdWaitOperatorFactory.java


示例4: messageReceived

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
    logger.debug("Received {}: {}", message);
    // message is a HeapBuffer
    IoBuffer buffer = (IoBuffer) message;
    Unpacker unpacker = Unpacker.getUnpacker(buffer.array());
    ArrayValue values = unpacker.unpackValue().asArrayValue();
    // TODO: This might have to change to handle tagging of messages
    if (values.get(0).isBinaryValue()) {
        String type = values.get(0).asBinaryValue().asString();
        logger.info("Received {}", type);
        // Ignore dummy values
        // TODO: Wait what, Loopix sends DUMMY messages in plaintext?
        if (type.equals("DUMMY")) {
            return;
        } else {
            logger.warn("Received unknown message");
        }
    } else if (values.get(0).isArrayValue()) {
        SphinxHeader header = SphinxHeader.fromValue(values.get(0).asArrayValue());
        byte[] body = values.get(1).asBinaryValue().asByteArray();
        byte[] decryptedBody = cryptoClient.processPacket(new ImmutablePair<>(header, body), secret);
        // Assume we are sending/receiving text messages for now
        logger.info("Received: {}", new String(decryptedBody, Charset.forName("UTF-8")));
    } else {
        logger.warn("Received unknown message");
    }
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:29,代码来源:LoopixClient.java


示例5: fromValue

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
public static SphinxHeader fromValue(ArrayValue values) {
    try {
        ECPoint alpha = Unpacker.unpackEcPoint(values.get(0));
        byte[] beta = values.get(1).asBinaryValue().asByteArray();
        byte[] gamma = values.get(2).asBinaryValue().asByteArray();
        return new SphinxHeader(alpha, beta, gamma);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:11,代码来源:SphinxHeader.java


示例6: ecPointToByteArray

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
public static byte[] ecPointToByteArray(ECPoint point) throws IOException {
    MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
    byte[] pointData = point.getEncoded(false);
    ArrayValue values = new ImmutableArrayValueImpl(new Value[]{
            new ImmutableLongValueImpl(713),
            new ImmutableBinaryValueImpl(pointData)
    });
    packer.packValue(values);
    return packer.toByteArray();
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:11,代码来源:Packer.java


示例7: deserializeCollection

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private Collection<?> deserializeCollection( ModuleDescriptor module, CollectionType collectionType,
                                             ArrayValue value ) throws IOException
{
    Collection<?> collection = collectionType.isSet() ? new LinkedHashSet( value.size() )
                                                      : new ArrayList( value.size() );
    for( Value element : value.list() )
    {
        collection.add( doDeserialize( module, collectionType.collectedType(), element ) );
    }
    return collection;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:12,代码来源:MessagePackDeserializer.java


示例8: fetchJobResult

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private boolean fetchJobResult(int rows, TDJobOperator job)
{
    Optional<ArrayValue> firstRow = pollingRetryExecutor(state, RESULT)
            .retryUnless(TDOperator::isDeterministicClientException)
            .withErrorMessage("Failed to download result of job '%s'", job.getJobId())
            .withRetryInterval(retryInterval)
            .run(s -> job.getResult(
                    ite -> ite.hasNext()
                            ? Optional.of(ite.next())
                            : Optional.absent()));

    if (!firstRow.isPresent()) {
        throw new TaskExecutionException("Got unexpected empty result for count job: " + job.getJobId());
    }
    ArrayValue row = firstRow.get();
    if (row.size() != 1) {
        throw new TaskExecutionException("Got unexpected result row size for count job: " + row.size());
    }
    Value count = row.get(0);
    IntegerValue actualRows;
    try {
        actualRows = count.asIntegerValue();
    }
    catch (MessageTypeCastException e) {
        throw new TaskExecutionException("Got unexpected value type count job: " + count.getValueType());
    }

    return BigInteger.valueOf(rows).compareTo(actualRows.asBigInteger()) <= 0;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:30,代码来源:TdWaitTableOperatorFactory.java


示例9: addCsvRow

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private static void addCsvRow(Writer out, ArrayValue row)
    throws IOException
{
    boolean first = true;
    for (Value v : row) {
        if (first) { first = false; }
        else { out.write(DELIMITER_CHAR); }
        addCsvValue(out, v);
    }
    out.write("\r\n");
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:12,代码来源:TdOperatorFactory.java


示例10: buildStoreParams

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
static Config buildStoreParams(ConfigFactory cf, TDJobOperator j, boolean storeLastResults, TaskState state, DurationInterval retryInterval)
{
    if (storeLastResults) {
        Config td = cf.create();

        List<ArrayValue> results = downloadFirstResults(j, 1, state, RESULT, retryInterval);
        Map<RawValue, Value> map = new LinkedHashMap<>();
        if (!results.isEmpty()) {
            ArrayValue row = results.get(0);
            List<String> columnNames = j.getResultColumnNames();
            for (int i = 0; i < Math.min(row.size(), columnNames.size()); i++) {
                map.put(ValueFactory.newString(columnNames.get(i)), row.get(i));
            }
        }
        MapValue lastResults = ValueFactory.newMap(map);
        try {
            td.set("last_results", new ObjectMapper().readTree(lastResults.toJson()));
        }
        catch (IOException ex) {
            throw Throwables.propagate(ex);
        }

        return cf.create().set("td", td);
    }
    else {
        return cf.create();
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:29,代码来源:TdOperatorFactory.java


示例11: downloadFirstResults

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private static List<ArrayValue> downloadFirstResults(TDJobOperator j, int max, TaskState state, String stateKey, DurationInterval retryInterval)
{
    return pollingRetryExecutor(state, stateKey)
            .retryUnless(TDOperator::isDeterministicClientException)
            .withRetryInterval(retryInterval)
            .withErrorMessage("Failed to download result of job '%s'", j.getJobId())
            .run(s -> {
                try {
                    return j.getResult(ite -> {
                        List<ArrayValue> results = new ArrayList<>(max);
                        for (int i = 0; i < max; i++) {
                            if (ite.hasNext()) {
                                ArrayValue row = ite.next().asArrayValue();
                                results.add(row);
                            }
                            else {
                                break;
                            }
                        }
                        return results;
                    });
                }
                catch (TDClientHttpNotFoundException ex) {
                    // this happens if query is INSERT or CREATE. return empty results
                    return ImmutableList.of();
                }
            });
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:29,代码来源:TdOperatorFactory.java


示例12: row

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private Config row(List<String> keys, ArrayValue values)
{
    Config config = configFactory.create();
    // TODO: fail on keys and values count mismatch?
    int n = Math.min(keys.size(), values.size());
    for (int i = 0; i < n; i++) {
        config.set(keys.get(i), value(values.get(i)));
    }
    return config;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:11,代码来源:TdForEachOperatorFactory.java


示例13: isDestinationSelf

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private boolean isDestinationSelf(ArrayValue dest) {
    return host.equals(dest.get(0).asStringValue().asString())
            && port == dest.get(1).asIntegerValue().asShort()
            && name.equals(dest.get(2).asStringValue().asString());
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:6,代码来源:ClientCore.java


示例14: decodeMultiEventStream

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private List<EventEntry> decodeMultiEventStream(final ArrayValue value) {
  return value.list().stream().map(this::decodeEntry).collect(Collectors.toList());
}
 
开发者ID:okumin,项目名称:influent,代码行数:4,代码来源:MsgpackForwardRequestDecoder.java


示例15: serializeIterable

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private ArrayValue serializeIterable( Options options, Iterable<?> iterable )
{
    return serializeStream( options, StreamSupport.stream( iterable.spliterator(), false ) );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:5,代码来源:MessagePackSerializer.java


示例16: serializeStream

import org.msgpack.value.ArrayValue; //导入依赖的package包/类
private ArrayValue serializeStream( Options options, Stream<?> stream )
{
    return ValueFactory.newArray( stream.map( element -> doSerialize( options, element, false ) )
                                        .collect( toList() ) );
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:6,代码来源:MessagePackSerializer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DeleteByExampleMethodGenerator类代码示例发布时间:2022-05-22
下一篇:
Java ZipHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap