/** * Execute a SELECT query and returns just one row. * * <p> * The default session (obtained via {@link #getSession()} is used to execute the query. * </p> * * @param stm * @return * @since 0.4.0.2 */ public Row executeOne(Statement stm) { return executeOne(stm, null); }
/** * {@inheritDoc} */ @Override public byte[] get(String table, String key) { String CQL = MessageFormat.format(CQL_SELECT_ONE, calcTableName(table)); Row row = getSessionManager().executeOne(CQL, getConsistencyLevelGet(), key); ByteBuffer data = row != null ? row.getBytes(columnValue) : null; return data != null ? data.array() : null; }
/** * {@inheritDoc} */ @Override public Map<String, Object> get(String table, String key) { String CQL = MessageFormat.format(CQL_SELECT_ONE, calcTableName(table)); Row row = getSessionManager().executeOne(CQL, getConsistencyLevelGet(), key); ByteBuffer data = row != null ? row.getBytes(columnDocument) : null; return bytesToDocument(data.array()); }
/** * {@inheritDoc} */ @Override public long size(String table) { String CQL = MessageFormat.format(CQL_COUNT, calcTableName(table)); Row row = getSessionManager().executeOne(CQL, getConsistencyLevelCount()); return row != null ? row.getLong(0) : -1; }
/** * {@inheritDoc} */ @Override public long size(String table) { String CQL = MessageFormat.format(CQL_COUNT, calcTableName(table)); Row row = getSessionManager().executeOne(CQL, getConsistencyLevelCount()); return row != null ? row.getLong(0) : -1; } }
/** * {@inheritDoc} */ @Override public long size(String table) { String CQL = MessageFormat.format(CQL_COUNT, calcTableName(table)); Row row = getSessionManager().executeOne(CQL, getConsistencyLevelCount()); return row != null ? row.getLong(0) : -1; }
/** * {@inheritDoc} */ @Override protected FileInfo getFileInfo(String name) { String CACHE_KEY = cacheKeyFileInfo(name); FileInfo fileInfo = getFromCache(CACHE_KEY, FileInfo.class); if (fileInfo == null) { Row row = sessionManager.executeOne(CQL_GET_FILEINFO, consistencyLevelReadFileInfo, name); if (row != null) { fileInfo = createFileInfo(row); putToCache(CACHE_KEY, fileInfo); } } return fileInfo; }
/** * {@inheritDoc} */ @Override protected byte[] readFileBlock(FileInfo fileInfo, int blockNum) { String CACHE_KEY = cacheKeyDataBlock(fileInfo, blockNum); byte[] dataArr = getFromCache(CACHE_KEY, byte[].class); if (LOGGER.isTraceEnabled()) { if (dataArr != null) { LOGGER.trace("readFileBlock(" + fileInfo.getId() + ":" + fileInfo.getName() + "/" + blockNum + ") --> cache hit!"); } else { LOGGER.trace("readFileBlock(" + fileInfo.getId() + ":" + fileInfo.getName() + "/" + blockNum + ") --> cache missed!"); } } if (dataArr == null) { Row row = sessionManager.executeOne(CQL_LOAD_FILEDATA, consistencyLevelReadFileData, fileInfo.getId(), blockNum); ByteBuffer data = row != null ? row.getBytes(COL_BLOCK_DATA) : null; dataArr = data != null ? data.array() : null; putToCache(CACHE_KEY, dataArr); } return dataArr != null ? (dataArr.length >= getBlockSize() ? dataArr : Arrays.copyOf(dataArr, getBlockSize())) : null; }