本文整理汇总了Java中com.tangosol.net.BackingMapContext类的典型用法代码示例。如果您正苦于以下问题:Java BackingMapContext类的具体用法?Java BackingMapContext怎么用?Java BackingMapContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BackingMapContext类属于com.tangosol.net包,在下文中一共展示了BackingMapContext类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildElement
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
private String buildElement(BackingMapContext bmc, String path, long docId, int docType) {
Set<Integer> parts = mDictionary.getPathElements(docType, path);
Filter f = new AndFilter(
new EqualsFilter(new PofExtractor(Long.TYPE, 2), docId),
new InFilter(new PofExtractor(Integer.TYPE, 4), parts));
Set<Map.Entry> xdEntries = QueryHelper.INSTANCE.query(bmc, f, true, false, null);
return null; //buildXml(xdEntries);
}
示例2: buildDocument
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@Override
public Collection<String> buildDocument(Set<Long> docIds, String template,
Map<String, String> params) {
logger.trace("buildDocument.enter; docIds: {}", docIds.size());
long stamp = System.currentTimeMillis();
// TODO: get docTYpe..
int docType = 0;
BackingMapManagerContext ctx = null;
Collection<String> result = new ArrayList<String>(docIds.size());
if (ctx != null && docIds.size() > 0) {
BackingMapContext bmc = ctx.getBackingMapContext(CN_XDM_ELEMENT);
for (long docId: docIds) {
StringBuilder buff = new StringBuilder(template);
for (Map.Entry<String, String> param: params.entrySet()) {
String key = param.getKey();
String str = buildElement(bmc, param.getValue(), docId, docType);
while (true) {
int idx = buff.indexOf(key);
//logger.trace("buildDocument; searching key: {} in buff: {}; result: {}", new Object[] {key, buff, idx});
if (idx < 0) break;
buff.replace(idx, idx + key.length(), str);
//logger.trace("buildDocument; replaced key: {} with {}", key, str);
}
}
result.add(buff.toString());
}
}
stamp = System.currentTimeMillis() - stamp;
logger.trace("buildDocument.exit; time taken: {}; returning: {}", stamp, result.size());
return result;
}
示例3: deleteDocument
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@Override
public void deleteDocument(Entry<Long, XDMDocument> entry) {
logger.trace("deleteDocument.enter; entry: {}", entry);
BinaryEntry docEntry = (BinaryEntry) entry;
if (!docEntry.isPresent()) {
throw new IllegalStateException("Document Entry with id " + entry.getKey() + " not found");
}
Long id = entry.getKey();
BackingMapManagerContext ctx = docEntry.getContext();
BackingMapContext xdmCtx = ctx.getBackingMapContext(CN_XDM_ELEMENT);
Filter f = new EqualsFilter(new PofExtractor(Long.class, 2), id);
Set<Map.Entry> xdEntries = QueryHelper.INSTANCE.query(xdmCtx, f, true, false, null);
logger.trace("deleteDocument; removing {} entries for docId: {}", xdEntries.size(), id);
for (Map.Entry xdEntry : xdEntries) {
//((BinaryEntry) xdEntry).remove(false);
Object xdKey = ((BinaryEntry) xdEntry).getBinaryKey();
//logger.trace("process; removing entry for key: {}", xdKey);
xdmCtx.getBackingMap().remove(xdKey);
//xdEntry.setValue(null);
//logger.trace("process; removing {} entries for docId: {}", xdEntry.size(), id);
}
docEntry.remove(false);
logger.trace("deleteDocument.exit; removed: {}", true);
}
示例4: createIndex
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@Override
public MapIndex createIndex(boolean ordered, Comparator comparator, Map rawMapIndex, BackingMapContext context) {
//noinspection unchecked,UnnecessaryLocalVariable
Map<ValueExtractor, MapIndex> mapIndex = rawMapIndex;
if (mapIndex.containsKey(this)) {
throw new IllegalArgumentException("Repetitive addIndex call for " + this);
}
MapIndex index = new TemporalIndex(this, context);
mapIndex.put(this, index);
return index;
}
示例5: TemporalIndex
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
/**
* Create a TemporalIndex - normally used by way of {@link org.acc.coherence.versioning.temporal.TemporalExtractor}
*
* @param extractor The temporal extractor to use to build the index
* @param context The map context for the cache on which the index is to be built.
*/
public TemporalIndex(TemporalExtractor extractor, BackingMapContext context) {
Validate.notNull(extractor);
this.extractor = extractor;
this.serialiser = context.getManagerContext().getCacheService().getSerializer();
this.timeLineIndex = new HashMap<Object, TimeLine>();
this.versionComparator = createVersionComparator(extractor.getVersionExtractor(), serialiser);
// Todo(ac): compare performance of SegmentedHashMap and HashMap for reverse indexes
}
示例6: mockSerialiserChain
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
private static BackingMapContext mockSerialiserChain() {
BackingMapContext context = mock(BackingMapContext.class);
BackingMapManagerContext managerContext = mock(BackingMapManagerContext.class);
CacheService service = mock(CacheService.class);
when(context.getManagerContext()).thenReturn(managerContext);
when(managerContext.getCacheService()).thenReturn(service);
when(service.getSerializer()).thenReturn(serialiser);
return context;
}
示例7: createIndex
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public MapIndex createIndex(boolean ordered, Comparator comparator, Map mapIndex, BackingMapContext context) {
MapIndex index = (MapIndex) mapIndex.get(this);
if (index != null || ordered) {
throw new IllegalArgumentException();
}
index = new BloomIndex(this);
mapIndex.put(this, index);
return index;
}
示例8: createElement
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
private Object createElement(BackingMapManagerContext ctx, XDMElement xdm, int docType) {
//XDMDataKey xdk = mFactory.newXDMDataKey(xdm.getElementId(), 0L); //xdm.getDocumentId());
XDMDataKey xdk = mFactory.newXDMDataKey(0L, 0); //xdm.getDocumentId());
Object xdk1 = ctx.getKeyToInternalConverter().convert(xdk);
BackingMapContext xdmCtx = ctx.getBackingMapContext(CN_XDM_ELEMENT);
BinaryEntry xdmEntry = (BinaryEntry) xdmCtx.getBackingMapEntry(xdk1);
if (xdmEntry == null) {
throw new IllegalStateException("XDM entry is null; means we're on the wrong partition! key: " + xdk);
}
if (xdmEntry.isPresent()) {
throw new IllegalStateException("XDM Entry with id " + xdmEntry.getKey() + " already exists");
}
//xdm.setPathId(mDictionary.translatePath(docType, xdm.getPath(), XDMNodeKind.fromPath(xdm.getPath())));
xdmEntry.setValue(xdm, false);
/*
if (xdm.getPath() != null) {
PathDocumentKey pdk = new PathDocumentKey(xdm.getPath(), xdm.getDocumentId());
Object pdk1 = ctx.getKeyToInternalConverter().convert(pdk);
BackingMapContext pdCtx = ctx.getBackingMapContext(CN_XDM_PATH_INDEX);
BinaryEntry pdEntry = (BinaryEntry) pdCtx.getBackingMapEntry(pdk1);
if (pdEntry == null) {
throw new IllegalStateException("Path entry is null; means we're on the wrong partition! key: " + pdk);
}
XDMIndex<Boolean> idx;
if (pdEntry.isPresent()) {
idx = (XDMIndex<Boolean>) pdEntry.getValue();
idx.addIndex(xdm.getDocumentId(), xdm.getDataId());
} else {
idx = new XDMIndex<Boolean>(xdm.getPath(), true, xdm.getDocumentId(), xdm.getDataId());
}
pdEntry.setValue(idx, false);
}
*/
//logger.trace("create.exit; store entry: {}", xdmEntry);
return xdmEntry.getKey(); //xdm.getId();
}
示例9: query
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public <T> Set<T> query(BackingMapContext backingMapContext, Filter filter,
boolean shouldReturnEntries, boolean shouldSort,
Comparator comparator) {
Map backingMap = backingMapContext.getBackingMap();
Map indexMap = backingMapContext.getIndexMap();
boolean matchAll = AlwaysFilter.INSTANCE.equals(filter);
Filter remainingFilter = null;
Object[] results;
if (matchAll || indexMap == null || !(filter instanceof IndexAwareFilter)) {
results = backingMap.keySet().toArray();
} else {
Set filteredKeys = new SubSet(backingMap.keySet());
try {
remainingFilter = ((IndexAwareFilter) filter).applyIndex(indexMap, filteredKeys);
} catch (ConcurrentModificationException e) {
filteredKeys = new SubSet(new ImmutableArrayList(backingMap.keySet().toArray()));
remainingFilter = ((IndexAwareFilter) filter).applyIndex(indexMap, filteredKeys);
}
results = filteredKeys.toArray();
matchAll = (remainingFilter == null);
}
int numberOfResults = 0;
if (matchAll && !shouldReturnEntries) {
numberOfResults = results.length;
} else {
for (Object key : results) {
Object value = backingMap.get(key);
if (value == null && !backingMap.containsKey(key)) {
continue;
}
Map.Entry entry = new QueryBinaryEntry((Binary) key, (Binary) value, null, backingMapContext);
if (matchAll || InvocableMapHelper.evaluateEntry(remainingFilter, entry)) {
results[numberOfResults++] = shouldReturnEntries ? entry : key;
}
}
}
boolean isLimitFilter = filter instanceof LimitFilter;
if (isLimitFilter || (shouldReturnEntries && shouldSort)) {
if (numberOfResults < results.length) {
Object[] copy = new Object[numberOfResults];
System.arraycopy(results, 0, copy, 0, numberOfResults);
results = copy;
}
if (shouldReturnEntries && shouldSort) {
if (comparator == null) {
comparator = SafeComparator.INSTANCE;
}
Arrays.sort(results, new EntryComparator(comparator));
} else if (shouldSort) {
Arrays.sort(results, comparator);
}
if (isLimitFilter) {
LimitFilter limitFilter = (LimitFilter) filter;
limitFilter.setComparator(null);
results = limitFilter.extractPage(results);
numberOfResults = results.length;
limitFilter.setComparator(comparator);
}
}
return new ImmutableArrayList(results, 0, numberOfResults).getSet();
}
示例10: keySet
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
public <T> Set<T> keySet(BinaryEntry entry, String cacheName,
Filter filter, boolean shouldSort, Comparator comparator) {
BackingMapContext backingMapContext = entry.getContext().getBackingMapContext(cacheName);
return query(backingMapContext, filter, false, shouldSort, comparator);
}
示例11: entrySet
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
public Set entrySet(BinaryEntry entry, String cacheName, Filter filter,
boolean shouldSort, Comparator comparator) {
BackingMapContext backingMapContext = entry.getContext().getBackingMapContext(cacheName);
return query(backingMapContext, filter, true, shouldSort, comparator);
}
示例12: QueryBinaryEntry
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
private QueryBinaryEntry(Binary key, Binary value,
Binary originalValue, BackingMapContext backingMapContext) {
super(key, value, originalValue, backingMapContext
.getManagerContext());
this.backingMapContext = backingMapContext;
}
示例13: getBackingMapContext
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@Override
public BackingMapContext getBackingMapContext() {
return backingMapContext;
}
示例14: getBackingMapContext
import com.tangosol.net.BackingMapContext; //导入依赖的package包/类
@Override
public BackingMapContext getBackingMapContext() {
throw new UnsupportedOperationException();
}