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


Java UTF8Type类代码示例

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


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

示例1: deserialize

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public Columns deserialize(DataInputPlus in, CFMetaData metadata) throws IOException
{
    int length = (int)in.readUnsignedVInt();
    BTree.Builder<ColumnDefinition> builder = BTree.builder(Comparator.naturalOrder());
    builder.auto(false);
    for (int i = 0; i < length; i++)
    {
        ByteBuffer name = ByteBufferUtil.readWithVIntLength(in);
        ColumnDefinition column = metadata.getColumnDefinition(name);
        if (column == null)
        {
            // If we don't find the definition, it could be we have data for a dropped column, and we shouldn't
            // fail deserialization because of that. So we grab a "fake" ColumnDefinition that ensure proper
            // deserialization. The column will be ignore later on anyway.
            column = metadata.getDroppedColumnDefinition(name);
            if (column == null)
                throw new RuntimeException("Unknown column " + UTF8Type.instance.getString(name) + " during deserialization");
        }
        builder.add(column);
    }
    return new Columns(builder.build());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:Columns.java

示例2: getIdentifier

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public ColumnIdentifier getIdentifier(CFMetaData cfm)
{
    if (!cfm.isStaticCompactTable())
        return ColumnIdentifier.getInterned(text, true);

    AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
    if (thriftColumnNameType instanceof UTF8Type)
        return ColumnIdentifier.getInterned(text, true);

    // We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
    // thriftColumnNameType
    ByteBuffer bufferName = ByteBufferUtil.bytes(text);
    for (ColumnDefinition def : cfm.allColumns())
    {
        if (def.name.bytes.equals(bufferName))
            return def.name;
    }
    return ColumnIdentifier.getInterned(thriftColumnNameType, thriftColumnNameType.fromString(text), text);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:ColumnDefinition.java

示例3: prepare

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public ColumnDefinition prepare(CFMetaData cfm)
{
    if (!cfm.isStaticCompactTable())
        return find(cfm);

    AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
    if (thriftColumnNameType instanceof UTF8Type)
        return find(cfm);

    // We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
    // thriftColumnNameType
    ByteBuffer bufferName = ByteBufferUtil.bytes(text);
    for (ColumnDefinition def : cfm.allColumns())
    {
        if (def.name.bytes.equals(bufferName))
            return def;
    }
    return find(thriftColumnNameType.fromString(text), cfm);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:ColumnDefinition.java

示例4: insertInIndex

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
@SuppressWarnings("unused")
private boolean insertInIndex(final String indexResourceType, Row row) {
	// only index in the correct lucene index.
	// this code checks if the resourceType is the same as the index.
	// TODO: externalizar resource_type

	for (Cell cell : row.cells()) {
		String columnname = cell.column().name.toString();
		if ("resource_type".equals(columnname)) {
			String resourceType = ByteBufferUtils.toString(cell.value(), UTF8Type.instance);

			if (indexResourceType.equals(resourceType)) {
				return true;
			}
			return false;
		}
	}
	return false;
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:20,代码来源:FhirIndexIndexer.java

示例5: validateAssignableTo

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof UserType))
        throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

    UserType ut = (UserType)receiver.type;
    for (int i = 0; i < ut.size(); i++)
    {
        ColumnIdentifier field = new ColumnIdentifier(ut.fieldName(i), UTF8Type.instance);
        Term.Raw value = entries.get(field);
        if (value == null)
            continue;

        ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
        if (!value.isAssignableTo(keyspace, fieldSpec))
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver, field, fieldSpec.type.asCQL3Type()));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:UserTypes.java

示例6: prepare

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public ColumnIdentifier prepare(CFMetaData cfm)
{
    AbstractType<?> comparator = cfm.comparator.asAbstractType();
    if (cfm.getIsDense() || comparator instanceof CompositeType || comparator instanceof UTF8Type)
        return new ColumnIdentifier(text, true);

    // We have a Thrift-created table with a non-text comparator.  We need to parse column names with the comparator
    // to get the correct ByteBuffer representation.  However, this doesn't apply to key aliases, so we need to
    // make a special check for those and treat them normally.  See CASSANDRA-8178.
    ByteBuffer bufferName = ByteBufferUtil.bytes(text);
    for (ColumnDefinition def : cfm.partitionKeyColumns())
    {
        if (def.name.bytes.equals(bufferName))
            return new ColumnIdentifier(text, true);
    }
    return new ColumnIdentifier(comparator.fromString(rawText), text);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:ColumnIdentifier.java

示例7: list

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public Set<PermissionDetails> list(AuthenticatedUser performer, Set<Permission> permissions, IResource resource, String of)
throws RequestValidationException, RequestExecutionException
{
    if (!performer.isSuper() && !performer.getName().equals(of))
        throw new UnauthorizedException(String.format("You are not authorized to view %s's permissions",
                                                      of == null ? "everyone" : of));

    Set<PermissionDetails> details = new HashSet<PermissionDetails>();

    for (UntypedResultSet.Row row : process(buildListQuery(resource, of)))
    {
        if (row.has(PERMISSIONS))
        {
            for (String p : row.getSet(PERMISSIONS, UTF8Type.instance))
            {
                Permission permission = Permission.valueOf(p);
                if (permissions.contains(permission))
                    details.add(new PermissionDetails(row.getString(USERNAME),
                                                      DataResource.fromName(row.getString(RESOURCE)),
                                                      permission));
            }
        }
    }

    return details;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:CassandraAuthorizer.java

示例8: differentKeyRowMutations

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
@Test
public void differentKeyRowMutations() throws ConfigurationException, InvalidRequestException
{
    CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerDefinition.create("test", DifferentKeyTrigger.class.getName()));
    ColumnFamily cf = makeCf(metadata, "v1", null);
    Mutation rm = new Mutation(UTF8Type.instance.fromString("k1"), cf);

    List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm)));
    assertEquals(2, tmutations.size());
    Collections.sort(tmutations, new RmComparator());

    assertEquals(bytes("k1"), tmutations.get(0).key());
    assertEquals(bytes("otherKey"), tmutations.get(1).key());

    List<ColumnFamily> mutatedCFs = new ArrayList<>(tmutations.get(0).getColumnFamilies());
    assertEquals(1, mutatedCFs.size());
    assertEquals(bytes("v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value());
    assertNull(mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")));

    mutatedCFs = new ArrayList<>(tmutations.get(1).getColumnFamilies());
    assertEquals(1, mutatedCFs.size());
    assertNull(mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")));
    assertEquals(bytes("trigger"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")).value());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:TriggerExecutorTest.java

示例9: readRequiredRows

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
protected Map<ByteBuffer, ColumnGroupMap> readRequiredRows(List<ByteBuffer> partitionKeys, ColumnNameBuilder clusteringPrefix, boolean local, ConsistencyLevel cl)
throws RequestExecutionException, RequestValidationException
{
    // Lists SET operation incurs a read.
    Set<ByteBuffer> toRead = null;
    for (Operation op : columnOperations)
    {
        if (op.requiresRead())
        {
            if (toRead == null)
                toRead = new TreeSet<ByteBuffer>(UTF8Type.instance);
            toRead.add(op.columnName.key);
        }
    }

    return toRead == null ? null : readRows(partitionKeys, clusteringPrefix, toRead, (CompositeType)cfm.comparator, local, cl);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:ModificationStatement.java

示例10: caseInsensitiveAnalizer

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
@Test
public void caseInsensitiveAnalizer() throws Exception
{
    NonTokenizingAnalyzer analyzer = new NonTokenizingAnalyzer();
    NonTokenizingOptions options = NonTokenizingOptions.getDefaultOptions();
    options.setCaseSensitive(false);
    analyzer.init(options, UTF8Type.instance);

    String testString = "Nip it in the bud";
    ByteBuffer toAnalyze = ByteBuffer.wrap(testString.getBytes());
    analyzer.reset(toAnalyze);
    ByteBuffer analyzed = null;
    while (analyzer.hasNext())
        analyzed = analyzer.next();
    Assert.assertTrue(testString.toLowerCase().equals(ByteBufferUtil.string(analyzed)));
}
 
开发者ID:xedin,项目名称:sasi,代码行数:17,代码来源:NonTokenizingAnalyzerTest.java

示例11: testSuperBlockRetrieval

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
@Test
public void testSuperBlockRetrieval() throws Exception
{
    OnDiskIndexBuilder builder = new OnDiskIndexBuilder(UTF8Type.instance, LongType.instance, OnDiskIndexBuilder.Mode.SPARSE);
    for (long i = 0; i < 100000; i++)
        builder.add(LongType.instance.decompose(i), keyAt(i), i);

    File index = File.createTempFile("on-disk-sa-multi-superblock-match", ".db");
    index.deleteOnExit();

    builder.finish(index);

    OnDiskIndex onDiskIndex = new OnDiskIndex(index, LongType.instance, new KeyConverter());

    testSearchRangeWithSuperBlocks(onDiskIndex, 0, 500);
    testSearchRangeWithSuperBlocks(onDiskIndex, 300, 93456);
    testSearchRangeWithSuperBlocks(onDiskIndex, 210, 1700);
    testSearchRangeWithSuperBlocks(onDiskIndex, 530, 3200);

    Random random = new Random(0xdeadbeef);
    for (int i = 0; i < 100000; i += random.nextInt(1500)) // random steps with max of 1500 elements
    {
        for (int j = 0; j < 3; j++)
            testSearchRangeWithSuperBlocks(onDiskIndex, i, ThreadLocalRandom.current().nextInt(i, 100000));
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:27,代码来源:OnDiskIndexTest.java

示例12: testSatisfiedByWithMultipleTerms

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
@Test
public void testSatisfiedByWithMultipleTerms()
{
    final ByteBuffer comment = UTF8Type.instance.decompose("comment");
    final ColumnFamilyStore store = Keyspace.open("sasecondaryindex").getColumnFamilyStore("saindexed1");
    final IPartitioner<?> partitioner = StorageService.getPartitioner();

    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(store.metadata);
    cf.addColumn(new Column(comment, UTF8Type.instance.decompose("software engineer is working on a project"), System.currentTimeMillis()));

    Operation.Builder builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("eng is a work")));
    Operation op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));

    builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("soft works fine")));
    op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));
}
 
开发者ID:xedin,项目名称:sasi,代码行数:23,代码来源:OperationTest.java

示例13: rowToJson

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
private List<ByteBuffer> rowToJson(List<ByteBuffer> row, int protocolVersion)
{
    StringBuilder sb = new StringBuilder("{");
    for (int i = 0; i < metadata.names.size(); i++)
    {
        if (i > 0)
            sb.append(", ");

        ColumnSpecification spec = metadata.names.get(i);
        String columnName = spec.name.toString();
        if (!columnName.equals(columnName.toLowerCase(Locale.US)))
            columnName = "\"" + columnName + "\"";

        ByteBuffer buffer = row.get(i);
        sb.append('"');
        sb.append(Json.quoteAsJsonString(columnName));
        sb.append("\": ");
        if (buffer == null)
            sb.append("null");
        else
            sb.append(spec.type.toJSONString(buffer, protocolVersion));
    }
    sb.append("}");
    return Collections.singletonList(UTF8Type.instance.getSerializer().serialize(sb.toString()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:Selection.java

示例14: validateAssignableTo

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof UserType))
        throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

    UserType ut = (UserType)receiver.type;
    for (int i = 0; i < ut.size(); i++)
    {
        ColumnIdentifier field = new ColumnIdentifier(ut.fieldName(i), UTF8Type.instance);
        Term.Raw value = entries.get(field);
        if (value == null)
            continue;

        ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
        if (!value.testAssignment(keyspace, fieldSpec).isAssignable())
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver, field, fieldSpec.type.asCQL3Type()));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:UserTypes.java

示例15: prepare

import org.apache.cassandra.db.marshal.UTF8Type; //导入依赖的package包/类
public ColumnIdentifier prepare(CFMetaData cfm)
{
    if (!cfm.isStaticCompactTable())
        return getInterned(text, true);

    AbstractType<?> thriftColumnNameType = cfm.thriftColumnNameType();
    if (thriftColumnNameType instanceof UTF8Type)
        return getInterned(text, true);

    // We have a Thrift-created table with a non-text comparator. Check if we have a match column, otherwise assume we should use
    // thriftColumnNameType
    ByteBuffer bufferName = ByteBufferUtil.bytes(text);
    for (ColumnDefinition def : cfm.allColumns())
    {
        if (def.name.bytes.equals(bufferName))
            return def.name;
    }
    return getInterned(thriftColumnNameType.fromString(rawText), text);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:ColumnIdentifier.java


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