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


Java UntypedResultSet.Row方法代码示例

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


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

示例1: list

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的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

示例2: loadDcRackInfo

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Return a map of IP addresses containing a map of dc and rack info
 */
public static Map<InetAddress, Map<String,String>> loadDcRackInfo()
{
    Map<InetAddress, Map<String, String>> result = new HashMap<InetAddress, Map<String, String>>();
    for (UntypedResultSet.Row row : processInternal("SELECT peer, data_center, rack from system." + PEERS_CF))
    {
        InetAddress peer = row.getInetAddress("peer");
        if (row.has("data_center") && row.has("rack"))
        {
            Map<String, String> dcRack = new HashMap<String, String>();
            dcRack.put("data_center", row.getString("data_center"));
            dcRack.put("rack", row.getString("rack"));
            result.put(peer, dcRack);
        }
    }
    return result;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:SystemKeyspace.java

示例3: getUnfinishedCompactions

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Returns a Map whose keys are KS.CF pairs and whose values are maps from sstable generation numbers to the
 * task ID of the compaction they were participating in.
 */
public static Map<Pair<String, String>, Map<Integer, UUID>> getUnfinishedCompactions()
{
    String req = "SELECT * FROM system.%s";
    UntypedResultSet resultSet = executeInternal(String.format(req, COMPACTION_LOG));

    Map<Pair<String, String>, Map<Integer, UUID>> unfinishedCompactions = new HashMap<>();
    for (UntypedResultSet.Row row : resultSet)
    {
        String keyspace = row.getString("keyspace_name");
        String columnfamily = row.getString("columnfamily_name");
        Set<Integer> inputs = row.getSet("inputs", Int32Type.instance);
        UUID taskID = row.getUUID("id");

        Pair<String, String> kscf = Pair.create(keyspace, columnfamily);
        Map<Integer, UUID> generationToTaskID = unfinishedCompactions.get(kscf);
        if (generationToTaskID == null)
            generationToTaskID = new HashMap<>(inputs.size());

        for (Integer generation : inputs)
            generationToTaskID.put(generation, taskID);

        unfinishedCompactions.put(kscf, generationToTaskID);
    }
    return unfinishedCompactions;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:30,代码来源:SystemKeyspace.java

示例4: waitForMinor

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private void waitForMinor(String keyspace, String cf, long maxWaitTime, boolean shouldFind) throws Throwable
{
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() - startTime < maxWaitTime)
    {
        UntypedResultSet res = execute("SELECT * FROM system.compaction_history");
        for (UntypedResultSet.Row r : res)
        {
            if (r.getString("keyspace_name").equals(keyspace) && r.getString("columnfamily_name").equals(cf))
                if (shouldFind)
                    return;
                else
                    fail("Found minor compaction");
        }
        Thread.sleep(100);
    }
    if (shouldFind)
        fail("No minor compaction triggered in "+maxWaitTime+"ms");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:CompactionsCQLTest.java

示例5: testValidationCompactStorage

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * For CASSANDRA-6892 too, check that for a compact table with one cluster column, we can insert whatever
 * we want as value for the clustering column, including something that would conflict with a CQL column definition.
 */
@Test
public void testValidationCompactStorage() throws Exception
{
    QueryProcessor.process(String.format("CREATE TABLE \"%s\".test_compact_dynamic_columns (a int, b text, c text, PRIMARY KEY (a, b)) WITH COMPACT STORAGE", KEYSPACE), ConsistencyLevel.ONE);

    Keyspace keyspace = Keyspace.open(KEYSPACE);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("test_compact_dynamic_columns");

    QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'a', 'foo')", KEYSPACE));
    QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'b', 'bar')", KEYSPACE));
    QueryProcessor.executeInternal(String.format("INSERT INTO \"%s\".test_compact_dynamic_columns (a, b, c) VALUES (0, 'c', 'boo')", KEYSPACE));
    cfs.forceBlockingFlush();
    CompactionManager.instance.performScrub(cfs, true, true, 2);

    // Scrub is silent, but it will remove broken records. So reading everything back to make sure nothing to "scrubbed away"
    UntypedResultSet rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".test_compact_dynamic_columns", KEYSPACE));
    assertEquals(3, rs.size());

    Iterator<UntypedResultSet.Row> iter = rs.iterator();
    assertEquals("foo", iter.next().getString("c"));
    assertEquals("bar", iter.next().getString("c"));
    assertEquals("boo", iter.next().getString("c"));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:28,代码来源:ScrubTest.java

示例6: fromSchema

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Deserialize only Keyspace attributes without nested ColumnFamilies
 *
 * @param row Keyspace attributes in serialized form
 *
 * @return deserialized keyspace without cf_defs
 */
public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes)
{
    UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one();
    try
    {
        return new KSMetaData(result.getString("keyspace_name"),
                              AbstractReplicationStrategy.getClass(result.getString("strategy_class")),
                              fromJsonMap(result.getString("strategy_options")),
                              result.getBoolean("durable_writes"),
                              cfms,
                              userTypes);
    }
    catch (ConfigurationException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:KSMetaData.java

示例7: replayBatch

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private void replayBatch(UUID id)
{
    logger.debug("Replaying batch {}", id);

    UntypedResultSet result = process("SELECT written_at, data FROM %s.%s WHERE id = %s", Keyspace.SYSTEM_KS, SystemKeyspace.BATCHLOG_CF, id);
    if (result.isEmpty())
        return;

    try
    {
        UntypedResultSet.Row batch = result.one();
        replaySerializedMutations(batch.getBytes("data"), batch.getLong("written_at"));
    }
    catch (IOException e)
    {
        logger.warn("Skipped batch replay of {} due to {}", id, e);
    }

    process("DELETE FROM %s.%s WHERE id = %s", Keyspace.SYSTEM_KS, SystemKeyspace.BATCHLOG_CF, id);

    totalBatchesReplayed.incrementAndGet();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:23,代码来源:BatchlogManager.java

示例8: getSSTableReadMeter

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM %s WHERE keyspace_name='%s' and columnfamily_name='%s' and generation=%d";
    UntypedResultSet results = processInternal(String.format(cql,
                                                             SSTABLE_ACTIVITY_CF,
                                                             keyspace,
                                                             table,
                                                             generation));

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:SystemKeyspace.java

示例9: replayAllFailedBatches

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private void replayAllFailedBatches() throws ExecutionException, InterruptedException
{
    if (!isReplaying.compareAndSet(false, true))
        return;

    logger.debug("Started replayAllFailedBatches");

    try
    {
        for (UntypedResultSet.Row row : process("SELECT id, written_at FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.BATCHLOG_CF))
            if (System.currentTimeMillis() > row.getLong("written_at") + TIMEOUT)
                replayBatch(row.getUUID("id"));
        cleanup();
    }
    finally
    {
        isReplaying.set(false);
    }

    logger.debug("Finished replayAllFailedBatches");
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:BatchlogManager.java

示例10: checkNeedsUpgrade

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private static boolean checkNeedsUpgrade(Iterable<UntypedResultSet.Row> defs, boolean isSuper, boolean isStaticCompactTable)
{
    if (isSuper)
    {
        // Check if we've added the "supercolumn map" column yet or not
        for (UntypedResultSet.Row row : defs)
            if (row.getString("column_name").isEmpty())
                return false;
        return true;
    }

    // For static compact tables, we need to upgrade if the regular definitions haven't been converted to static yet,
    // i.e. if we don't have a static definition yet.
    if (isStaticCompactTable)
        return !hasKind(defs, ColumnDefinition.Kind.STATIC);

    // For dense compact tables, we need to upgrade if we don't have a compact value definition
    return !hasRegularColumns(defs);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:LegacySchemaMigrator.java

示例11: loadDcRackInfo

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Return a map of IP addresses containing a map of dc and rack info
 */
public static Map<InetAddress, Map<String,String>> loadDcRackInfo()
{
    Map<InetAddress, Map<String, String>> result = new HashMap<>();
    for (UntypedResultSet.Row row : executeInternal("SELECT peer, data_center, rack from system." + PEERS))
    {
        InetAddress peer = row.getInetAddress("peer");
        if (row.has("data_center") && row.has("rack"))
        {
            Map<String, String> dcRack = new HashMap<>();
            dcRack.put("data_center", row.getString("data_center"));
            dcRack.put("rack", row.getString("rack"));
            result.put(peer, dcRack);
        }
    }
    return result;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:SystemKeyspace.java

示例12: getAvailableRanges

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static synchronized Set<Range<Token>> getAvailableRanges(String keyspace, IPartitioner partitioner)
{
    Set<Range<Token>> result = new HashSet<>();
    String query = "SELECT * FROM system.%s WHERE keyspace_name=?";
    UntypedResultSet rs = executeInternal(String.format(query, AVAILABLE_RANGES), keyspace);
    for (UntypedResultSet.Row row : rs)
    {
        Set<ByteBuffer> rawRanges = row.getSet("ranges", BytesType.instance);
        for (ByteBuffer rawRange : rawRanges)
        {
            result.add(byteBufferToRange(rawRange, partitioner));
        }
    }
    return ImmutableSet.copyOf(result);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:SystemKeyspace.java

示例13: testFunctionWithReservedName

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
@Test
public void testFunctionWithReservedName() throws Throwable
{
    execute("CREATE TABLE " + KEYSPACE_PER_TEST + ".second_tab (key int primary key, val double)");

    String fName = createFunction(KEYSPACE_PER_TEST, "",
                                  "CREATE OR REPLACE FUNCTION %s() " +
                                  "RETURNS NULL ON NULL INPUT " +
                                  "RETURNS timestamp " +
                                  "LANGUAGE JAVA " +
                                  "AS 'return null;';");

    execute("INSERT INTO " + KEYSPACE_PER_TEST + ".second_tab (key, val) VALUES (?, ?)", 1, 1d);
    execute("INSERT INTO " + KEYSPACE_PER_TEST + ".second_tab (key, val) VALUES (?, ?)", 2, 2d);
    execute("INSERT INTO " + KEYSPACE_PER_TEST + ".second_tab (key, val) VALUES (?, ?)", 3, 3d);

    // ensure that system now() is executed
    UntypedResultSet rows = execute("SELECT key, val, now() FROM " + KEYSPACE_PER_TEST + ".second_tab");
    Assert.assertEquals(3, rows.size());
    UntypedResultSet.Row row = rows.iterator().next();
    Date ts = row.getTimestamp(row.getColumns().get(2).name.toString());
    Assert.assertNotNull(ts);

    // ensure that KEYSPACE_PER_TEST's now() is executed
    rows = execute("SELECT key, val, " + fName + "() FROM " + KEYSPACE_PER_TEST + ".second_tab");
    Assert.assertEquals(3, rows.size());
    row = rows.iterator().next();
    Assert.assertFalse(row.has(row.getColumns().get(2).name.toString()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:30,代码来源:UFTest.java

示例14: loadHostIds

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Return a map of store host_ids to IP addresses
 *
 */
public static Map<InetAddress, UUID> loadHostIds()
{
    Map<InetAddress, UUID> hostIdMap = new HashMap<InetAddress, UUID>();
    for (UntypedResultSet.Row row : executeInternal("SELECT peer, host_id FROM system." + PEERS_CF))
    {
        InetAddress peer = row.getInetAddress("peer");
        if (row.has("host_id"))
        {
            hostIdMap.put(peer, row.getUUID("host_id"));
        }
    }
    return hostIdMap;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:SystemKeyspace.java

示例15: compactionFromRow

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static CompactionParams compactionFromRow(UntypedResultSet.Row row)
{
    Class<? extends AbstractCompactionStrategy> klass =
        CFMetaData.createCompactionStrategy(row.getString("compaction_strategy_class"));
    Map<String, String> options = fromJsonMap(row.getString("compaction_strategy_options"));

    int minThreshold = row.getInt("min_compaction_threshold");
    int maxThreshold = row.getInt("max_compaction_threshold");

    Map<String, String> optionsWithThresholds = new HashMap<>(options);
    optionsWithThresholds.putIfAbsent(CompactionParams.Option.MIN_THRESHOLD.toString(), Integer.toString(minThreshold));
    optionsWithThresholds.putIfAbsent(CompactionParams.Option.MAX_THRESHOLD.toString(), Integer.toString(maxThreshold));

    try
    {
        Map<String, String> unrecognizedOptions =
            (Map<String, String>) klass.getMethod("validateOptions", Map.class).invoke(null, optionsWithThresholds);

        if (unrecognizedOptions.isEmpty())
            options = optionsWithThresholds;
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }

    return CompactionParams.create(klass, options);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:30,代码来源:LegacySchemaMigrator.java


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