StaticArrayEntry(Entry entry) { super(entry,entry.getValuePosition()); }
@Override public int compareTo(StaticBuffer other) { int otherLen = (other instanceof Entry)?((Entry) other).getValuePosition():other.length(); return compareTo(getValuePosition(),other, otherLen); }
@Override public int compareTo(StaticBuffer other) { int otherLen = (other instanceof Entry)?((Entry) other).getValuePosition():other.length(); return compareTo(getValuePosition(),other, otherLen); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; if (!(o instanceof StaticBuffer)) return false; final Entry b = (Entry) o; return getValuePosition() == b.getValuePosition() && compareTo(getValuePosition(), b, getValuePosition()) == 0; }
public static void writeEntry(DataOutput out, Entry entry) { VariableLong.writePositive(out,entry.getValuePosition()); writeBuffer(out,entry); if (!entry.hasMetaData()) out.putByte((byte)0); else { Map<EntryMetaData,Object> metadata = entry.getMetaData(); assert metadata.size()>0 && metadata.size()<Byte.MAX_VALUE; assert EntryMetaData.values().length<Byte.MAX_VALUE; out.putByte((byte)metadata.size()); for (Map.Entry<EntryMetaData,Object> metas : metadata.entrySet()) { EntryMetaData meta = metas.getKey(); out.putByte((byte)meta.ordinal()); out.writeObjectNotNull(metas.getValue()); } } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; if (!(o instanceof StaticBuffer)) return false; final Entry b = (Entry) o; return getValuePosition() == b.getValuePosition() && compareTo(getValuePosition(), b, getValuePosition()) == 0; }
public Stream<Object> query(final JointIndexQuery.Subquery query, final BackendTransaction tx) { final IndexType index = query.getIndex(); if (index.isCompositeIndex()) { final MultiKeySliceQuery sq = query.getCompositeQuery(); final List<EntryList> rs = sq.execute(tx); final List<Object> results = new ArrayList<>(rs.get(0).size()); for (final EntryList r : rs) { for (final java.util.Iterator<Entry> iterator = r.reuseIterator(); iterator.hasNext(); ) { final Entry entry = iterator.next(); final ReadBuffer entryValue = entry.asReadBuffer(); entryValue.movePositionTo(entry.getValuePosition()); switch(index.getElement()) { case VERTEX: results.add(VariableLong.readPositive(entryValue)); break; default: results.add(bytebuffer2RelationId(entryValue)); } } } return results.stream(); } else { return tx.indexQuery(index.getBackingIndexName(), query.getMixedQuery()).map(IndexSerializer::string2ElementId); } }
public static EntryList of(Iterable<Entry> entries) { Preconditions.checkNotNull(entries); int num=0; int dataLength=0; EntryMetaData[] metadataSchema = null; for (Entry entry : entries) { num++; dataLength+=entry.length(); if (metadataSchema==null) metadataSchema=StaticArrayEntry.ENTRY_GETTER.getMetaSchema(entry); dataLength+=getMetaDataSize(metadataSchema,entry,StaticArrayEntry.ENTRY_GETTER); } if (num==0) return EMPTY_LIST; byte[] data = new byte[dataLength]; long[] limitAndValuePos = new long[num]; int pos=0; CopyFactory cpf = new CopyFactory(data); for (Entry entry : entries) { cpf.addMetaData(metadataSchema,entry); entry.as(cpf); limitAndValuePos[pos]= getOffsetAndValue(cpf.dataOffset,entry.getValuePosition()); pos++; } assert cpf.dataOffset==data.length; assert pos==limitAndValuePos.length; return new StaticArrayEntryList(data,limitAndValuePos,metadataSchema); }
otherVertexId = VariableLong.readPositive(in); } else { in.movePositionTo(data.getValuePosition()); otherVertexId = VariableLong.readPositiveBackward(in); in.movePositionTo(data.getValuePosition()); in.movePositionTo(data.getValuePosition()); in.movePositionTo(data.getValuePosition()); relationId = VariableLong.readPositive(in); } else { in.movePositionTo(data.getValuePosition()); relationId = VariableLong.readPositiveBackward(in); endKeyPos = in.getPosition(); in.movePositionTo(data.getValuePosition()); other = readPropertyValue(in,key);