use of org.neo4j.values.storable.TextArray in project neo4j by neo4j.
the class NodeEntityWrappingNodeValue method labels.
public TextArray labels(NodeCursor nodeCursor) {
TextArray l = labels;
if (l == null) {
try {
synchronized (this) {
l = labels;
if (l == null) {
List<String> ls = new ArrayList<>();
// No DBHits for Virtual node hacks.
var nodeLabels = node instanceof NodeEntity ? ((NodeEntity) node).getLabels(nodeCursor) : node.getLabels();
for (Label label : nodeLabels) {
ls.add(label.name());
}
l = labels = Values.stringArray(ls.toArray(new String[0]));
}
}
} catch (NotFoundException | IllegalStateException | StoreFailureException e) {
throw new ReadAndDeleteTransactionConflictException(NodeEntity.isDeletedInCurrentTransaction(node), e);
}
}
return l;
}
use of org.neo4j.values.storable.TextArray in project neo4j by neo4j.
the class NodeEntityWrappingNodeValue method writeTo.
@Override
public <E extends Exception> void writeTo(AnyValueWriter<E> writer) throws E {
if (writer.entityMode() == REFERENCE) {
writer.writeNodeReference(id());
} else {
TextArray l;
MapValue p;
try {
l = labels();
p = properties();
} catch (ReadAndDeleteTransactionConflictException e) {
if (!e.wasDeletedInThisTransaction()) {
throw e;
}
// If it isn't a transient error then the node was deleted in the current transaction and we should write an 'empty' node.
l = Values.stringArray();
p = VirtualValues.EMPTY_MAP;
}
if (id() < 0) {
writer.writeVirtualNodeHack(node);
}
writer.writeNode(node.getId(), l, p);
}
}
use of org.neo4j.values.storable.TextArray in project neo4j by neo4j.
the class TransportUnauthenticatedConnectionErrorIT method createHelloWithOversizeDeclaredList.
byte[] createHelloWithOversizeDeclaredList(Neo4jPack neo4jPack) throws IOException {
PackedOutputArray output = new PackedOutputArray();
Neo4jPack.Packer packer = neo4jPack.newPacker(output);
packer.packStructHeader(2, HelloMessage.SIGNATURE);
packer.packMapHeader(1);
packer.pack("x");
// list claims to be huge when it isn't
packer.packListHeader(Integer.MAX_VALUE);
TextArray labels = ALICE.labels();
for (int i = 0; i < labels.length(); i++) {
String labelName = labels.stringValue(i);
packer.pack(labelName);
}
return output.bytes();
}
use of org.neo4j.values.storable.TextArray in project neo4j by neo4j.
the class LuceneIndexValueValidatorTest method tooLongArrayIsNotAllowed.
@Test
void tooLongArrayIsNotAllowed() {
IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> {
TextArray largeArray = Values.stringArray(randomAlphabetic(MAX_TERM_LENGTH), randomAlphabetic(MAX_TERM_LENGTH));
VALIDATOR.validate(ENTITY_ID, largeArray);
});
assertThat(iae.getMessage()).contains("Property value is too large to index");
}
use of org.neo4j.values.storable.TextArray in project neo4j by neo4j.
the class Neo4jPackV1Test method shouldBeAbleToPackAndUnpackList.
@Test
void shouldBeAbleToPackAndUnpackList() throws IOException {
// Given
PackedOutputArray output = new PackedOutputArray();
Neo4jPack.Packer packer = neo4jPack.newPacker(output);
packer.packListHeader(ALICE.labels().length());
List<String> expected = new ArrayList<>();
TextArray labels = ALICE.labels();
for (int i = 0; i < labels.length(); i++) {
String labelName = labels.stringValue(i);
packer.pack(labelName);
expected.add(labelName);
}
AnyValue unpacked = unpacked(output.bytes());
// Then
assertThat(unpacked).isInstanceOf(ListValue.class);
ListValue unpackedList = (ListValue) unpacked;
assertThat(unpackedList).isEqualTo(ValueUtils.asListValue(expected));
}
Aggregations