VERSANT Developer Center



Support & Discussions Forums

Forum Topic Overview

tschleicher
Topic posted 2009/12/10, 12:26 UTC+1

FastObjects j2 (10.0.8.184)
Hello,

the default sort order for string objects on indexes is ISO 14651. I know FastObject j2 supports also UNICODE sorting.
How can I switch the lexical order? I don't find anything in my manual or google for FOj2.

Example for default ISO 14651 sorting:

[classes\com.bla.Entry]
useIndexes = Index_For_Name
persistent = true

[indexes\Index_For_Name]
members = name
class = com.bla.Entry

Best regards



nbehncke
Comment posted 2010/02/01, 14:37 UTC+1

Hi,

In FastObjects j2 there is a system property available to disable lexical order (ISO 14651):
poet.navajo.index.disable_i18n=true

However, you have to take care that you write and read in a database using the same setting in your application.

Best regards,

Nils Behncke
Versant Team


tschleicher
Comment posted 2010/02/01, 15:03 UTC+1

Hello,

it works fine! Now it respects the String Comparable Smile
I don't need the iso 14651 string sorting order anywhere.


But for those people who need the iso sorting order in java and want to work with these, the String equals and startswith will not work, because of ignored characters. I found only one way to handle this:


private static final RuleBasedCollator instance = (RuleBasedCollator)RuleBasedCollator.getInstance(); // use default language, because versant string index use it, too

static {
instance.setStrength(Collator.PRIMARY);
}

private static boolean startsWith(String oneString, String twoString) {
final ISO14651CollationIterator oneStringIterator = new ISO14651CollationIterator(instance.getCollationElementIterator(oneString));
final ISO14651CollationIterator twoStringIterator = new ISO14651CollationIterator(instance.getCollationElementIterator(twoString));

while (oneStringIterator.hasNext() && twoStringIterator.hasNext())
if (oneStringIterator.next() != twoStringIterator.next())
return false;

return true;
}

private static final class ISO14651CollationIterator { // do not implement 'Iterator', cause next result 'int' not 'Integer'
private final CollationElementIterator iterator;

private int next;
private boolean noNext;

private ISO14651CollationIterator(CollationElementIterator iterator) {
this.iterator = iterator;
}

private int next() {
if (!hasNext())
throw new NoSuchElementException();

final int next = this.next;
this.next = 0;
return next;
}

private boolean hasNext() {
if (noNext)
return false;

while (next == 0) {
final int magicKey = iterator.next();
if (magicKey == CollationElementIterator.NULLORDER) {
noNext = true;
return false;
}
next = CollationElementIterator.primaryOrder(magicKey);
}
return true;
}
}


I don't think this solution is clean, because iso 14651 is language dependent (by the java propertys poet.navajo.index.language=EN / poet.navajo.index.country=US).
If the user switch the language of the OS, you can't change the language of the sorting order too. Otherwise the String Index will break in a painfull death... perhaps... :-/


The VDC Message Boards

What do I have to do to get started?
Before you can post messages to the message boards, you must register as a VDC Member. To register, create a new profile at VDC Member Area, see right-hand panel. If you already have signed-up for a VDC Member account you just need to logon.

Forum Guidelines


Site Search



Forum Search




Contact

Technical Questions:
Message Boards

Purchase Inquiries:
Versant Object Database
FastObjects .NET

General Questions:
Quick Message Form

For postal adresses, phone numbers,  e-mail addresses, driving directions etc please refer to:

Contact Details Overview


VDC Member Login

You are not logged in.

Joining the VDC Member Area is the best way to get the best out of the Versant Developer Center!

Registered User Login

Create New User Profile

Why sign-up?


young_guys_205.jpg

Now Hiring! Seeking good staff that take action on good stuff!

In today's fast paced world you want to be part of a company that is on the leading edge of technology? Join Versant!

More...

V Compact Icon

Online Database Reorganization for the Versant Object Database

Versant Vorkout lets you reclaim unused space in your database while it is in normal operation, increasing free space and improving performance.

More...

promo_university_205.jpg

Versant and German University Team Up to Grant Scholarship

Database Company supports Masters students enrolling in Databases / Information Systems through 2-year Scholarship

Press Release