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


Java FBUtilities.MAX_UNSIGNED_SHORT属性代码示例

本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.MAX_UNSIGNED_SHORT属性的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.MAX_UNSIGNED_SHORT属性的具体用法?Java FBUtilities.MAX_UNSIGNED_SHORT怎么用?Java FBUtilities.MAX_UNSIGNED_SHORT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.cassandra.utils.FBUtilities的用法示例。


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

示例1: bind

public Value bind(QueryOptions options) throws InvalidRequestException
{
    List<ByteBuffer> buffers = new ArrayList<ByteBuffer>(elements.size());
    for (Term t : elements)
    {
        ByteBuffer bytes = t.bindAndGet(options);

        if (bytes == null)
            throw new InvalidRequestException("null is not supported inside collections");

        // We don't support value > 64K because the serialization format encode the length as an unsigned short.
        if (bytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("List value is too long. List values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            bytes.remaining()));

        buffers.add(bytes);
    }
    return new Value(buffers);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:Lists.java

示例2: bind

public Value bind(QueryOptions options) throws InvalidRequestException
{
    Map<ByteBuffer, ByteBuffer> buffers = new TreeMap<ByteBuffer, ByteBuffer>(comparator);
    for (Map.Entry<Term, Term> entry : elements.entrySet())
    {
        // We don't support values > 64K because the serialization format encode the length as an unsigned short.
        ByteBuffer keyBytes = entry.getKey().bindAndGet(options);
        if (keyBytes == null)
            throw new InvalidRequestException("null is not supported inside collections");
        if (keyBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Map key is too long. Map keys are limited to %d bytes but %d bytes keys provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            keyBytes.remaining()));

        ByteBuffer valueBytes = entry.getValue().bindAndGet(options);
        if (valueBytes == null)
            throw new InvalidRequestException("null is not supported inside collections");
        if (valueBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Map value is too long. Map values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            valueBytes.remaining()));

        buffers.put(keyBytes, valueBytes);
    }
    return new Value(buffers);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:Maps.java

示例3: deserialize

public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputStream input, ColumnFamilyStore cfs) throws IOException
{
    int keyLength = input.readInt();
    if (keyLength > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new IOException(String.format("Corrupted key cache. Key length of %d is longer than maximum of %d",
                                            keyLength, FBUtilities.MAX_UNSIGNED_SHORT));
    }
    ByteBuffer key = ByteBufferUtil.read(input, keyLength);
    int generation = input.readInt();
    SSTableReader reader = findDesc(generation, cfs.getSSTables());
    input.readBoolean(); // backwards compatibility for "promoted indexes" boolean
    if (reader == null)
    {
        RowIndexEntry.Serializer.skipPromotedIndex(input);
        return null;
    }
    RowIndexEntry entry = reader.metadata.comparator.rowIndexEntrySerializer().deserialize(input, reader.descriptor.version);
    return Futures.immediateFuture(Pair.create(new KeyCacheKey(cfs.metadata.cfId, reader.descriptor, key), entry));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:CacheService.java

示例4: bind

public Value bind(List<ByteBuffer> values) throws InvalidRequestException
{
    Set<ByteBuffer> buffers = new TreeSet<ByteBuffer>(comparator);
    for (Term t : elements)
    {
        ByteBuffer bytes = t.bindAndGet(values);

        if (bytes == null)
            throw new InvalidRequestException("null is not supported inside collections");

        // We don't support value > 64K because the serialization format encode the length as an unsigned short.
        if (bytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Set value is too long. Set values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            bytes.remaining()));

        buffers.add(bytes);
    }
    return new Value(buffers);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:Sets.java

示例5: bind

public Value bind(List<ByteBuffer> values) throws InvalidRequestException
{
    List<ByteBuffer> buffers = new ArrayList<ByteBuffer>(elements.size());
    for (Term t : elements)
    {
        ByteBuffer bytes = t.bindAndGet(values);

        if (bytes == null)
            throw new InvalidRequestException("null is not supported inside collections");

        // We don't support value > 64K because the serialization format encode the length as an unsigned short.
        if (bytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("List value is too long. List values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            bytes.remaining()));

        buffers.add(bytes);
    }
    return new Value(buffers);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:Lists.java

示例6: bind

public Value bind(List<ByteBuffer> values) throws InvalidRequestException
{
    Map<ByteBuffer, ByteBuffer> buffers = new TreeMap<ByteBuffer, ByteBuffer>(comparator);
    for (Map.Entry<Term, Term> entry : elements.entrySet())
    {
        // We don't support values > 64K because the serialization format encode the length as an unsigned short.
        ByteBuffer keyBytes = entry.getKey().bindAndGet(values);
        if (keyBytes == null)
            throw new InvalidRequestException("null is not supported inside collections");
        if (keyBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Map key is too long. Map keys are limited to %d bytes but %d bytes keys provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            keyBytes.remaining()));

        ByteBuffer valueBytes = entry.getValue().bindAndGet(values);
        if (valueBytes == null)
            throw new InvalidRequestException("null is not supported inside collections");
        if (valueBytes.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Map value is too long. Map values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            valueBytes.remaining()));

        buffers.put(keyBytes, valueBytes);
    }
    return new Value(buffers);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:26,代码来源:Maps.java

示例7: validateKey

public static void validateKey(CFMetaData metadata, ByteBuffer key) throws org.apache.cassandra.exceptions.InvalidRequestException
{
    if (key == null || key.remaining() == 0)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("Key may not be empty");
    }

    // check that key can be handled by FBUtilities.writeShortByteArray
    if (key.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("Key length of " + key.remaining() +
                                                                          " is longer than maximum of " +
                                                                          FBUtilities.MAX_UNSIGNED_SHORT);
    }

    try
    {
        metadata.getKeyValidator().validate(key);
    }
    catch (MarshalException e)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:ThriftValidation.java

示例8: testMapsWithElementsBiggerThan64K

@Test
public void testMapsWithElementsBiggerThan64K() throws Throwable
{
    byte[] bytes = new byte[FBUtilities.MAX_UNSIGNED_SHORT + 10];
    Arrays.fill(bytes, (byte) 1);
    String largeText = new String(bytes);

    bytes = new byte[FBUtilities.MAX_UNSIGNED_SHORT + 10];
    Arrays.fill(bytes, (byte) 2);
    String largeText2 = new String(bytes);

    createTable("CREATE TABLE %s (k int PRIMARY KEY, m frozen<map<text, text>>)");

    execute("INSERT INTO %s(k, m) VALUES (0, ?)", map(largeText, "v1", "k2", largeText));
    flush();

    assertRows(execute("SELECT m FROM %s WHERE k = 0"),
        row(map(largeText, "v1", "k2", largeText)));

    // Full overwrite
    execute("UPDATE %s SET m = ? WHERE k = 0", map("k5", largeText, largeText2, "v6"));
    flush();

    assertRows(execute("SELECT m FROM %s WHERE k = 0"),
               row(map("k5", largeText, largeText2, "v6")));

    execute("DELETE m FROM %s WHERE k = 0");

    assertRows(execute("SELECT m FROM %s WHERE k = 0"), row((Object) null));

    execute("INSERT INTO %s(k, m) VALUES (0, {'" + largeText + "' : 'v1', 'k2' : '" + largeText + "'})");
    flush();

    assertRows(execute("SELECT m FROM %s WHERE k = 0"),
               row(map(largeText, "v1", "k2", largeText)));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:36,代码来源:FrozenCollectionsTest.java

示例9: validateIndexedValue

private void validateIndexedValue(ByteBuffer value)
{
    if (value != null && value.remaining() >= FBUtilities.MAX_UNSIGNED_SHORT)
        throw new InvalidRequestException(String.format(
                                                       "Cannot index value of size %d for index %s on %s.%s(%s) (maximum allowed size=%d)",
                                                       value.remaining(),
                                                       metadata.name,
                                                       baseCfs.metadata.ksName,
                                                       baseCfs.metadata.cfName,
                                                       indexedColumn.name.toString(),
                                                       FBUtilities.MAX_UNSIGNED_SHORT));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:CustomCassandraIndex.java

示例10: validateKey

public static void validateKey(ByteBuffer key) throws InvalidRequestException
{
    if (key == null || key.remaining() == 0)
    {
        throw new InvalidRequestException("Key may not be empty");
    }

    // check that key can be handled by FBUtilities.writeShortByteArray
    if (key.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new InvalidRequestException("Key length of " + key.remaining() +
                                          " is longer than maximum of " + FBUtilities.MAX_UNSIGNED_SHORT);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:QueryProcessor.java

示例11: calculateChecksum

private static int calculateChecksum(File file) throws IOException
{
    CRC32 crc = new CRC32();
    byte[] buffer = new byte[FBUtilities.MAX_UNSIGNED_SHORT];

    try (InputStream in = Files.newInputStream(file.toPath()))
    {
        int bytesRead;
        while((bytesRead = in.read(buffer)) != -1)
            crc.update(buffer, 0, bytesRead);
    }

    return (int) crc.getValue();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:HintsWriteThenReadTest.java

示例12: testSetsWithElementsBiggerThan64K

@Test
public void testSetsWithElementsBiggerThan64K() throws Throwable
{
    createTable("CREATE TABLE %s (k int PRIMARY KEY, s frozen<set<text>>)");

    byte[] bytes = new byte[FBUtilities.MAX_UNSIGNED_SHORT + 10];
    Arrays.fill(bytes, (byte) 1);
    String largeText = new String(bytes);

    execute("INSERT INTO %s(k, s) VALUES (0, ?)", set(largeText, "v1", "v2"));
    flush();

    assertRows(execute("SELECT s FROM %s WHERE k = 0"), row(set(largeText, "v1", "v2")));

    // Full overwrite
    execute("UPDATE %s SET s = ? WHERE k = 0", set(largeText, "v3"));
    flush();

    assertRows(execute("SELECT s FROM %s WHERE k = 0"), row(set(largeText, "v3")));

    execute("DELETE s FROM %s WHERE k = 0");

    assertRows(execute("SELECT s FROM %s WHERE k = 0"), row((Object) null));

    execute("INSERT INTO %s(k, s) VALUES (0, {'" + largeText + "', 'v1', 'v2'})");
    flush();

    assertRows(execute("SELECT s FROM %s WHERE k = 0"), row(set(largeText, "v1", "v2")));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:FrozenCollectionsTest.java

示例13: deserialize

public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputPlus input, ColumnFamilyStore cfs) throws IOException
{
    //Keyspace and CF name are deserialized by AutoSaving cache and used to fetch the CFS provided as a
    //parameter so they aren't deserialized here, even though they are serialized by this serializer
    int keyLength = input.readInt();
    if (keyLength > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new IOException(String.format("Corrupted key cache. Key length of %d is longer than maximum of %d",
                                            keyLength, FBUtilities.MAX_UNSIGNED_SHORT));
    }
    ByteBuffer key = ByteBufferUtil.read(input, keyLength);
    int generation = input.readInt();
    input.readBoolean(); // backwards compatibility for "promoted indexes" boolean
    SSTableReader reader = null;
    if (cfs == null || !cfs.isKeyCacheEnabled() || (reader = findDesc(generation, cfs.getSSTables(SSTableSet.CANONICAL))) == null)
    {
        // The sstable doesn't exist anymore, so we can't be sure of the exact version and assume its the current version. The only case where we'll be
        // wrong is during upgrade, in which case we fail at deserialization. This is not a huge deal however since 1) this is unlikely enough that
        // this won't affect many users (if any) and only once, 2) this doesn't prevent the node from starting and 3) CASSANDRA-10219 shows that this
        // part of the code has been broken for a while without anyone noticing (it is, btw, still broken until CASSANDRA-10219 is fixed).
        RowIndexEntry.Serializer.skip(input, BigFormat.instance.getLatestVersion());
        return null;
    }
    RowIndexEntry.IndexSerializer<?> indexSerializer = reader.descriptor.getFormat().getIndexSerializer(reader.metadata,
                                                                                                        reader.descriptor.version,
                                                                                                        SerializationHeader.forKeyCache(cfs.metadata));
    RowIndexEntry entry = indexSerializer.deserialize(input);
    return Futures.immediateFuture(Pair.create(new KeyCacheKey(cfs.metadata.ksAndCFName, reader.descriptor, key), entry));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:CacheService.java

示例14: append

/**
 * Appends partition data to this writer.
 *
 * @param iterator the partition to write
 * @return the created index entry if something was written, that is if {@code iterator}
 * wasn't empty, {@code null} otherwise.
 *
 * @throws FSWriteError if a write to the dataFile fails
 */
public RowIndexEntry append(UnfilteredRowIterator iterator)
{
    DecoratedKey key = iterator.partitionKey();

    if (key.getKey().remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        logger.error("Key size {} exceeds maximum of {}, skipping row", key.getKey().remaining(), FBUtilities.MAX_UNSIGNED_SHORT);
        return null;
    }

    if (iterator.isEmpty())
        return null;

    long startPosition = beforeAppend(key);
    observers.forEach((o) -> o.startPartition(key, iwriter.indexFile.position()));

    //Reuse the writer for each row
    columnIndexWriter.reset();

    try (UnfilteredRowIterator collecting = Transformation.apply(iterator, new StatsCollector(metadataCollector)))
    {
        columnIndexWriter.buildRowIndex(collecting);

        // afterAppend() writes the partition key before the first RowIndexEntry - so we have to add it's
        // serialized size to the index-writer position
        long indexFilePosition = ByteBufferUtil.serializedSizeWithShortLength(key.getKey()) + iwriter.indexFile.position();

        RowIndexEntry entry = RowIndexEntry.create(startPosition, indexFilePosition,
                                                   collecting.partitionLevelDeletion(),
                                                   columnIndexWriter.headerLength,
                                                   columnIndexWriter.columnIndexCount,
                                                   columnIndexWriter.indexInfoSerializedSize(),
                                                   columnIndexWriter.indexSamples(),
                                                   columnIndexWriter.offsets(),
                                                   getRowIndexEntrySerializer().indexInfoSerializer());

        long endPosition = dataFile.position();
        long rowSize = endPosition - startPosition;
        maybeLogLargePartitionWarning(key, rowSize);
        metadataCollector.addPartitionSizeInBytes(rowSize);
        afterAppend(key, endPosition, entry, columnIndexWriter.buffer());
        return entry;
    }
    catch (IOException e)
    {
        throw new FSWriteError(e, dataFile.getPath());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:57,代码来源:BigTableWriter.java

示例15: validate

public boolean validate(Cell cell)
{
    return cell.value().remaining() < FBUtilities.MAX_UNSIGNED_SHORT;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:4,代码来源:PerColumnSecondaryIndex.java


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