gpt4 book ai didi

org.infinispan.commons.marshall.WrappedByteArray类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 20:51:05 26 4
gpt4 key购买 nike

本文整理了Java中org.infinispan.commons.marshall.WrappedByteArray类的一些代码示例,展示了WrappedByteArray类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WrappedByteArray类的具体详情如下:
包路径:org.infinispan.commons.marshall.WrappedByteArray
类名称:WrappedByteArray

WrappedByteArray介绍

[英]Simple wrapper around a byte[] to provide equals and hashCode semantics
[中]围绕字节[]的简单包装,以提供equals和hashCode语义

代码示例

代码示例来源:origin: wildfly/wildfly

private byte[] marshall(Object key) {
  try {
    return (key instanceof WrappedByteArray) ? ((WrappedByteArray) key).getBytes() : this.ctx.getMarshaller().objectToByteBuffer(key);
  } catch (IOException | InterruptedException e) {
    throw new PersistenceException(e);
  }
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
public Object wrap(Object obj) {
 if (obj instanceof byte[]) return new WrappedByteArray((byte[]) obj);
 return obj;
}

代码示例来源:origin: org.infinispan/infinispan-commons

public boolean equalsWrappedBytes(WrappedBytes other) {
 int length = getLength();
 if (other.getLength() != length) return false;
 if (other.hashCode() != hashCode()) return false;
 for (int i = 0; i < length; ++i) {
   if (getByte(i) != other.getByte(i)) return false;
 }
 return true;
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
public boolean equals(Object o) {
 if (this == o) return true;
 if (o == null) return false;
 Class<?> oClass = o.getClass();
 if (getClass() != oClass) {
   return WrappedBytes.class.isAssignableFrom(oClass) && equalsWrappedBytes((WrappedBytes) o);
 }
 WrappedByteArray that = (WrappedByteArray) o;
 return Arrays.equals(bytes, that.bytes);
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

private static WrappedByteArray wrapId(byte[] id) {
 return new WrappedByteArray(id);
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
public Object unwrap(Object obj) {
 if (obj != null && obj.getClass().equals(WrappedByteArray.class))
   return WrappedByteArray.class.cast(obj).getBytes();
 return obj;
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
 public WrappedByteArray readObject(ObjectInput input) throws IOException {
   byte[] bytes = MarshallUtil.unmarshallByteArray(input);
   boolean hasHashCode = input.readBoolean();
   if (hasHashCode) {
    return new WrappedByteArray(bytes, input.readInt());
   } else {
    return new WrappedByteArray(bytes);
   }
 }
}

代码示例来源:origin: org.infinispan/infinispan-query

@Override
protected <K, V> void matchEvent(EventWrapper<K, V, CacheEntryEvent<K, V>> eventWrapper, Matcher matcher) {
 CacheEntryEvent<?, ?> event = eventWrapper.getEvent();
 Object instance = event.getValue();
 if (instance != null) {
   if (instance.getClass() == WrappedByteArray.class) {
    instance = ((WrappedByteArray) instance).getBytes();
   }
   matcher.match(eventWrapper, event.getType(), instance);
 }
}

代码示例来源:origin: org.infinispan/infinispan-core

private WrappedByteArray toUserObject(byte[] bytes) {
   return new WrappedByteArray(bytes);
  }
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
protected <K, V> void matchEvent(EventWrapper<K, V, CacheEntryEvent<K, V>> eventWrapper, Matcher matcher) {
 CacheEntryEvent<?, ?> event = eventWrapper.getEvent();
 Object instance = event.getValue();
 if (instance != null) {
   if (instance.getClass() == WrappedByteArray.class) {
    instance = ((WrappedByteArray) instance).getBytes();
   }
   matcher.match(eventWrapper, event.getType(), instance);
 }
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

boolean removeClientListener(byte[] listenerId, Cache cache) {
 Object sender = eventSenders.get(new WrappedByteArray(listenerId));
 if (sender != null) {
   cache.removeListener(sender);
   return true;
 } else return false;
}

代码示例来源:origin: org.wildfly/wildfly-clustering-infinispan-extension

private byte[] marshall(Object key) {
  try {
    return (key instanceof WrappedByteArray) ? ((WrappedByteArray) key).getBytes() : this.ctx.getMarshaller().objectToByteBuffer(key);
  } catch (IOException | InterruptedException e) {
    throw new PersistenceException(e);
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

private static WrappedByteArray byteArray() {
 return new WrappedByteArray(new byte[]{1});
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

private static TxWrite transform(Map.Entry<WrappedByteArray, ContextValue> entry) {
 ContextValue contextValue = entry.getValue();
 if (contextValue.removed) {
   return TxWrite.remove(entry.getKey().getBytes(), ControlByte.REMOVE_OP.set(contextValue.control),
      contextValue.versionRead);
 } else {
   return TxWrite.put(entry.getKey().getBytes(), contextValue.value, contextValue.lifespan, contextValue.maxIdle,
      contextValue.control, contextValue.versionRead);
 }
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

void removeEntry(HotRodHeader header, Subject subject, byte[] key, byte[] value) {
 log.trace("Call removeEntry");
 WrappedByteArray keyWrappped = new WrappedByteArray(key);
 WrappedByteArray valueWrapped = new WrappedByteArray(value);
 server.multimap(header, subject).remove(keyWrappped, valueWrapped).whenComplete(handleBoolean(header));
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
public int hash(Object o) {
 if (o instanceof byte[])
   return hash((byte[]) o);
 else if (o instanceof WrappedByteArray) {
   return hash(((WrappedByteArray) o).getBytes());
 }
 else if (o instanceof long[])
   return hash((long[]) o);
 else if (o instanceof String)
   return hashString((String) o);
 else
   return hash(o.hashCode());
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

void removeClientListener(byte[] listenerId) {
 clientListeners.remove(new WrappedByteArray(listenerId));
}

代码示例来源:origin: org.infinispan/infinispan-query

@Override
protected <K, V> void matchEvent(EventWrapper<K, V, CacheEntryEvent<K, V>> eventWrapper, Matcher matcher) {
 CacheEntryEvent<?, ?> event = eventWrapper.getEvent();
 Object oldValue = event.getType() == Event.Type.CACHE_ENTRY_REMOVED ? ((CacheEntryRemovedEvent) event).getOldValue() : null;
 if (event.getType() == Event.Type.CACHE_ENTRY_MODIFIED) {
   oldValue = ((EventImpl) event).getOldValue();
 }
 Object newValue = event.getValue();
 if (event.getType() == Event.Type.CACHE_ENTRY_EXPIRED) {
   oldValue = newValue;   // expired events have the expired value as newValue
   newValue = null;
 }
 if (oldValue != null || newValue != null) {
   if (oldValue != null && oldValue.getClass() == WrappedByteArray.class) {
    oldValue = ((WrappedByteArray) oldValue).getBytes();
   }
   if (newValue != null && newValue.getClass() == WrappedByteArray.class) {
    newValue = ((WrappedByteArray) newValue).getBytes();
   }
   matcher.matchDelta(eventWrapper, event.getType(), oldValue, newValue, joiningEvent, updatedEvent, leavingEvent);
 }
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

void containsEntry(HotRodHeader header, Subject subject, byte[] key, byte[] value) {
 log.trace("Call containsEntry");
 WrappedByteArray keyWrappped = new WrappedByteArray(key);
 WrappedByteArray valueWrapped = new WrappedByteArray(value);
 server.multimap(header, subject).containsEntry(keyWrappped, valueWrapped).whenComplete(handleBoolean(header));
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

private ClientNotificationManager add(WrappedByteArray id, ClientNotificationManager manager, byte version,
                   String counterName, Channel channel, VersionedEncoder encoder, ByRef<ListenerOperationStatus> status) {
 boolean useChannel = false;
 if (manager == null) {
   manager = new ClientNotificationManager(id.getBytes(), counterManager, channel, encoder);
   useChannel = true;
 }
 if (manager.addCounterListener(version, counterName)) {
   status.set(useChannel ? ListenerOperationStatus.OK_AND_CHANNEL_IN_USE : ListenerOperationStatus.OK);
   return manager;
 } else {
   status.set(ListenerOperationStatus.COUNTER_NOT_FOUND);
   return null;
 }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com