/** * {@inheritDoc} */ @Override public void setPositionAndSize(long position, long size) { simpleStorageDescriptor.setPosition(position); simpleStorageDescriptor.setSize((int) size); }
/** * Returns the branches to Query. * * @param <R> * * @param query * query * @return the list of branches */ public List<IStorageTreeComponent<E>> getBranchesToQuery(IIndexQuery query) { return getBranches(); }
/** * Default constructor. Instantiates new {@link SimpleStorageDescriptor}. */ public StorageDescriptor() { simpleStorageDescriptor = new SimpleStorageDescriptor(); }
/** * {@inheritDoc} */ @Override public IStorageDescriptor put(E element) throws IndexingException { if (null == element) { throw new IndexingException("Element to index can not be null."); } else if (0 == element.getId()) { throw new IndexingException("Element to index can not have ID that is equal to zero."); } StorageDescriptor descriptor = new StorageDescriptor(this.id); if (insertIntoArrays(element.getId(), descriptor.getSimpleStorageDescriptor())) { return descriptor; } else { throw new IndexingException("Element already indexed."); } }
/** * Joins the position and size information if possible contained in other descriptor. This * method will return true if the join was successfully done, and false if no join was done. The * join is possible only if the given position and size is pointing to the data that is next to * the data currently described in {@link SimpleStorageDescriptor}. * * @param other * Descriptor to join * @return This method will return true if the join was successfully done, and false if no join * was done. */ public boolean join(SimpleStorageDescriptor other) { return join(other.getPosition(), other.getSize()); }
/** * {@inheritDoc} */ @Override public IStorageBranchIndexer<E> getNewInstance() { IBranchIndexer<E> branchIndexer = null; if (sharedInstance()) { branchIndexer = delegateIndexer; } else { branchIndexer = delegateIndexer.getNewInstance(); } StorageBranchIndexer<E> storageBranchIndexer = new StorageBranchIndexer<>(branchIndexer, childIndexer, passId); return storageBranchIndexer; }
/** * Init. */ @BeforeMethod public void init() { arrayBasedStorageLeaf = new ArrayBasedStorageLeaf<>(LEAF_ID); }
/** * {@inheritDoc} */ @Override public Object[] getKeys(IIndexQuery query) { Object[] keys = new Object[1]; if (query instanceof StorageIndexQuery) { if (((StorageIndexQuery) query).isOnlyInvocationsWithoutChildren()) { keys[0] = Boolean.TRUE; } else { keys[0] = Boolean.FALSE; } } else { keys[0] = Boolean.FALSE; } return keys; }
/** * {@inheritDoc} */ @Override public String toString() { ToStringBuilder toStringBuilder = new ToStringBuilder(this); toStringBuilder.append("channelId", channelId); toStringBuilder.append("position", simpleStorageDescriptor.getPosition()); toStringBuilder.append("size", simpleStorageDescriptor.getSize()); return toStringBuilder.toString(); }
/** * Initializes the index query. */ @BeforeMethod public void initMethod() { storageIndexQuery = new StorageIndexQuery(); }
/** * {@inheritDoc} */ @Override public long getPosition() { return simpleStorageDescriptor.getPosition(); }
/** * {@inheritDoc} */ @Override public long getSize() { return simpleStorageDescriptor.getSize(); }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + channelId; result = (prime * result) + ((simpleStorageDescriptor == null) ? 0 : simpleStorageDescriptor.hashCode()); return result; }
/** * {@inheritDoc} */ @Override public synchronized void preWriteFinalization() { optimiseDescriptors(descriptors); }
/** * Joins the position and size information if possible. This method will return true if the join * was successfully done, and false if no join was done. The join is possible only if the given * position and size is pointing to the data that is next to the data currently described in * {@link StorageDescriptor}. * * @param otherPosition * Position * @param otherSize * Size * @return This method will return true if the join was successfully done, and false if no join * was done. */ public boolean join(long otherPosition, long otherSize) { return simpleStorageDescriptor.join(otherPosition, otherSize); }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((childIndexer == null) ? 0 : childIndexer.hashCode()); result = (prime * result) + ((delegateIndexer == null) ? 0 : delegateIndexer.hashCode()); return result; }
/** * {@inheritDoc} */ @Override public List<IStorageDescriptor> query(IIndexQuery query, ForkJoinPool forkJoinPool) { return forkJoinPool.invoke(getTaskForForkJoinQuery(query)); }
/** * {@inheritDoc} */ @Override public List<IStorageDescriptor> query(IIndexQuery query, ForkJoinPool forkJoinPool) { return forkJoinPool.invoke(getTaskForForkJoinQuery(query)); }
/** * {@inheritDoc} */ @Override public List<IStorageDescriptor> query(IIndexQuery query, ForkJoinPool forkJoinPool) { return forkJoinPool.invoke(getTaskForForkJoinQuery(query)); }
/** * Assigns the channel ID, position in file and size. * * @param channelId * Channel id to hold. * @param position * Position in file. * @param size * Size. */ public StorageDescriptor(int channelId, long position, long size) { this.channelId = channelId; this.simpleStorageDescriptor = new SimpleStorageDescriptor(position, (int) size); }