public static String readSchemaXML(String indexName) throws IOException { ByteBuffer schema = readCoreResource(indexName, CassandraUtils.schemaKey); //Schema resource not found for the core if (schema == null) { throw new IOException(String.format("invalid core '%s'", indexName)); } return ByteBufferUtil.string(schema); }
throw new IllegalArgumentException(ByteBufferUtil.string(e.getKey()));
@Override public BigIntegerToken getToken(ByteBuffer key) { ByteBuffer extractedToken = extractSolandraToken(key); if(extractedToken == null) return super.getToken(key); //the token is pre-processed try { return new BigIntegerToken(ByteBufferUtil.string(extractedToken)); } catch (CharacterCodingException e) { throw new RuntimeException(e); } }
public Long checkForUpdate(String indexName, String key) throws IOException { ByteBuffer keyCol = ByteBuffer.wrap(key.getBytes("UTF-8")); ByteBuffer keyKey = CassandraUtils.hashKeyBytes((indexName + "~" + key).getBytes("UTF-8"), CassandraUtils.delimeterBytes, "keys".getBytes("UTF-8")); List<Row> rows = CassandraUtils.robustRead(keyKey, new QueryPath(CassandraUtils.schemaInfoColumnFamily), Arrays.asList(keyCol), ConsistencyLevel.QUORUM); if (rows.size() == 1) { Row row = rows.get(0); if (row.cf != null) { IColumn col = row.cf.getColumn(keyCol); if (col != null) { Collection<IColumn> subCols = col.getSubColumns(); if (subCols != null && !subCols.isEmpty()) { ByteBuffer idVal = col.getSubColumns().iterator().next().name(); Long id = Long.valueOf(ByteBufferUtil.string(idVal)); return id; } } } } return null; }
resource = ByteBufferUtil.string(SolandraCoreContainer.readCoreResource(indexName, resourceName));
@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); } }
Long id = Long.valueOf(ByteBufferUtil.string(idCol)); int shard = CassandraIndexManager.getShardFromDocId(id); int sid = CassandraIndexManager.getShardedDocId(id);
String val = ByteBufferUtil.string(col.value());
@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; } }
String rowKey = ByteBufferUtil.string(row.key.key, CassandraUtils.UTF_8);
logger.debug(indexName + " - firstTerm: " + ByteBufferUtil.string(fieldCacheKey));
long termval = parser.parseLong(ByteBufferUtil.string(col.value()));
double termval = parser.parseDouble(ByteBufferUtil.string(col.value()));
/** * Decompose. * * @param value * the value * @param clazz * the clazz * @return the object */ private static Object decompose(Object value, Class clazz) { ByteBuffer buf = ByteBuffer.wrap((byte[]) value, 0, ((byte[]) value).length); try { return ByteBufferUtil.string(buf); } catch (CharacterCodingException e) { log.warn("Error while setting field value, Caused by: .", e); } return null; } }
@Test public void test() throws Exception { Assert.assertEquals(str, s.fromByteBuffer(s.toByteBuffer(str))); if (str != null) { Assert .assertEquals(str, ByteBufferUtil.string(ByteBufferUtil.bytes(str))); } if (str != null) { UTF8Type.instance.validate(s.toByteBuffer(str)); } } }