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(); }
public LucandraTermInfo[] loadFilteredTerms(Term term, List<ByteBuffer> docNums) throws IOException { long start = System.currentTimeMillis(); ColumnParent parent = new ColumnParent(); parent.setColumn_family(CassandraUtils.termVecColumnFamily); ByteBuffer key; try { key = CassandraUtils.hashKeyBytes(indexName.getBytes("UTF-8"), CassandraUtils.delimeterBytes, term.field() .getBytes("UTF-8"), CassandraUtils.delimeterBytes, term.text().getBytes("UTF-8")); } catch (UnsupportedEncodingException e2) { throw new RuntimeException("JVM doesn't support UTF-8", e2); } ReadCommand rc = new SliceByNamesReadCommand(CassandraUtils.keySpace, key, parent, docNums); List<Row> rows = CassandraUtils.robustRead(CassandraUtils.consistency, rc); LucandraTermInfo[] termInfo = null; if (rows != null && rows.size() > 0 && rows.get(0) != null && rows.get(0).cf != null) { termInfo = TermCache.convertTermInfo(rows.get(0).cf.getSortedColumns()); } long end = System.currentTimeMillis(); if (logger.isDebugEnabled()) logger.debug("loadFilterdTerms: " + term + "(" + termInfo == null ? 0 : termInfo.length + ") took " + (end - start) + "ms"); return termInfo; }
new ColumnParent(CassandraUtils.schemaInfoColumnFamily), startCol, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, pageSize);
ByteBufferUtil.EMPTY_BYTE_BUFFER, false, bufferSize)); ColumnParent columnParent = new ColumnParent(CassandraUtils.termVecColumnFamily);
"shards".getBytes("UTF-8")); ReadCommand cmd = new SliceFromReadCommand(CassandraUtils.keySpace, key, new ColumnParent( CassandraUtils.schemaInfoColumnFamily), ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, Integer.MAX_VALUE);
readCommands.add(new SliceByNamesReadCommand(CassandraUtils.keySpace, key, new ColumnParent() .setColumn_family(CassandraUtils.termVecColumnFamily), Arrays.asList(ByteBuffer .wrap(CassandraUtils.writeVInt(docI)))));
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); } } } }
ColumnParent columnParent = new ColumnParent(); columnParent.setColumn_family(CassandraUtils.docColumnFamily);
connection.getClient().get_range_slices(new ColumnParent(columnFamily), new SlicePredicate() .setSlice_range(sliceRange),
public Map<StaticBuffer, EntryList> getNamesSlice(List<StaticBuffer> keys, SliceQuery query, StoreTransaction txh) throws BackendException { ColumnParent parent = new ColumnParent(columnFamily);
public HColumnFamilyImpl(Keyspace keyspace, String columnFamilyName, Serializer<K> keySerializer, Serializer<N> columnNameSerializer) { this.keyspace = (ExecutingKeyspace)keyspace; this.columnFamilyName = columnFamilyName; this._keys = new ArrayList<K>(); this.keySerializer = keySerializer; this.columnNameSerializer = columnNameSerializer; this.activeSlicePredicate = new HSlicePredicate<N>(columnNameSerializer); this.columnParent = new ColumnParent(columnFamilyName); exceptionsTranslator = new ExceptionsTranslatorImpl(); this.consistencyLevelPolicy = new ConfigurableConsistencyLevel(); }
@Override public CounterSlice<N> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); List<CounterColumn> thriftRet = ks.getCounterSlice(keySerializer.toByteBuffer(key), columnParent, getPredicate()); return new CounterSliceImpl<N>(thriftRet, columnNameSerializer); } }, consistency), this);
@Override public SuperSlice<SN, N, V> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); List<SuperColumn> thriftRet = ks.getSuperSlice(keySerializer.toByteBuffer(key), columnParent, getPredicate()); return new SuperSliceImpl<SN, N, V>(thriftRet, columnNameSerializer, nameSerializer, valueSerializer); } }, consistency), this);
@Override public ColumnSlice<N, V> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); List<Column> thriftRet = ks.getSlice(keySerializer.toByteBuffer(key), columnParent, getPredicate()); return new ColumnSliceImpl<N, V>(thriftRet, columnNameSerializer, valueSerializer); } }, consistency), this);
@Override public Integer doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamily); columnParent.setSuper_column(superNameSerializer.toByteBuffer(superColumnName)); Integer count = ks.getCount(keySerializer.toByteBuffer(key), columnParent, slicePredicate.toThrift()); return count; } }, consistency), this);
@Override public OrderedCounterRows<K, N> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); Map<K, List<CounterColumn>> thriftRet = keySerializer.fromBytesMap( ks.getRangeCounterSlices(columnParent, getPredicate(), keyRange.toThrift())); return new OrderedCounterRowsImpl<K,N>((LinkedHashMap<K, List<CounterColumn>>) thriftRet, columnNameSerializer); } }, consistency), this);
@Override public OrderedCounterSuperRows<K, SN,N> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); Map<K, List<CounterSuperColumn>> thriftRet = keySerializer.fromBytesMap( ks.getSuperRangeCounterSlices(columnParent, getPredicate(), keyRange.toThrift())); return new OrderedCounterSuperRowsImpl<K, SN, N>( (LinkedHashMap<K, List<CounterSuperColumn>>) thriftRet, keySerializer, columnNameSerializer, nameSerializer); } }, consistency), this);
@Override public OrderedRows<K, N,V > doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamilyName); Map<K, List<Column>> thriftRet = keySerializer.fromBytesMap( ks.getRangeSlices(columnParent, getPredicate(), keyRange.toThrift())); return new OrderedRowsImpl<K,N,V>((LinkedHashMap<K, List<Column>>) thriftRet, columnNameSerializer, valueSerializer); } }, consistency), this);
@Override public Map<K,Integer> doInKeyspace(KeyspaceService ks) throws HectorException { ColumnParent columnParent = new ColumnParent(columnFamily); columnParent.setSuper_column(superNameSerializer.toByteBuffer(superColumnName)); Map<K,Integer> counts = keySerializer.fromBytesMap( ks.multigetCount(keySerializer.toBytesList(keys), columnParent, slicePredicate.toThrift())); return counts; } }, consistency), this);
@Override public void insert(String key, ColumnPath columnPath, ByteBuffer value) throws HectorException { // valideColumnPath(columnPath); ColumnParent columnParent = new ColumnParent(columnPath.getColumn_family()); if (columnPath.isSetSuper_column()) { columnParent.setSuper_column(columnPath.getSuper_column()); } Column column = new Column(ByteBuffer.wrap(columnPath.getColumn())); column.setValue(value); column.setTimestamp(connectionManager.createClock()); insert(StringSerializer.get().toByteBuffer(key), columnParent, column); }