Examples of UntypedResultSet


Examples of org.apache.cassandra.cql3.UntypedResultSet

    public static UUID getLocalHostId()
    {
        UUID hostId = null;

        String req = "SELECT host_id FROM system.%s WHERE key='%s'";
        UntypedResultSet result = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));

        // Look up the Host UUID (return it if found)
        if (!result.isEmpty() && result.one().has("host_id"))
        {
            return result.one().getUUID("host_id");
        }

        // ID not found, generate a new one, persist, and then return it.
        hostId = UUID.randomUUID();
        logger.warn("No host ID found, created {} (Note: This should happen exactly once per node).", hostId);
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

    }

    public static PaxosState loadPaxosState(ByteBuffer key, CFMetaData metadata)
    {
        String req = "SELECT * FROM system.%s WHERE row_key = 0x%s AND cf_id = %s";
        UntypedResultSet results = processInternal(String.format(req, PAXOS_CF, ByteBufferUtil.bytesToHex(key), metadata.cfId));
        if (results.isEmpty())
            return new PaxosState(key, metadata);
        UntypedResultSet.Row row = results.one();
        Commit inProgress = new Commit(key,
                                       row.getUUID("in_progress_ballot"),
                                       row.has("proposal") ? ColumnFamily.fromBytes(row.getBytes("proposal")) : EmptyColumns.factory.create(metadata));
        // either most_recent_commit and most_recent_commit_at will both be set, or neither
        Commit mostRecent = row.has("most_recent_commit")
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

     * @param username Username to query.
     * @return true is the user is a superuser, false if they aren't or don't exist at all.
     */
    public static boolean isSuperuser(String username)
    {
        UntypedResultSet result = selectUser(username);
        return !result.isEmpty() && result.one().getBoolean("super");
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

    {
        try
        {
            ResultMessage.Rows rows = selectUserStatement.execute(new QueryState(new ClientState(true)),
                                                                  new QueryOptions(consistencyForUser(username), Lists.newArrayList(ByteBufferUtil.bytes(username))));
            return new UntypedResultSet(rows.result);
        }
        catch (RequestValidationException e)
        {
            throw new AssertionError(e); // not supposed to happen
        }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

    {
        CacheService.instance.setRowCacheCapacityInMB(1);
        createTable("CREATE TABLE %s (p1 bigint, c1 int, PRIMARY KEY (p1, c1)) WITH caching = '{\"keys\":\"NONE\", \"rows_per_partition\":\"ALL\"}'");
        execute("INSERT INTO %s (p1, c1) VALUES (123, 10)");
        assertEmpty(execute("SELECT * FROM %s WHERE p1=123 and c1 > 1000"));
        UntypedResultSet res = execute("SELECT * FROM %s WHERE p1=123 and c1 > 0");
        assertEquals(1, res.size());
        assertEmpty(execute("SELECT * FROM %s WHERE p1=123 and c1 > 1000"));
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

     * @param username Username to query.
     * @return true is the user is a superuser, false if they aren't or don't exist at all.
     */
    public static boolean isSuperuser(String username)
    {
        UntypedResultSet result = selectUser(username);
        return !result.isEmpty() && result.one().getBoolean("super");
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

        UntypedResultSet.Row cfRow = new UntypedResultSet.Row(convertThriftCqlRow(cf));

        List<Map<String, ByteBuffer>> cols = new ArrayList<>(columnsRes.rows.size());
        for (CqlRow row : columnsRes.rows)
            cols.add(convertThriftCqlRow(row));
        UntypedResultSet colsRow = UntypedResultSet.create(cols);

        return fromSchemaNoTriggers(cfRow, colsRow);
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

        File tempSS = tempSSTableFile(cql_keyspace, cql_table);
        new SSTableImport(true).importJson(jsonUrl, cql_keyspace, cql_table, tempSS.getPath());
        SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
        Keyspace.open(cql_keyspace).getColumnFamilyStore(cql_table).addSSTable(reader);
       
        UntypedResultSet result = QueryProcessor.executeOnceInternal(String.format("SELECT * FROM %s.%s", cql_keyspace, cql_table));
        assertThat(result.size(), is(2));
        assertThat(result, hasItem(withElements(1, "NY", 1980)));
        assertThat(result, hasItem(withElements(2, "CA", 2014)));
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

        UntypedResultSet.Row cfRow = new UntypedResultSet.Row(convertThriftCqlRow(cf));

        List<Map<String, ByteBuffer>> cols = new ArrayList<>(columnsRes.rows.size());
        for (CqlRow row : columnsRes.rows)
            cols.add(convertThriftCqlRow(row));
        UntypedResultSet colsRow = UntypedResultSet.create(cols);

        return fromSchemaNoTriggers(cfRow, colsRow);
    }
View Full Code Here

Examples of org.apache.cassandra.cql3.UntypedResultSet

    }

    public static Map<UUID, Pair<ReplayPosition, Long>> getTruncationRecords()
    {
        String req = "SELECT truncated_at FROM system.%s WHERE key = '%s'";
        UntypedResultSet rows = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));
        if (rows.isEmpty())
            return Collections.emptyMap();

        UntypedResultSet.Row row = rows.one();
        Map<UUID, ByteBuffer> rawMap = row.getMap("truncated_at", UUIDType.instance, BytesType.instance);
        if (rawMap == null)
            return Collections.emptyMap();

        Map<UUID, Pair<ReplayPosition, Long>> positions = new HashMap<UUID, Pair<ReplayPosition, Long>>();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.