Tabnine Logo
org.apache.cassandra.db
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.cassandra.db

Best Java code snippets using org.apache.cassandra.db (Showing top 20 results out of 315)

origin: thinkaurelius/titan

  @Override
  public boolean apply(Cell input) {
    if (!input.isLive(tsMillis))
      return false;
    // Don't do this.  getTimeToLive() is a duration divorced from any particular clock.
    // For instance, if TTL=10 seconds, getTimeToLive() will have value 10 (not 10 + epoch seconds), and
    // this will always return false.
    //if (input instanceof ExpiringCell)
    //    return tsSeconds < ((ExpiringCell)input).getTimeToLive();
    return true;
  }
}
origin: thinkaurelius/titan

  @Override
  public Object getMetaData(Cell element, EntryMetaData meta) {
    switch (meta) {
      case TIMESTAMP:
        return element.timestamp();
      case TTL:
        return ((element instanceof ExpiringCell)
                ? ((ExpiringCell) element).getTimeToLive()
                : 0);
      default:
        throw new UnsupportedOperationException("Unsupported meta data: " + meta);
    }
  }
}
origin: thinkaurelius/titan

  @Override
  public boolean apply(@Nullable Row row) {
    // The hasOnlyTombstones(x) call below ultimately calls Column.isMarkedForDelete(x)
    return !(row == null || row.cf == null || row.cf.isMarkedForDelete() || row.cf.hasOnlyTombstones(nowMillis));
  }
});
origin: tjake/Solandra

ReadCommand cmd = new SliceFromReadCommand(CassandraUtils.keySpace, key,
    new ColumnParent(CassandraUtils.schemaInfoColumnFamily), startCol,
    ByteBufferUtil.EMPTY_BYTE_BUFFER, false, pageSize);
for(IColumn sc : row.cf.getSortedColumns()){
  if(sc.name().equals(startCol))
    continue;
  startCol = sc.name();
  if(!sc.isLive())
    continue;
  Integer id  = Integer.valueOf(ByteBufferUtil.string(sc.name()));
origin: tjake/Solandra

public void deleteDocuments(String indexName, Term term, boolean autoCommit) throws CorruptIndexException,
    IOException
{
  ColumnParent cp = new ColumnParent(CassandraUtils.termVecColumnFamily);
  ByteBuffer key = CassandraUtils.hashKeyBytes(indexName.getBytes("UTF-8"), CassandraUtils.delimeterBytes, term
      .field().getBytes("UTF-8"), CassandraUtils.delimeterBytes, term.text().getBytes("UTF-8"));
  ReadCommand rc = new SliceFromReadCommand(CassandraUtils.keySpace, key, cp, ByteBufferUtil.EMPTY_BYTE_BUFFER,
      ByteBufferUtil.EMPTY_BYTE_BUFFER, false, Integer.MAX_VALUE);
  List<Row> rows = CassandraUtils.robustRead(CassandraUtils.consistency, rc);
  // delete by documentId
  for (Row row : rows)
  {
    if (row.cf != null)
    {
      Collection<IColumn> columns = row.cf.getSortedColumns();
      for (IColumn col : columns)
      {
        deleteLucandraDocument(indexName, CassandraUtils.readVInt(col.name()), autoCommit);
      }
    }
  }
}
origin: tjake/Solandra

public static LucandraTermInfo[] convertTermInfo(Collection<IColumn> docs)
{
  LucandraTermInfo termInfo[] = new LucandraTermInfo[docs.size()];
  int i = 0;
  for (IColumn col : docs)
  {
    if (i == termInfo.length)
      break;
    if (i == 0 && col instanceof SuperColumn)
      throw new IllegalStateException(
          "TermInfo ColumnFamily is a of type Super: This is no longer supported, please see NEWS.txt");
    if (col == null || col.name() == null || col.value() == null)
      throw new IllegalStateException("Encountered missing column: " + col);
    termInfo[i] = new LucandraTermInfo(CassandraUtils.readVInt(col.name()), col.value());
    i++;
  }
  return termInfo;
}
origin: tjake/Solandra

private static Collection<IColumn> getFieldCacheEntries(IndexReader indexReader, String field) throws IOException
{
  String indexName = SolandraCoreContainer.coreInfo.get().indexName + "~"
      + SolandraCoreContainer.coreInfo.get().shard;
  byte[] indexNameBytes = indexName.getBytes("UTF-8");
  if(logger.isDebugEnabled())
    logger.debug("Loading field cache from " + indexName + " " + field);
  ColumnParent fieldCacheParent = new ColumnParent(CassandraUtils.fieldCacheColumnFamily);
  ByteBuffer fieldCacheKey = CassandraUtils.hashKeyBytes(indexNameBytes, CassandraUtils.delimeterBytes, field
      .getBytes());
  List<Row> rows = CassandraUtils.robustRead(CassandraUtils.consistency, new SliceFromReadCommand(
      CassandraUtils.keySpace, fieldCacheKey, fieldCacheParent, ByteBufferUtil.EMPTY_BYTE_BUFFER,
      ByteBufferUtil.EMPTY_BYTE_BUFFER, false, Integer.MAX_VALUE));
  if (rows.isEmpty())
    return Collections.emptyList();
  
  Row row = rows.get(0);
  if (row.cf == null)
    return Collections.emptyList();
  
  return row.cf.getSortedColumns();
}
origin: thinkaurelius/titan

  @Override
  public boolean apply(@Nullable Row row) {
    return row != null && !row.key.getKey().equals(exceptKey);
  }
});
origin: thinkaurelius/titan

@Override
public ByteBuffer getValue(Cell element) {
  return org.apache.cassandra.utils.ByteBufferUtil.clone(element.value());
}
origin: tjake/Solandra

public void flush(String core) throws IOException
{
  // Make sure all writes are in for this core
  writer.commit(core, true);
  ByteBuffer cacheKey = CassandraUtils.hashKeyBytes((core).getBytes("UTF-8"), CassandraUtils.delimeterBytes,
      "cache".getBytes("UTF-8"));
  RowMutation rm = new RowMutation(CassandraUtils.keySpace, cacheKey);
  rm.add(new QueryPath(CassandraUtils.schemaInfoColumnFamily, CassandraUtils.cachedColBytes,
      CassandraUtils.cachedColBytes), ByteBufferUtil.EMPTY_BYTE_BUFFER, System.currentTimeMillis());
  CassandraUtils.robustInsert(ConsistencyLevel.QUORUM, rm);
  // also directly notify the local readers
  SolandraComponent.cacheCheck.put(core, System.currentTimeMillis() - CassandraUtils.cacheInvalidationInterval
      - 1);
}
origin: thinkaurelius/titan

@Override
public ByteBuffer getColumn(Cell element) {
  return org.apache.cassandra.utils.ByteBufferUtil.clone(element.name().toByteBuffer());
}
origin: tjake/Solandra

List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily, CassandraUtils.cachedColBytes), Arrays
    .asList(CassandraUtils.cachedColBytes), ConsistencyLevel.QUORUM);
    rows.get(0).cf.getColumn(CassandraUtils.cachedColBytes).getSubColumn(CassandraUtils.cachedColBytes).timestamp() >= lastCheck)
origin: Netflix/Priam

/**
 * You must do the compaction before running this to remove the duplicate tokens out of the
 * server. TODO code it.
 */
@SuppressWarnings("unchecked")
public JSONObject estimateKeys() throws JSONException {
  Iterator<Entry<String, ColumnFamilyStoreMBean>> it =
      super.getColumnFamilyStoreMBeanProxies();
  JSONObject object = new JSONObject();
  while (it.hasNext()) {
    Entry<String, ColumnFamilyStoreMBean> entry = it.next();
    object.put("keyspace", entry.getKey());
    object.put("column_family", entry.getValue().getColumnFamilyName());
    object.put("estimated_size", entry.getValue().estimateKeys());
  }
  return object;
}
origin: tjake/Solandra

public static List<Row> robustRead(ByteBuffer key, QueryPath qp, List<ByteBuffer> columns, ConsistencyLevel cl)
    throws IOException
{
  ReadCommand rc = new SliceByNamesReadCommand(CassandraUtils.keySpace, key, qp, columns);
  return robustRead(cl, rc);
}
origin: Netflix/Priam

public void refresh(List<String> keyspaces)
    throws IOException, ExecutionException, InterruptedException {
  Iterator<Entry<String, ColumnFamilyStoreMBean>> it =
      super.getColumnFamilyStoreMBeanProxies();
  while (it.hasNext()) {
    Entry<String, ColumnFamilyStoreMBean> entry = it.next();
    if (keyspaces.contains(entry.getKey())) {
      logger.info(
          "Refreshing {} {}", entry.getKey(), entry.getValue().getColumnFamilyName());
      loadNewSSTables(entry.getKey(), entry.getValue().getColumnFamilyName());
    }
  }
}
origin: tjake/Solandra

@Override
public void collect(int docNumber) throws IOException
{
  deleteLucandraDocument(indexName, docNumber, autoCommit);
  numRemoved.incrementAndGet();
  
  //delete the id reference
  rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, ByteBufferUtil.bytes(Integer.toString(docNumber))), System.currentTimeMillis()-1);
  }
origin: thinkaurelius/titan

private CLevel() {
  db = org.apache.cassandra.db.ConsistencyLevel.valueOf(toString());
  thrift = org.apache.cassandra.thrift.ConsistencyLevel.valueOf(toString());
  astyanax = com.netflix.astyanax.model.ConsistencyLevel.valueOf("CL_" + toString());
}
origin: tjake/Solandra

@Override
public org.apache.cassandra.db.DecoratedKey<BigIntegerToken> decorateKey(ByteBuffer key)
{
  
  ByteBuffer extractedToken = extractSolandraToken(key);
        //non-solandra key passes through
  if(extractedToken == null)    
    return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(super.getToken(key), key);
   
 
  //the token is pre-processed
  try
  {
    return new org.apache.cassandra.db.DecoratedKey<BigIntegerToken>(new BigIntegerToken(ByteBufferUtil.string(extractedToken)), key);
  } 
  catch (CharacterCodingException e)
  {
    throw new RuntimeException(e);
  }        
}
origin: tjake/Solandra

  @Override
  protected Object createValue(IndexReader reader, Entry entryKey) throws IOException
  {
    String field = StringHelper.intern(entryKey.field);
    final String[] retArray = new String[reader.maxDoc()];
    Collection<IColumn> fcEntries = getFieldCacheEntries(reader, field);
    for (IColumn col : fcEntries)
    {
      if (col instanceof DeletedColumn)
        continue;
      int docId = CassandraUtils.readVInt(col.name());
      String val = ByteBufferUtil.string(col.value());
      retArray[docId] = val;
    }
    return retArray;
  }
}
origin: thinkaurelius/titan

@Override
public StaticBuffer next() {
  ensureOpen();
  if (!hasNext())
    throw new NoSuchElementException();
  currentRow = keys.next();
  ByteBuffer currentKey = currentRow.key.getKey().duplicate();
  try {
    return StaticArrayBuffer.of(currentKey);
  } finally {
    lastSeenKey = currentKey;
  }
}
org.apache.cassandra.db

Most used classes

  • AbstractType
    Specifies a Comparator for a specific type of ByteBuffer. Note that empty ByteBuffer are used to rep
  • CompositeType
  • ConsistencyLevel
  • CommitLog
  • DecoratedKey
  • MapType,
  • SetType,
  • UTF8Type,
  • ColumnFamilyStore,
  • Keyspace,
  • BooleanType,
  • TypeParser,
  • UUIDType,
  • Cell,
  • ColumnFamily,
  • IColumn,
  • SystemKeyspace,
  • BytesType,
  • Int32Type
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now