use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class SystemKeyspace method getBuiltIndexes.
public static List<String> getBuiltIndexes(String keyspaceName, Set<String> indexNames) {
List<String> names = new ArrayList<>(indexNames);
String req = "SELECT index_name from %s.\"%s\" WHERE table_name=? AND index_name IN ?";
UntypedResultSet results = executeInternal(format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, names);
return StreamSupport.stream(results.spliterator(), false).map(r -> r.getString("index_name")).collect(Collectors.toList());
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class SystemKeyspace method getAvailableRanges.
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(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);
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class SystemKeyspace method isIndexBuilt.
public static boolean isIndexBuilt(String keyspaceName, String indexName) {
String req = "SELECT index_name FROM %s.\"%s\" WHERE table_name=? AND index_name=?";
UntypedResultSet result = executeInternal(format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName);
return !result.isEmpty();
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class LocalSessions method start.
/**
* Loads sessions out of the repairs table and sets state to started
*/
public synchronized void start() {
Preconditions.checkArgument(!started, "LocalSessions.start can only be called once");
Preconditions.checkArgument(sessions.isEmpty(), "No sessions should be added before start");
UntypedResultSet rows = QueryProcessor.executeInternalWithPaging(String.format("SELECT * FROM %s.%s", keyspace, table), 1000);
Map<UUID, LocalSession> loadedSessions = new HashMap<>();
for (UntypedResultSet.Row row : rows) {
try {
LocalSession session = load(row);
loadedSessions.put(session.sessionID, session);
} catch (IllegalArgumentException | NullPointerException e) {
logger.warn("Unable to load malformed repair session {}, ignoring", row.has("parent_id") ? row.getUUID("parent_id") : null);
}
}
sessions = ImmutableMap.copyOf(loadedSessions);
started = true;
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class SystemKeyspace method getPreferredIP.
/**
* Get preferred IP for given endpoint if it is known. Otherwise this returns given endpoint itself.
*
* @param ep endpoint address to check
* @return Preferred IP for given endpoint if present, otherwise returns given ep
*/
public static InetAddress getPreferredIP(InetAddress ep) {
String req = "SELECT preferred_ip FROM system.%s WHERE peer=?";
UntypedResultSet result = executeInternal(format(req, PEERS), ep);
if (!result.isEmpty() && result.one().has("preferred_ip"))
return result.one().getInetAddress("preferred_ip");
return ep;
}
Aggregations