本文整理匯總了Java中com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper類的典型用法代碼示例。如果您正苦於以下問題:Java CassandraHelper類的具體用法?Java CassandraHelper怎麽用?Java CassandraHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CassandraHelper類屬於com.thinkaurelius.titan.diskstorage.cassandra.utils包,在下文中一共展示了CassandraHelper類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEntries
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public RecordIterator<Entry> getEntries() {
ensureOpen();
if (sliceQuery == null)
throw new IllegalStateException("getEntries() requires SliceQuery to be set.");
return new RecordIterator<Entry>() {
private final Iterator<Entry> columns =
CassandraHelper.makeEntryIterator(currentRow.getColumns(),
entryGetter,
sliceQuery.getSliceEnd(),sliceQuery.getLimit());
@Override
public boolean hasNext() {
ensureOpen();
return columns.hasNext();
}
@Override
public Entry next() {
ensureOpen();
return columns.next();
}
@Override
public void close() {
isClosed = true;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例2: getEntries
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public RecordIterator<Entry> getEntries() {
ensureOpen();
if (sliceQuery == null)
throw new IllegalStateException("getEntries() requires SliceQuery to be set.");
return new RecordIterator<Entry>() {
final Iterator<Entry> columns = CassandraHelper.makeEntryIterator(
Iterables.filter(currentRow.cf.getSortedColumns(), new FilterDeletedColumns(nowMillis)),
entryGetter,
sliceQuery.getSliceEnd(),
sliceQuery.getLimit());
//cfToEntries(currentRow.cf, sliceQuery).iterator();
@Override
public boolean hasNext() {
ensureOpen();
return columns.hasNext();
}
@Override
public Entry next() {
ensureOpen();
return columns.next();
}
@Override
public void close() {
isClosed = true;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例3: getLocalKeyPartition
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
public List<KeyRange> getLocalKeyPartition() throws BackendException {
ensureKeyspaceExists(keySpaceName);
@SuppressWarnings("rawtypes")
Collection<Range<Token>> ranges = StorageService.instance.getPrimaryRanges(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (@SuppressWarnings("rawtypes") Range<Token> range : ranges) {
keyRanges.add(CassandraHelper.transformRange(range));
}
return keyRanges;
}
示例4: getEntries
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public RecordIterator<Entry> getEntries() {
ensureOpen();
return new RecordIterator<Entry>() {
final Iterator<Entry> columns =
CassandraHelper.makeEntryIterator(mostRecentRow.getColumns(),
entryGetter, columnSlice.getSliceEnd(),
columnSlice.getLimit());
@Override
public boolean hasNext() {
ensureOpen();
return columns.hasNext();
}
@Override
public Entry next() {
ensureOpen();
return columns.next();
}
@Override
public void close() {
closeIterator();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例5: getLocalKeyPartition
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
CTConnection conn = null;
IPartitioner partitioner = getCassandraPartitioner();
// DAVID CASSANDRA
// if (!(partitioner instanceof AbstractByteOrderedPartitioner))
if (!(partitioner instanceof ByteOrderedPartitioner))
throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");
Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
try {
// Resist the temptation to describe SYSTEM_KS. It has no ring.
// Instead, we'll create our own keyspace (or check that it exists), then describe it.
ensureKeyspaceExists(keySpaceName);
conn = pool.borrowObject(keySpaceName);
List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (TokenRange range : ranges) {
if (!NetworkUtil.hasLocalAddress(range.endpoints))
continue;
keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
}
return keyRanges;
} catch (Exception e) {
throw CassandraThriftKeyColumnValueStore.convertException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}
示例6: getLocalKeyPartition
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
CTConnection conn = null;
IPartitioner partitioner = getCassandraPartitioner();
if (!(partitioner instanceof AbstractByteOrderedPartitioner))
throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");
Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
try {
// Resist the temptation to describe SYSTEM_KS. It has no ring.
// Instead, we'll create our own keyspace (or check that it exists), then describe it.
ensureKeyspaceExists(keySpaceName);
conn = pool.borrowObject(keySpaceName);
List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (TokenRange range : ranges) {
if (!NetworkUtil.hasLocalAddress(range.endpoints))
continue;
keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
}
return keyRanges;
} catch (Exception e) {
throw CassandraThriftKeyColumnValueStore.convertException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}
示例7: getLocalKeyPartition
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
public List<KeyRange> getLocalKeyPartition() throws BackendException {
@SuppressWarnings("rawtypes")
Collection<Range<Token>> ranges = StorageService.instance.getLocalPrimaryRanges(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (@SuppressWarnings("rawtypes") Range<Token> range : ranges) {
keyRanges.add(CassandraHelper.transformRange(range));
}
return keyRanges;
}
示例8: getLocalKeyPartition
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
CTConnection conn = null;
IPartitioner<?> partitioner = getCassandraPartitioner();
if (!(partitioner instanceof AbstractByteOrderedPartitioner))
throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");
Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
try {
conn = pool.borrowObject(keySpaceName);
List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (TokenRange range : ranges) {
if (!NetworkUtil.hasLocalAddress(range.endpoints))
continue;
keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
}
return keyRanges;
} catch (Exception e) {
throw CassandraThriftKeyColumnValueStore.convertException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}
示例9: getSlice
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public EntryList getSlice(KeySliceQuery query, StoreTransaction txh) throws BackendException {
/**
* This timestamp mimics the timestamp used by
* {@link org.apache.cassandra.thrift.CassandraServer#get(ByteBuffer,ColumnPath,ConsistencyLevel)}.
*
* That method passes the server's System.currentTimeMillis() to
* {@link ReadCommand#create(String, ByteBuffer, String, long, IDiskAtomFilter)}.
* {@code create(...)} in turn passes that timestamp to the SliceFromReadCommand constructor.
*/
final long nowMillis = times.getTime().toEpochMilli();
Composite startComposite = CellNames.simpleDense(query.getSliceStart().asByteBuffer());
Composite endComposite = CellNames.simpleDense(query.getSliceEnd().asByteBuffer());
SliceQueryFilter sqf = new SliceQueryFilter(startComposite, endComposite,
false, query.getLimit() + (query.hasLimit()?1:0));
ReadCommand sliceCmd = new SliceFromReadCommand(keyspace, query.getKey().asByteBuffer(), columnFamily, nowMillis, sqf);
List<Row> slice = read(sliceCmd, getTx(txh).getReadConsistencyLevel().getDB());
if (null == slice || 0 == slice.size())
return EntryList.EMPTY_LIST;
int sliceSize = slice.size();
if (1 < sliceSize)
throw new PermanentBackendException("Received " + sliceSize + " rows for single key");
Row r = slice.get(0);
if (null == r) {
log.warn("Null Row object retrieved from Cassandra StorageProxy");
return EntryList.EMPTY_LIST;
}
ColumnFamily cf = r.cf;
if (null == cf) {
log.debug("null ColumnFamily (\"{}\")", columnFamily);
return EntryList.EMPTY_LIST;
}
if (cf.isMarkedForDelete())
return EntryList.EMPTY_LIST;
return CassandraHelper.makeEntryList(
Iterables.filter(cf.getSortedColumns(), new FilterDeletedColumns(nowMillis)),
entryGetter,
query.getSliceEnd(),
query.getLimit());
}
示例10: getSlice
import com.thinkaurelius.titan.diskstorage.cassandra.utils.CassandraHelper; //導入依賴的package包/類
@Override
public EntryList getSlice(KeySliceQuery query, StoreTransaction txh) throws BackendException {
/**
* This timestamp mimics the timestamp used by
* {@link org.apache.cassandra.thrift.CassandraServer#get(ByteBuffer,ColumnPath,ConsistencyLevel)}.
*
* That method passes the server's System.currentTimeMillis() to
* {@link ReadCommand#create(String, ByteBuffer, String, long, IDiskAtomFilter)}.
* {@code create(...)} in turn passes that timestamp to the SliceFromReadCommand constructor.
*/
final long nowMillis = times.getTime().getTimestamp(TimeUnit.MILLISECONDS);
SliceQueryFilter sqf = new SliceQueryFilter(query.getSliceStart().asByteBuffer(), query.getSliceEnd().asByteBuffer(), false, query.getLimit() + (query.hasLimit()?1:0));
ReadCommand sliceCmd = new SliceFromReadCommand(keyspace, query.getKey().asByteBuffer(), columnFamily, nowMillis, sqf);
List<Row> slice = read(sliceCmd, getTx(txh).getReadConsistencyLevel().getDB());
if (null == slice || 0 == slice.size())
return EntryList.EMPTY_LIST;
int sliceSize = slice.size();
if (1 < sliceSize)
throw new PermanentBackendException("Received " + sliceSize + " rows for single key");
Row r = slice.get(0);
if (null == r) {
log.warn("Null Row object retrieved from Cassandra StorageProxy");
return EntryList.EMPTY_LIST;
}
ColumnFamily cf = r.cf;
if (null == cf) {
log.debug("null ColumnFamily (\"{}\")", columnFamily);
return EntryList.EMPTY_LIST;
}
if (cf.isMarkedForDelete())
return EntryList.EMPTY_LIST;
return CassandraHelper.makeEntryList(
Iterables.filter(cf.getSortedColumns(), new FilterDeletedColumns(nowMillis)),
entryGetter,
query.getSliceEnd(),
query.getLimit());
}
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:49,代碼來源:CassandraEmbeddedKeyColumnValueStore.java