@Override public BigInteger compose(ByteBuffer bytes) { return new BigInteger(ByteBufferUtil.getArray(bytes)); }
@Override public InputStream openResource(String resourceName) { ByteBuffer resourceValue = null; try { resourceValue = SolandraCoreContainer.readCoreResource(coreName, resourceName); } catch (Exception e) { throw new RuntimeException("Error opening " + resourceName, e); } //fallback to solr.home if (resourceValue == null) { return super.openResource(resourceName); } else { return new ByteArrayInputStream(ByteBufferUtil.getArray(resourceValue)); } } }
public synchronized SolrCore readSchema(String indexName) throws IOException, ParserConfigurationException, SAXException { SolrCore core = cache.get(indexName); if (core == null) { // get from cassandra if (logger.isDebugEnabled()) logger.debug("loading index schema for: " + indexName); ByteBuffer buf = readCoreResource(indexName, CassandraUtils.schemaKey); //Schema resource not found for the core if (buf == null) { throw new IOException(String.format("invalid core '%s'", indexName)); } InputStream stream = new ByteArrayInputStream(ByteBufferUtil.getArray(buf)); SolrResourceLoader resourceLoader = new SolandraResourceLoader(indexName, null); SolrConfig solrConfig = new SolrConfig(resourceLoader, solrConfigFile, null); IndexSchema schema = new IndexSchema(solrConfig, indexName, new InputSource(stream)); core = new SolrCore(indexName, "/tmp", solrConfig, schema, null); if (logger.isDebugEnabled()) logger.debug("Loaded core from cassandra: " + indexName); cache.put(indexName, core); } return core; }
/** Read the object from bytes string. */ public static DocumentMetadata fromBytesUsingThrift(ByteBuffer data) throws IOException { DocumentMetadata docMeta = new DocumentMetadata(); byte[] decompressedData = CassandraUtils.decompress(ByteBufferUtil.getArray(data)); TTransport trans = new TMemoryInputTransport(decompressedData); TProtocol deser = protocolFactory.getProtocol(trans); try { docMeta.read(deser); } catch (TException e) { throw new IOException(e); } return docMeta; } }
public AtlasBytesToken(ByteBuffer token) { this(ByteBufferUtil.getArray(token)); }
public RowCacheKey(Pair<String, String> ksAndCFName, ByteBuffer key) { super(ksAndCFName); this.key = ByteBufferUtil.getArray(key); assert this.key != null; }
public KeyCacheKey(Pair<String, String> ksAndCFName, Descriptor desc, ByteBuffer key) { super(ksAndCFName); this.desc = desc; this.key = ByteBufferUtil.getArray(key); assert this.key != null; }
public RowCacheKey(Pair<String, String> ksAndCFName, ByteBuffer key) { super(ksAndCFName); this.key = ByteBufferUtil.getArray(key); assert this.key != null; }
public RowCacheKey(Pair<String, String> ksAndCFName, ByteBuffer key) { super(ksAndCFName); this.key = ByteBufferUtil.getArray(key); assert this.key != null; }
public BigInteger deserialize(ByteBuffer bytes) { return bytes.hasRemaining() ? new BigInteger(ByteBufferUtil.getArray(bytes)) : null; }
public BigInteger deserialize(ByteBuffer bytes) { return bytes.hasRemaining() ? new BigInteger(ByteBufferUtil.getArray(bytes)) : null; }
public InetAddress deserialize(ByteBuffer bytes) { if (bytes.remaining() == 0) return null; try { return InetAddress.getByAddress(ByteBufferUtil.getArray(bytes)); } catch (UnknownHostException e) { throw new AssertionError(e); } }
/** trims size of bytebuffer to exactly number of bytes in it, to do not hold too much memory */ public static ByteBuffer minimalBufferFor(ByteBuffer buf) { return buf.capacity() > buf.remaining() || !buf.hasArray() ? ByteBuffer.wrap(getArray(buf)) : buf; }
/** trims size of bytebuffer to exactly number of bytes in it, to do not hold too much memory */ public static ByteBuffer minimalBufferFor(ByteBuffer buf) { return buf.capacity() > buf.remaining() || !buf.hasArray() ? ByteBuffer.wrap(getArray(buf)) : buf; }
/** trims size of bytebuffer to exactly number of bytes in it, to do not hold too much memory */ public static ByteBuffer minimalBufferFor(ByteBuffer buf) { return buf.capacity() > buf.remaining() || !buf.hasArray() ? ByteBuffer.wrap(getArray(buf)) : buf; }
private HashCode hash(ByteBuffer buf) { HashFunction hashFn = Hashing.murmur3_128(); if (buf.hasArray()) { return hashFn.hashBytes(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining()); } else { return hashFn.hashBytes(ByteBufferUtil.getArray(buf)); } }
public Token fromByteArray(ByteBuffer bytes) { return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes))); }
public void validate(ByteBuffer bytes) throws MarshalException { if (bytes.remaining() == 0) return; try { InetAddress.getByAddress(ByteBufferUtil.getArray(bytes)); } catch (UnknownHostException e) { throw new MarshalException(String.format("Expected 4 or 16 byte inetaddress; got %s", ByteBufferUtil.bytesToHex(bytes))); } }