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


Java ClusteringComparator类代码示例

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


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

示例1: getKeyValidatorAsClusteringComparator

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
public ClusteringComparator getKeyValidatorAsClusteringComparator()
{
    boolean isCompound = keyValidator instanceof CompositeType;
    List<AbstractType<?>> types = isCompound
            ? ((CompositeType) keyValidator).types
            : Collections.<AbstractType<?>>singletonList(keyValidator);
    return new ClusteringComparator(types);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:CFMetaData.java

示例2: compare

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
private int compare(List<ByteBuffer> values1, List<ByteBuffer> values2)
{
    ClusteringComparator comparator = metadata.comparator;
    for (int i = 0; i < Math.min(values1.size(), values2.size()); i++)
    {
        int cmp = comparator.subtype(i).compare(values1.get(i), values2.get(i));
        if (cmp != 0)
            return cmp;
    }
    return 0;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:SSTableReader.java

示例3: isValid

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
boolean isValid(ClusteringComparator comparator, String search, PartitionRangeReadCommand command) {
	if (search.equals(this.search)) {
		DataRange dataRange = command.dataRange();
		return validKey(dataRange) && validPrefix(comparator, dataRange);
	}
	return false;
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:8,代码来源:SearchCacheEntry.java

示例4: validPrefix

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
private boolean validPrefix(ClusteringComparator comparator, DataRange dataRange) {

		// Discard start prefix
		Optional<ClusteringPrefix> start = KeyMapper.startClusteringPrefix(dataRange);
		if (start.isPresent() && startPrefix.isPresent() && comparator.compare(startPrefix.get(), start.get()) > 0) {
			return false;
		}

		// Discard null clusterings
		if (start.isPresent() != currentClustering.isPresent()) {
			return false;
		}

		// Discard clustering
		if (start.isPresent()
				&& comparator.compare(new Clustering(start.get().getRawValues()), currentClustering.get()) != 0) {
			return false;
		}

		// Discard stop prefix
		Optional<ClusteringPrefix> stop = KeyMapper.stopClusteringPrefix(dataRange);
		if (stop.isPresent() && stopPrefix.isPresent() && comparator.compare(stopPrefix.get(), stop.get()) != 0) {
			return false;
		}

		return true;
	}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:28,代码来源:SearchCacheEntry.java

示例5: TestableCSW

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
private TestableCSW(File file, File offsetsFile) throws IOException
{
    this(file, offsetsFile, new CompressedSequentialWriter(file,
                                                           offsetsFile.getPath(),
                                                           CompressionParams.lz4(BUFFER_SIZE),
                                                           new MetadataCollector(new ClusteringComparator(UTF8Type.instance))));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:CompressedSequentialWriterTest.java

示例6: AbstractPrimaryKeyRestrictions

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
public AbstractPrimaryKeyRestrictions(ClusteringComparator comparator)
{
    this.comparator = comparator;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:AbstractPrimaryKeyRestrictions.java

示例7: test6791

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
@Test
public void test6791() throws IOException, ConfigurationException
{
    File f = File.createTempFile("compressed6791_", "3");
    String filename = f.getAbsolutePath();
    try(ChannelProxy channel = new ChannelProxy(f))
    {

        MetadataCollector sstableMetadataCollector = new MetadataCollector(new ClusteringComparator(BytesType.instance));
        try(CompressedSequentialWriter writer = new CompressedSequentialWriter(f, filename + ".metadata", CompressionParams.snappy(32), sstableMetadataCollector))
        {

            for (int i = 0; i < 20; i++)
                writer.write("x".getBytes());

            DataPosition mark = writer.mark();
            // write enough garbage to create new chunks:
            for (int i = 0; i < 40; ++i)
                writer.write("y".getBytes());

            writer.resetAndTruncate(mark);

            for (int i = 0; i < 20; i++)
                writer.write("x".getBytes());
            writer.finish();
        }

        try(RandomAccessReader reader = new CompressedRandomAccessReader.Builder(channel,
                                                                                 new CompressionMetadata(filename + ".metadata", f.length(), ChecksumType.CRC32))
                                        .build())
        {
            String res = reader.readLine();
            assertEquals(res, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
            assertEquals(40, res.length());
        }
    }
    finally
    {
        if (f.exists())
            assertTrue(f.delete());
        File metadata = new File(filename+ ".metadata");
        if (metadata.exists())
            metadata.delete();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:46,代码来源:CompressedRandomAccessReaderTest.java

示例8: testMapForCompressionMetadata

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
@Test
public void testMapForCompressionMetadata() throws Exception
{
    int OLD_MAX_SEGMENT_SIZE = MmappedRegions.MAX_SEGMENT_SIZE;
    MmappedRegions.MAX_SEGMENT_SIZE = 1024;

    ByteBuffer buffer = allocateBuffer(128 * 1024);
    File f = File.createTempFile("testMapForCompressionMetadata", "1");
    f.deleteOnExit();

    File cf = File.createTempFile(f.getName() + ".metadata", "1");
    cf.deleteOnExit();

    MetadataCollector sstableMetadataCollector = new MetadataCollector(new ClusteringComparator(BytesType.instance));
    try(SequentialWriter writer = new CompressedSequentialWriter(f,
                                                                 cf.getAbsolutePath(),
                                                                 CompressionParams.snappy(),
                                                                 sstableMetadataCollector))
    {
        writer.write(buffer);
        writer.finish();
    }

    CompressionMetadata metadata = new CompressionMetadata(cf.getAbsolutePath(), f.length(), ChecksumType.CRC32);
    try(ChannelProxy channel = new ChannelProxy(f);
        MmappedRegions regions = MmappedRegions.map(channel, metadata))
    {

        assertFalse(regions.isEmpty());
        int i = 0;
        while(i < buffer.capacity())
        {
            CompressionMetadata.Chunk chunk = metadata.chunkFor(i);

            MmappedRegions.Region region = regions.floor(chunk.offset);
            assertNotNull(region);

            ByteBuffer compressedChunk = region.buffer.duplicate();
            assertNotNull(compressedChunk);
            assertEquals(chunk.length + 4, compressedChunk.capacity());

            assertEquals(chunk.offset, region.bottom());
            assertEquals(chunk.offset + chunk.length + 4, region.top());

            i += metadata.chunkLength();
        }
    }
    finally
    {
        MmappedRegions.MAX_SEGMENT_SIZE = OLD_MAX_SEGMENT_SIZE;
        metadata.close();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:54,代码来源:MmappedRegionsTest.java

示例9: forPaging

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
/**
 * Returns a filter for continuing the paging of this filter given the last returned clustering prefix.
 *
 * @param comparator the comparator for the table this is a filter for.
 * @param lastReturned the last clustering that was returned for the query we are paging for. The
 * resulting filter will be such that results coming after {@code lastReturned} are returned
 * (where coming after means "greater than" if the filter is not reversed, "lesser than" otherwise;
 * futher, whether the comparison is strict or not depends on {@code inclusive}).
 * @param inclusive whether or not we want to include the {@code lastReturned} in the newly returned
 * page of results.
 *
 * @return a new filter that selects results coming after {@code lastReturned}.
 */
public ClusteringIndexFilter forPaging(ClusteringComparator comparator, Clustering lastReturned, boolean inclusive);
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:ClusteringIndexFilter.java

示例10: clusteringComparator

import org.apache.cassandra.db.ClusteringComparator; //导入依赖的package包/类
/**
 * Returns the clustering key comparator.
 *
 * @return the comparator
 */
public ClusteringComparator clusteringComparator() {
	return clusteringComparator;
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:9,代码来源:KeyMapper.java


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