Java Code Examples for org.apache.cassandra.config.DatabaseDescriptor#getPartitioner()
The following examples show how to use
org.apache.cassandra.config.DatabaseDescriptor#getPartitioner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraUtils.java From sstable-tools with Apache License 2.0 | 6 votes |
public static Cluster loadTablesFromRemote(String host, int port, String cfidOverrides) throws IOException { Map<String, UUID> cfs = parseOverrides(cfidOverrides); Cluster.Builder builder = Cluster.builder().addContactPoints(host).withPort(port); Cluster cluster = builder.build(); Metadata metadata = cluster.getMetadata(); IPartitioner partitioner = FBUtilities.newPartitioner(metadata.getPartitioner()); if (DatabaseDescriptor.getPartitioner() == null) DatabaseDescriptor.setPartitionerUnsafe(partitioner); for (com.datastax.driver.core.KeyspaceMetadata ksm : metadata.getKeyspaces()) { if (!ksm.getName().equals("system")) { for (TableMetadata tm : ksm.getTables()) { String name = ksm.getName()+"."+tm.getName(); try { CassandraUtils.tableFromCQL( new ByteArrayInputStream(tm.asCQLQuery().getBytes()), cfs.get(name) != null ? cfs.get(name) : tm.getId()); } catch(SyntaxException e) { // ignore tables that we cant parse (probably dse) logger.debug("Ignoring table " + name + " due to syntax exception " + e.getMessage()); } } } } return cluster; }
Example 2
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
IPartitioner setPartitionerUnsafe(IPartitioner newPartitioner) { IPartitioner oldPartitioner = DatabaseDescriptor.getPartitioner(); DatabaseDescriptor.setPartitioner(newPartitioner); valueFactory = new VersionedValue.VersionedValueFactory(getPartitioner()); return oldPartitioner; }
Example 3
Source File: SSTableImport.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Convert a JSON formatted file to an SSTable. * * @param jsonFile the file containing JSON formatted data * @param keyspace keyspace the data belongs to * @param cf column family the data belongs to * @param ssTablePath file to write the SSTable to * * @throws IOException for errors reading/writing input/output */ public int importJson(String jsonFile, String keyspace, String cf, String ssTablePath) throws IOException { ColumnFamily columnFamily = ArrayBackedSortedColumns.factory.create(keyspace, cf); IPartitioner partitioner = DatabaseDescriptor.getPartitioner(); int importedKeys = (isSorted) ? importSorted(jsonFile, columnFamily, ssTablePath, partitioner) : importUnsorted(jsonFile, columnFamily, ssTablePath, partitioner); if (importedKeys != -1) System.out.printf("%d keys imported successfully.%n", importedKeys); return importedKeys; }
Example 4
Source File: AbstractSSTableSimpleWriter.java From stratio-cassandra with Apache License 2.0 | 5 votes |
protected SSTableWriter getWriter() { return new SSTableWriter( makeFilename(directory, metadata.ksName, metadata.cfName), 0, // We don't care about the bloom filter ActiveRepairService.UNREPAIRED_SSTABLE, metadata, DatabaseDescriptor.getPartitioner(), new MetadataCollector(metadata.comparator)); }
Example 5
Source File: TokenMapper.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Returns a new {@link TokenMapper} instance for the current partitioner using the specified column family * metadata. * * @param metadata The column family metadata. * @return A new {@link TokenMapper} instance for the current partitioner. */ public static TokenMapper instance(CFMetaData metadata) { IPartitioner partitioner = DatabaseDescriptor.getPartitioner(); if (partitioner instanceof Murmur3Partitioner) { return new TokenMapperMurmur(metadata); } else { return new TokenMapperGeneric(metadata); } }
Example 6
Source File: QueryPlan.java From sasi with Apache License 2.0 | 4 votes |
public List<Row> execute() throws RequestTimeoutException { DataRange range = filter.dataRange; RowPosition lastKey = range.stopKey(); IPartitioner<?> partitioner = DatabaseDescriptor.getPartitioner(); final int maxRows = Math.min(filter.maxColumns(), Math.min(MAX_ROWS, filter.maxRows())); final List<Row> rows = new ArrayList<>(maxRows); Operation operationTree = null; try { operationTree = analyze(); if (operationTree == null) return Collections.emptyList(); operationTree.skipTo(((LongToken) range.keyRange().left.getToken()).token); intersection: while (operationTree.hasNext()) { for (DecoratedKey key : operationTree.next()) { if ((!lastKey.isMinimum(partitioner) && lastKey.compareTo(key) < 0) || rows.size() >= maxRows) break intersection; if (!range.contains(key)) continue; Row row = getRow(key, filter); if (row != null && operationTree.satisfiedBy(row, null, !isColumnSlice(key))) rows.add(row); } } } finally { FileUtils.closeQuietly(operationTree); controller.finish(); } return rows; }
Example 7
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public static IPartitioner getPartitioner() { return DatabaseDescriptor.getPartitioner(); }
Example 8
Source File: PartitionKeyMapper.java From stratio-cassandra with Apache License 2.0 | 4 votes |
/** * Returns a new {@code PartitionKeyMapper} according to the specified column family meta data. * * @param metadata The column family metadata. */ private PartitionKeyMapper(CFMetaData metadata) { partitioner = DatabaseDescriptor.getPartitioner(); this.metadata = metadata; this.type = metadata.getKeyValidator(); }